Viewer Events is a mechanism that allows to interact at the bean level during the life-cycle of a server request. The request life-cyle is depicted in figure 1. There are several points in the request life-cycle in which you can interact, the list is in the following table:
Property | Description |
---|---|
onCreateViewPhase | Occurs the first time a viewer is displayed |
onRestoreViewPhase | Occurs whenever a request is made to the viewer and it has already been initialized |
beforeApplyRequestValuesPhase | Occurs before applying request parameters to the components |
afterApplyRequestValuesPhase | Occurs after applying request parameters to the component |
beforeUpdateModelPhase | Occurs before applying component values to beans/XEO Model instances |
afterUpdateModelPhase | Occurs after applying component values to beans/XEO Model instances |
beforeRenderPhase | Occurs before rendering the current view |
afterRenderPhase | Occurs after rendering the current view |
All these properties (events) accept an EL Expression to a method with the following signature:
public void myEventMethod( PhaseEvent e);
Let's see an example:
Viewer Declaration:
<xvw:viewer beanClass='MyBean' beanId='viewBean' afterUpdateModelPhase= '#{viewBean.afterUpdateModel}' afterRenderPhase= '#{viewBean.phaseEvent}' >
Bean:
public class MyBean { public void afterUpdateModel( PhaseEvent e ) { System.out.println( "After update Model!!" ); } public void afterRender( PhaseEvent e ) { System.out.println( "Before update Model!!" ); } }
The life-cycle of a server request is depicted in figure 1, bellow:
Figure 1 - The life-cycle of a server request
_
No permission to view TWiki.WebTopBar