IBM WebSphere Portal V5 A Guide for Portlet Application Development
Authors: Rodriguez J.R. Chan S. Gonzalez B.
Published year: 2004
Pages: 29-30/148
Buy this book on amazon.com >>
 <  Day Day Up  >  

2.14 PropertyListener interface

This interface is implemented for cooperative portlets using the programmatic approach. This interface may optionally be implemented by portlets. It is an alternate mechanism by which interested portlets may be notified of changed properties.

Other options are to be notified through portlet actions (the actionPerformed method of the ActionListener interface), or Struts actions. The PropertyListener interface may be implemented by portlets that only wish to update their current state based on property changes, rather than execute an action immediately. For more information and a sample scenario of a portlet using this interface, see Chapter 13, "Advanced cooperative portlets" on page 413.

Note: The PropertyListener interface requires that you implement the setProperties method to be notified of property changes.

setProperties

Invoked by the Property Broker to deliver new property values which were changed in the current event cycle of the current request. The Property Broker may be notified of such changes when a portlet invokes the changedProperties in the PropertyBrokerService interface (explicit notification), or when a portlet action which has declared output parameters is invoked (implicit notification).

This method is only invoked during the event phase. Since multiple explicit or implicit property change notifications may be made during an event cycle, one or more setProperties calls may be invoked on a single portlet instance during a single event cycle. The runtime may batch property values from multiple changedProperties calls in a single setProperties call. All properties are guaranteed to be delivered before the first endEventPhase call is delivered, which marks the start of the render phase.

Source cooperative portlets report property changes may be made by using the changedProperties method.

changedProperties method

This method publishes changes in properties and may be used during the portlet's event phase only. This includes the beginEventPhase method of the EventPhaseListener interface, the actionPerformed method of the ActionListener interface, and the setProperties method of the PropertyListener interface.

All properties must have been registered earlier, implicitly or explicitly. A simpler alternative to explicitly invoking this method is often applicable . For example, declare output parameters for registered actions (either programmatically or via an WSDL declaration). In this case, the action may bind the values of the output parameters on invocation, and at runtime the values will be transferred as if the changedProperties method had been explicitly invoked.

 <  Day Day Up  >  
 <  Day Day Up  >  

2.15 EventPhaseListener interface

This interface is mainly for programmatic cooperative portlets. It allows developers to get control of the portlet before the portlet receives a notification of a changed property. For more information and a sample scenario of a portlet using this interface, see Chapter 13, "Advanced cooperative portlets" on page 413.

This interface provides the following methods :

  • beginEventPhase() : 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 callback method associated with the start of the event phase (beginEventPhase()), in the invocation of the setProperties() method, or in the portlet action method invocation.

    Such publish 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. To register properties, you will use the beginEventPhase method of EventPhaseListener, because only during the event phase is it possible to register and unregister properties.

  • endEventPhase() :the property broker guarantees the completion of all property value notifications to target portlets by the end of the event phase, whether through portlet actions or through the special setProperties() method. The end of the event phase is indicated by the invocation of the endEventPhase() method.

    During the render phase of each request cycle, source portlets can write visual controls representing source data to their output stream. The end user interacts with the visual control in the response to trigger one or more actions on other portlets on the page. During the event phase of the subsequent request, the action is invoked on the corresponding target portlet or portlets.

 <  Day Day Up  >  
IBM WebSphere Portal V5 A Guide for Portlet Application Development
Authors: Rodriguez J.R. Chan S. Gonzalez B.
Published year: 2004
Pages: 29-30/148
Buy this book on amazon.com >>