When a dsp:setvalue tag is rendered, it invokes the same methods as events processed from a form. This includes calling both the appropriate setX and handleX methods. For example, consider the following tag:

<dsp:setvalue bean="/test/Person1.name" value="Frank"/>

As Dynamo renders the page, it encounters this tag. It first calls setName("Frank") on the /test/Person1 component, if a setName method exists for the class that Person1 is an instance of.

After calling setName, Dynamo then checks to see if a handleName method exists. If so, handleName is called. In other words, Dynamo goes through the same process as it does when the property values are set from a form input tag.

You can use this technique with a form handler to set up aspects of the form before it is displayed and handled. For example, you might want to display the form only to users who are over the age of 13. You can write a handleAge method for your form handler that returns false if the user is under 13. The page might contain something like this:

<dsp:setvalue bean="MyFormHandler.age" paramvalue="currentUser.age"/>

<dsp:form action=...>

In this example, before the form is displayed, the setvalue statement sets the value of the form handler’s age property to the value of the currentUser.age parameter. (Presumably, this parameter is set from information stored when the user registered.) Setting the age property causes the form handler’s handleAge method to be invoked. If age is less than 13, this method returns false, and Dynamo does not render the rest of the page (including the form). If age is 13 or greater, handleAge returns true, and the rest of the page is rendered.

loading table of contents...