13.2 Portlet event handling

 <  Day Day Up  >  

The portlet programming model involves an event phase and a render phase in each request-response cycle.

  • The event phase is when the property broker delivers notifications to cooperative portlets and when the cooperative portlets can notify the property broker of property value changes. During the event phase, an action may be delivered on one portlet. If the property broker is used, this may result in other actions being triggered on other portlets.

  • The event phase is followed by the render phase, in which each portlet is asked to return markup, which is then aggregated in a single page. The markup may embed actions which can be invoked by the user . The page is then returned to the client (such as a browser).

At any point during the event phase, a portlet may explicitly publish the value of an output property to the property broker by invoking the changedProperties() method. This is an alternative to the declaration of output parameters for actions and binding the output parameter values to the request or session when the action is invoked. This may happen in the following cases:

  • In the callback method associated with the start of the event phase (beginEventPhase method)

  • In the invocation of the setProperties() method in a target portlet

  • In the portlet action method invocation

The publishing calls are dealt with by the property broker in the same manner as output parameters of actions: wires associated with output properties are examined and the property values propagated using the information in the target end of the wire.

Note : The process may continue recursively; however, the property broker detects loops and breaks them. Also, during the event phase of the subsequent request, the action is invoked on the corresponding target portlet or portlets.

Figure 13-1 illustrates a simplified version of cooperative portlets implemented using the programmatic approach.

Figure 13-1. Sample summary of a programmatic approach

graphics/13fig01.gif

In the general case using a programmatic approach, the source portlet needs to implement the following:

  1. Specify the C2A wrapper in the web.xml descriptor as explained in Chapter 12, "Cooperative portlets" on page 371.

  2. The property broker attribute needs to be initialized ; this can be done in the initConcrete() method.

  3. The portlet will need to register its output properties by using the registerProperties() method. This can be done by implementing a beginEventPhase() method so the portlet is notified when the event phase starts.

    Note : The EventPhaseListener interface requires that you also provide the endEventPhase() method. If needed, some cleanup can be done in this method.

  4. The source portlet publishes its output properties, for example when processing an action in the actionPerformed() method.

In a similar way, the target portlet needs to be updated as follows :

  1. Specify the C2A wrapper in the web.xml descriptor as explained in Chapter 12, "Cooperative portlets" on page 371.

  2. The property broker attribute needs to be initialized; this can be done in the initConcrete() method.

  3. The portlet will need to register its input properties by using the registerProperties() method. This can be done by implementing a beginEventPhase() method so the portlet is notified when the event phase starts.

  4. The target portlet implements the setProperties() method to be notified of property changes reported by other source portlets.

    Note : The target portlet must implement the PropertyListener interface.

 <  Day Day Up  >  


IBM WebSphere Portal V5 A Guide for Portlet Application Development
IBM Websphere Portal V5: A Guide for Portlet Application Development
ISBN: 0738498513
EAN: 2147483647
Year: 2004
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net