The Generic Application Container Framework within the Composite Application Infrastructure (CAI) allows for the declaration of events and actions to be executed when that event is fired.
Currently there are four events supported ‘out of the box’ within the container framework. These events are as follows:
The contentComplete event fires when the container completes loading its content within the current context. For example, in a web browser container application, the contentComplete event fires when the Web page has finished loading. dataChanged
The dataChanged event fires when there is a change in a wired property or if data changes within the context of the container application. An example of this would be if a wired property changes its value or if a field in a web form has been edited and the value has changed.viewInit
viewInit triggers within the createPartControl method of the container view. If a view lifecycle handler class is specified for the view lifecycle events, the init method is called when this event fires.viewClose
viewClose triggers in the dispose method of the container view (if the dispose method exists). If a view lifecycle handler is specified for the view lifecycle events, the close method is called when this event fires.
View lifecycle events
In order to properly define a view lifecycle event you can define this event much like any other event. The main difference is that a view lifecycle class handler can be specified in the plugin.xml
of the container up front. This class handles the two types of view lifecycle events. The other option when defining a view lifecycle event is to specify a class handler with the event itself. This is especially powerful since it allows you to define multiple view lifecycle events under different landmarks within the application each with different behavior.
The following plugin.xml
sample shows a view lifecycle event handler specified up front. It also shows a view lifecycle event defined with a class handler.
<!-- identify the container view ID that declares this web application -->
<!-- define custom actions here -->
<action id="my action" class="com.ibm.rcp.composite.container.browser.sample.actions.ShowDialog">
<!-- Define a custom view lifecycle here with a class -->
You can then define a viewInit
event along with an additional action that uses the predefined viewLifecycle
class handler as shown in the sample above.
<actionref id="my action" field="name:name" property="Contact Name"/>
Then, define the viewInit
event with a class handler.
<event id="viewInit" class="com.ibm.rcp.composite.container.browser.sample.lifecycle.OverrideViewLifecycle"/>
Creating an event handler class
When defining a view lifecycle handler class you must extend the class com.ibm.rcp.composite.container.core.events.LifecycleEventHandler
. This class implements the Lifecycle interface which defines the init
methods. All other custom event handlers you create must extend the com.ibm.rcp.composite.container.core.events.EventHandler
Parent topic: Generic application container framework: XPD621