Hi
I was trying to create one form for portal with some input fields and a "SAVE" Button. Once I Click on the submit button, it suppose to display the details which I enter. But it is not working. Here is the code. Can you please check the code and correct it?
package Abstract;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
import com.sapportals.portal.prt.component.IPortalComponentURI;
import com.sapportals.portal.prt.event.IPortalRequestEvent;
public class UsingAbstractPortalComponent extends AbstractPortalComponent {
private final static int INITIAL_STATE = 0;
private final static int WELCOME_STATE = 1;
private int state = INITIAL_STATE;
private String fname = "";
private String lname = "";
private String sappn = "";
private String email = "";
private String center = "";
private String isuper = "";
private String phno = "";
private IPortalComponentURI uri;
//Fill in your output for "normal" content creation mode here
protected void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
System.out.println("doContent");
response.write("<h3><font color = blue>eLearning Logon Request</font></h3>");
switch (state) {
case INITIAL_STATE:
if (fname == null)
fname = "";
// create a uri for the event
uri = request.createPortalComponentURI();
uri.setPortalRequestEvent(request.createRequestEvent("compute"));
response.write("<form action=\"" + uri.toString() +
"\" method=\"post\">" + "<table>" + "<tr><td>" + "First Name" + "</td>" +
"<td>" + "<input type=\"text\" fname=\"expression\" value=\"" +
fname + "\">" + "</td></tr>" + "<tr><td>" + "Last Name" + "</td>" +
"<td>" + "<input type=\"text\" lname=\"expression\" value=\"" +
lname + "\">" + "</td></tr>"+ "<tr><td>" +
"SAP P# (employee #)" + "</td>" +
"<td>" + "<input type=\"text\" sappn=\"expression\" value=\"" +
sappn + "\">" + "</td></tr><tr><td>" +
"FSI E-mail Address" + "</td>" +
"<td>" + "<input type=\"text\" email=\"expression\" value=\"" +
email + "\">" + "</td></tr><tr><td>" +
"Center/Location" + "</td>" +
"<td>" + "<input type=\"text\" center=\"expression\" value=\"" +
center + "\">" + "</td></tr><tr><td>" +
"Immediate Supervisor" + "</td>" +
"<td>" + "<input type=\"text\" isuper=\"expression\" value=\"" +
isuper + "\">" + "</td></tr><tr><td>" +
"Phone Number" + "</td>" +
"<td>" + "<input type=\"text\" phno=\"expression\" value=\"" +
phno + "\">" + "</td></tr>" + "<tr><td></td><td>" +
"<input type=\"submit\" value=\"" + "Display" + "\">" +
"</td></tr>" + "</table>" + "</form>");
break;
case WELCOME_STATE:
if (fname != null)
// create a uri for the event
uri = request.createPortalComponentURI();
uri.setPortalRequestEvent(request.createRequestEvent("back"));
response.write("<form action=\"" + uri.toString() +
"\" method=\"post\">" + "<table>" + "<tr><td>" + "First Name " + fname + "</td></tr>" +
"<tr><td>" + "Last Name " + lname + "</td></tr>" +
"<tr><td>" +
"<input type=\"submit\" value=\"" + "Go back" + "\">" +
"</td></tr>" + "</table>" + "</form>");
break;
default:
//should never happen
}
;
}
public void doCompute(IPortalComponentRequest request, IPortalRequestEvent event) {
System.out.println("doCompute");
try {
fname = event.getData().getAttribute("expression");
state = WELCOME_STATE;
} catch (NullPointerException npe) {
}
}
public void doBack(IPortalComponentRequest request, IPortalRequestEvent event) {
System.out.println("doBack");
fname = "";
state = INITIAL_STATE;
}
}
Thanks in Advance
TT
_________________
Hi "TT",
just a general advise for submitting issues: If something does not work, try to minimize your example. No more characters than needed. And be precise about your problem, report what you would expect and what in fact happens. As precise as possible.
Following this, you will get double attraction!
Best regards
Detlev
Add a comment