Chapter 2. Simple notifications 63
Notification Services user group created. The following values are used in
this scenario:
Intelligent Notification Services user ID: GRB
Intelligent Notification Services user group name: Friends
Users belonging to the Friends group: ANG and MRR. These users
must be Intelligent Notification Services users.
Refer to Chapter 1, “Intelligent Notification Services” on page 1 for details
on how to create and configure Intelligent Notification Services users and
groups.
WebSphere Portal server or WebSphere Everyplace Access server where
you install and run the simple notification sample portlet.
A Pocket PC device or Pocket PC emulator is needed to access the
sample portlet (optional).
2.2.2 Sample application development
This section explains how to develop a simple notification portlet using
WebSphere Studio Site Developer.
1. Create a Portlet Application Project:
a. Start IBM WebSphere Studio Site Developer and select File
New
Project.
b. Select Portlet Development from the left panel and Portlet Application
Project from the right panel. Click Next.
c. Enter a project name. In this example it is SimpleNotification. Select the
options Create basic portlet and Configure advanced options. Click
Next.
d. Set the Enterprise Application project settings, context root, and J2EE
level. Take the default values for this example. Click Next.
e. Define the general settings of the basic portlet. Take the default values for
this example. Click Next.
f. Define the event handling options of the portlet. Take the default values for
this example. Click Next.
Note: You can also install the sample portlet in the same WebSphere
Everyplace Access server that is running Intelligent Notification
Services.
64 IBM WebSphere Everyplace Access V5, Volume IV: Advanced Topics
g. Define the single sign-on options of the portlet. Take the default values for
this example. Click Next.
h. Select miscellaneous options of the portlet. For this example select the
Add pda markup support option. Click Finish to create the project.
2. Include in the Java classpath the Intelligent Notification Services JAR files
insUtil.jar and insNmClient.jar that are located in the ins_home\lib directory,
where ins_home is in the installation directory, C:\Program
Files\WebSphere\INS.
a. Right click Project Name
Properties Java Build Path
Libraries.
b. Click Add External JARs... and browse the JAR files.
c. Click OK. The portlet structure in the Project Navigator panel of the
WebSphere Studio Site Developer should be similar to the structure that is
shown in Figure 2-2 on page 65.
Chapter 2. Simple notifications 65
Figure 2-2 Simple notification portlet structure in WebSphere Studio
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);
}
}
Chapter 2. Simple notifications 67
4. Open and modify the portlet session bean Java file. In our example it is the
SimpleNotificationPortletSessionBean.java file.
a. Import required packages, as shown in Example 2-3.
Example 2-3 Import packages
import javax.naming.Context;
import java.util.*;
import com.ibm.pvc.ins.nm.client.*;
import com.ibm.pvc.ins.nm.server.NotificationServiceLocal;
import com.ibm.pvc.ins.nm.server.Request;
import com.ibm.pvc.ins.nm.server.NotificationService;
b. Declare variables and define set and get methods for all the fields in the
form, as shown in Example 2-4.
Example 2-4 Variables and methods for the fields
public class SimpleNotificationPortletSessionBean {
private String formText = "";
private String formSubject = "";
private String formTo = "";
private String formToUID = "";
private String formFromUID = "";
private String formPriority = "";
private boolean flag = false;
public void setFormText(String formText) {
this.formText = formText;
}
public void setFormSubject(String formSubject) {
this.formSubject = formSubject;
}
public void setFormTo(String formTo) {
this.formTo = formTo;
}
public void setFormToUID(String formToUID) {
this.formToUID = formToUID;
}
public void setFormFromUID(String formFromUID) {
this.formFromUID = formFromUID;
}
public void setFormPriority(String formPriority) {
this.formPriority = formPriority;

Get IBM WebSphere Everyplace Access V5 Handbook for Developers and Administrators Volume IV: Advanced Topics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.