Model Glue has a bunch of handy and cool features. I can’t say I have a favorite - but one of my favorites is the event forwarding option and the fact that it will pass the state object along to the next event.

For instance I have a huge form that a user can fill out with a lot of check- boxes (part of an audit). When they submit the form the first thing I have to do is make sure the audit name they provided doesn’t exist - if it does I send them back to the form, let them know they need to enter a new name, and repopulate the entire form.

Without the framework I would have had to create my own function to move all that form data back to the form. But, with the frame work I just have to add one more line to my ModelGlue.xml file and one line to my controller handling the audit save event (set the reslt to “duplicateName”).

<result name="success" redirect="true" do="viewAuditResults"
append="auditID,statusMessage" />
<result name="duplicateName" redirect="true" do="enterAuditResults"
append="auditID,statusMessage,method,impactID" />

Comments

Bill

you are right, ajax would be good here (and in fact is already used). However, the app has to work without javascript as well so the use case I’m describing is really more for when javascript is disabled.

thanks for the suggestion though.

Gus

Bill,

This is actually a pretty good use case for AJAX.

When the user enters the audit name, fire an onChange event that checks if the name exists and let the user know the name is taken without even submitting the form.

Gus