Sets up a form for user input.
<dsp:form method="{get|post}"[
action="jsp-page
"]
[
synchronized="component-spec
"]
[
formid="id
"]
[
requiresSessionConfirmation="{true|false}"]
/>
Attributes
method
Specifies the action the ATG platform should perform with the data associated with the dsp:input
tags:
get
retrieves the value in the component property indicated in thedsp:input
bean
attribute and displays it in the input field.post
performs theget
operation and saves updated data in the input field to the same bean properties.
action
Designates the JSP to display on form submission. If no value is provided, the page holding the dsp:form
tag is displayed upon form submission.
Note: If a form’s contents are not on the same page as the dsp:form
tag, the dsp:form
tag must include the action
attribute.
synchronized
Specifies the Nucleus path and name of a component that is blocked from accepting other form submissions until this form is submitted. If a form uses a form handler that is global or session scoped, new data is liable to overwrite its data before it is saved to the database. See Synchronizing Form Submissions for more information.
formid
Assigns a unique identifier to the form. Forms require unique identifiers when a page specifies multiple forms and conditionally displays only one of them. By providing a form ID, the page compiler can distinguish one form from another.
Note: You can also use hidden input fields to differentiate various forms. This mechanism is especially useful when you generate multiple forms dynamically; in this case, you can test the value of each form’s hidden input field to determine which form to render.
requiresSessionConfirmation
If set to true, prevents cross-site attacks. The HTTP request that is generated on form submission supplies the request parameter _dynSessConf
, which contains a randomly generated session long number that is associated with the current session. On receiving this request, the request-handling pipeline validates _dynSessConf
against the current session’s confirmation number. If it detects a mismatch or missing number, it blocks further request processing.
Usage Notes
dsp:form
lets you set up a form that accepts user inputs, which are saved as component properties. The methods associated with form operations process JSP tags into forms, validate user-entered data, and manage errors. For more information, see Forms.
Note: The dsp:form
tag uses the iclass
attribute in place of the cascading stylesheet class
attribute to avoid using a Java-reserved word in Java code.
Example
<dsp:form action="FacilitySchedule.jsp" method="post" synchronized="/atg/droplet/FacilityFormHandler"> Room you'd like to reserve: <dsp:select bean="Classroom.roomNumbers"> <p><dsp:option value="10">10</dsp:option> <p><dsp:option value="12">12</dsp:option> <p><dsp:option value="14">14</dsp:option> <p><dsp:option value="16">16</dsp:option> <p><dsp:option value="20">20</dsp:option> </dsp:select> <p>Course Title: <dsp:input type="text" bean="FacilityFormHandler.course"/> <p>Instructor: <p><dsp:input type=radio bean="FacilityFormHandler.instructor" value="pear">Ms. Pear</dsp:input></p> <p><dsp:input type=radio bean="FacilityFormHandler.instructor" value="apricot"/>Mr. apricot</dsp:input> <p><dsp:input type=radio bean="FacilityFormHandler.instructor" value="cantelope"/>Ms. Cantelope</dsp:input> <p><dsp:input type=radio bean="FacilityFormHandler.instructor" value="pineapple">Mr. Pineapple</dsp:input> <dsp:input type="submit" value="Reserve Room" bean="FacilityFormHandler.create"/> </dsp:form>
This example demonstrates a form for reserving a classroom. Using this form, a user can specify:
desired room (drop-down list)
course title (text box)
teacher’s name (group of radio buttons)
When a user clicks Reserve Room, the entered data is saved to the FaciltyFormHandler
and authorized, and when data is approved as valid, saved to the database.
Because this example uses the post
method, the form is pre-populated with the data last-saved to FacilityFormHandler
—for example, 16, Geometry 101, Ms. Pear. There are no specific failure or success instructions; after form submission, FacilitySchedule.jsp
is displayed as specified by the form’s action
attribute.