66 IBM WebSphere Everyplace Access V5, Volume IV: Advanced Topics
3. Open and modify the portlet Java file. In our example is
SimpleNotificationPortlet.java file.
a. Include a constant for each field in the form, as shown in Example 2-1.
Example 2-1 Public constants
public class SimpleNotificationPortlet extends PortletAdapter implements
ActionListener {
public static final String FROMUID =
"simplenotification.SimpleNotificationPortletFromUID";
public static final String TO =
"simplenotification.SimpleNotificationPortletTo";
public static final String TOUID =
"simplenotification.SimpleNotificationPortletToUID";
public static final String TEXT =
"simplenotification.SimpleNotificationPortletText";
public static final String SUBJECT =
"simplenotification.SimpleNotificationPortletSubject";
public static final String PRIORITY=
"simplenotification.SimpleNotificationPortletPriority";
b. In the actionPerformed method, set all the fields of the form in the session
bean, as shown in Example 2-2.
Example 2-2 Set fields in session bean
public void actionPerformed(ActionEvent event) throws PortletException {
if( getPortletLog().isDebugEnabled() )
getPortletLog().debug("ActionListener - actionPerformed called");
String actionString = event.getActionString();
PortletRequest request = event.getRequest();
SimpleNotificationPortletSessionBean sessionBean = getSessionBean(request);
if( FORM_ACTION.equals(actionString) ) {
sessionBean.setFormFromUID(request.getParameter(FROMUID));
sessionBean.setFormTo(request.getParameter(TO));
sessionBean.setFormToUID(request.getParameter(TOUID));
sessionBean.setFormText(request.getParameter(TEXT));
sessionBean.setFormSubject(request.getParameter(SUBJECT));
sessionBean.setFormPriority (request.getParameter(PRIORITY));
sessionBean.setFlag(true);
}
}