User interface artifacts
Independent of the type of user interface artifact to integrate, for example, form, widget, standard portlet, the requirement is the same. The only thing required from that artifact is that it can send and receive JSR-286 events. Therefore, we implement or reuse JSR-286 compliant portlets that send and receive such events. To integrate forms or widgets, use such a portlet as a wrapper for these artifacts.
For more information about developing portlets, read the information about Developing portlets in the WebSphere Portal v8.0 product documentation. The following section provides a brief outline about what we need to do to ensure the portlets send and receive events.
Example: We need to develop two portlets:
- The portlet1 must be able to receive an event with the QName e0 and to send an event with the QName e1.
- The portlet2 must be able to receive an event with the QName e1 and to send an event with the QName e2.
When portlet1 sends the event e1, the user is routed from portlet1 to portlet2. This behavior matches the transition described later in code sample 9.
To enable portlet1 to receive and send the mentioned events, we need to do the following two things:
- Specify the events in theportlet.xml file of the portlet. For more information, read code sample 1.
- Include code in the portlet that can handle an incoming event and code that can send an event. For more information, read code sample 2.
Code sample 1:
01 <portlet id="portlet1"> 02 ... 03 <supported-processing-event> 04 <qname>e0</qname> 05 </supported-processing-event> 06 <supported-publishing-event> 07 <qname>e1</qname> 08 </supported-publishing-event> 09 </portlet> 10 11 <event-definition> 12 <qname>e0</qname> 13 <value-type>java.lang.String</value-type> 14 </event-definition> 15 <event-definition> 16 <qname>e1</qname> 17 <value-type>java.lang.String</value-type> 18 </event-definition>Code sample 2:
01 @Override 02 public void processAction(ActionRequest request, ActionResponse response) 03 throws PortletException, IOException { 04 // ... 05 06 response.setEvent(new QName("e1", "xyz"), new String()); 07 } 08 09 @Override 10 public void processEvent(EventRequest request, EventResponse response) 11 throws PortletException, IOException { 12 13 final Event event = request.getEvent(); 14 // ...Make similar changes to portlet 2. See code samples 3 and 4.
Code sample 3:
01 <portlet id="portlet2"> 02 ... 03 <supported-processing-event> 04 <qname>e1</qname> 05 </supported-processing-event> 06 <supported-publishing-event> 07 <qname>e2</qname> 08 </supported-publishing-event> 09 </portlet> 10 11 <event-definition> 12 <qname>e1</qname> 13 <value-type>java.lang.String</value-type> 14</event-definition> 15 <event-definition> 16 <qname>e2</qname> 17 <value-type>java.lang.String</value-type> 18 </event-definition>Code sample 4:
01 @Override 02 public void processAction(ActionRequest request, ActionResponse response) 03 throws PortletException, IOException { 04 // ... 05 06 response.setEvent(new QName("e2", "xyz"), new String()); 07 } 08 09 @Override 10 public void processEvent(EventRequest request, EventResponse response) 11 throws PortletException, IOException { 12 13 final Event event = request.getEvent(); 14 // ...
Parent Core Concepts