As described in the Creating Forms chapter of the ATG Page Developer’s Guide, you can create forms in JavaServer Pages that set values of properties of Nucleus components directly when the form is submitted. For example, this tag creates an input field for the user to enter his or her age:

<dsp:input type="text" bean="/samples/Person1.age"/>

When the user submits the form, the /samples/Person1.age property is set to the value entered in the input field.

For more complex form handling operations, setting the values of properties directly is not always desirable. It is generally preferable to first submit the form to a form handler. The form handler can evaluate the validity of the data, check for errors, and determine what action to take—for example, submit the data, direct the user to a different page, and display an error message. Often when you use a form handler, the form input fields are associated with properties of the form handler rather than the component you ultimately want to modify. For example, your form might include this tag:

<dsp:input type="text" bean="MyFormHandler.age"/>

When the form is submitted, a method of MyFormHandler associated with the age property is invoked. Depending on how this method is written, it might validate the data and then set the value of Person1.age, or use the data to fill in a record in a database.

A form handler class must include one or more handler methods. A handler method is typically invoked when the user clicks the submit button, and handles the processing of the form. Depending on the purpose of the form handler, it can have several different handler methods that each perform a different operation. For example, a form handler that works with user profiles might have separate handler methods for creating the profile, modifying the profile, and logging the user in.

loading table of contents...