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 ready-to-use events 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 event occurs 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 life cycle handler class is specified for the view life cycle 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 life cycle handler is specified for the view life cycle events, the close method is called when this event fires.
View life cycle events
To properly define a view life cycle event, you can define this event much like any other event. The main difference is that a view life cycle class handler can be specified in the plugin.xml
of the container up front. This class handles the two types of view life cycle events. The other option when defining a view life cycle event is to specify a class handler with the event itself. This is especially powerful because it allows you to define multiple view life cycle events under different landmarks within the application, each with different behavior.
The following plugin.xml
sample shows a view life cycle event handler specified up front. It also shows a view life cycle 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 life cycle handler class you must extend the class com.ibm.rcp.composite.container.core.events.LifecycleEventHandler
. This class implements the life cycle interface that 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