Xoetrope

 Wiki : PojoEvents

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
XUI 4.0

POJO Event Handling


Prior to XUI 4.0 it was not possible to access the methods of a POJO via XUI's event handling and this meant that the page class had to contain a proxy method to invoke method on the POJO. As of version 4.0 POJO methods can be invoked by specifying them as any other event

	    <Events>
	      <Event target="saveBtn" method="${pojo/myModel.saveStuff(pojo/model/myDataObject)}" 
	                 type="com.xoetrope.pojo.SaveBeforeActionHandler"/>
	    </Events>


when the event handler finds a slash (/) in the method specification it assumes it is dealing with a model node. Using this approach the path pojo/myModel is assumed to be a model node wrapping a POJO which contains the method saveStuff. The method may take arguments which in turn can point to model nodes. In the above example the argument pojo/model/myDataObject is also assumed to be a model node.

As the event handling declarations are processed when the page is loaded the event handler stores a reference to the model model implementing the method and also the model nodes providing the arguments.

During the life of an application the content of the model nodes may change and therefore the event handler does not normally get the content of the node till it needs to invoke the target method. However during setup the event handler gets the POJO wrapped by the model node so as to determine the class and locate the method to be used in handling the event. Therefore the object/POJO contained within the model node should remain consistent throughout the life of the application, or at least whenever the event handler is invoked.

If you want to fix the POJO used by the event handler then prefix the path with a / to make it an absolute node reference. In such a case the POJO is accessed immediately that the event handler declaration is processed and the POJO reference is accessed and retained.

There are no comments on this page. [Add comment]

Page was generated in 0.1706 seconds