-
Notifications
You must be signed in to change notification settings - Fork 24
Exit Events
The concept of an eXitEvent (XE) is derived from the Fusebox practice of eXitFuseAction, whereby event names are not hard-coded into views, but referenced as event arguments defined in the configuration. This practice provides at least two advantages:
- Renaming an event-handler only requires a change to the name referenced in the configuration file(s).
- Related events are clearly indicated in the configuration, making the configuration file itself somewhat self-documenting, and maintenance of the application simpler.
Consider a simple contact list application in which a user may list the contacts, add a new contact, and edit or delete an existing contact. Assuming that we can add and edit from the same event (by determining the final action to be taken by the value of a key field), we need 4 event-handlers:
- list
- edit
- save
- delete
In terms of application flow:
- from the list of contacts, the user may edit or delete a contact.
- upon editing or creating a new contact, the user may save the contact.
In our configuration file, we can indicate these relationships by using XEs.
<event-handler event="listContacts" access="public">
<event-arg name="xe.edit" value="editContact" />
<event-arg name="xe.delete" value="deleteContact" />
<notify listener="contactListener" method="list" resultArg="results" />
<view-page name="listView" contentArg="content"/>
</event-handler>
<event-handler event="editContact" access="public">
<event-arg name="xe.save" value="saveContact" />
<notify listener="contactListener" method="read" resultArg="results" />
<view-page name="editView" contentArg="content"/>
</event-handler>
<event-handler event="saveContact" access="public">
<notify listener="contactListener" method="save" />
<redirect event="listContacts" />
</event-handler>
<event-handler event="deleteContact" access="public">
<notify listener="contactListener" method="delete" />
<redirect event="listContacts" />
</event-handler>
XEs are referenced as event args in the view pages, e.g., the form action in the editContact view page in the editContact event would reference the XE for "saveContact" as the event-arg:
<form action="#BuildURL(event.getArg('xe.save'))#" ... >
</form>