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.

Attributes

FormName:action

The action attribute designates the JSP to display on form submission. If a value is not provided explicitly, the page holding the dsp:form tag is displayed upon form submission. Note that when a form’s contents are on a different page than the dsp:form tag (for example, the form is on a JSP and it includes the form body which is on a JSP fragment), you must provide an explicit value for the action attribute.

DataOperation:method(Required)

The method attribute specifies the action the ATG platform should perform with the data associated with the dsp:input tags. The options include get and post.

LockingaComponent:synchronized

The synchronized attribute ensures that the form handler component you want to update is unavailable for other processes. If your form uses a form handler that is global or session scoped, new data might overwrite your data before it is saved to the database. The synchronized attribute accepts the Nucleus path and component name that is blocked from submissions initiated by a form other than the one containing this designation. See Synchronizing Form Submissions for more information.

Uniqueformidentifier:formid

The formid attribute lets you specify a unique identifier for a form. Forms require unique IDs when, on one page, you specify several forms, only one of which is rendered because the rules for rendering use an if this condition, then render form A; if that condition, then render form B format. By providing a form ID, the page compiler is able to distinguish one form from another.

Session confirmation

In order to prevent cross-site attacks, you can set the requiresSessionConfirmation attribute to true. If set to true, 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.

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 that lets you reserve a classroom. Using this form, a user can specify the desired room (drop-down list), the course title (text box), and the teacher’s name (group of radio buttons). When a user enters data and clicks the ReserveRoom button, that 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 can appear pre-populated with data, such as Ms. Pear taught geometry in room 109, if the data was previously saved to FacilityFormHandler. There are no specific failure or success instructions, after the form is submitted, the user is sent to FacilitySchedule.jsp as indicated by the action attribute.

 
loading table of contents...