-
Notifications
You must be signed in to change notification settings - Fork 12
Adding Specific Event Handlers
TOC(heading=Scaffolds Section Contents, HowTos/HowToUseScaffolds*) By default, the tag adds five event-handlers: table''.list, ''table''.view, ''table''.edit, ''table''.commit, ''table.delete.
However, you may not want all of these added by default. To adjust the list of scaffolds to automatically create, change the value of the DefaultScaffolds property of the ModelGlueConfiguration bean in ColdSpring.xml. For example, to only automatically create view and list scaffolds, the tag would be changed to the following:
<property name="defaultScaffolds">
<value>list,view</value>
</property>
Edit, commit, delete, and delete scaffolds are still available, but would need to be specified in the scaffold tag's TYPE attribute (see below).
For a given scaffold tag, you may specify the list of event-handlers to create by using the TYPE attribute of the scaffold tag. This is especially useful for applying functionality such as security.
For example, in a given application where anyone can view contacts but only administrators can update contacts, we could use the following XML in ModelGlue.xml to protect the edit, commit, and delete event handlers from unauthorized access (assuming a message listener for "UserMustBeAdministrator" performs security functionality and adds a result named "SecurityViolation" in the event of bad access):
<scaffold object="contact" type="list,view" />
<scaffold object="contact" type="edit,commit,delete">
<broadcasts>
<message name="UserMustBeAdministrator" />
</broadcasts>
<results>
<result name="SecurityViolation" do="SecurityViolation" redirect="true" />
</results>
</scaffold>