Creates a form control that accepts user input.

<dsp:input [type="input-control"] [name="input-name"]
   bean="property-spec["source-spec"]
   [checked="{true|false}"]
   [default="value"]
   [priority=integer-value]
/><dsp:input type="submit"
   [name="input-name"]
   [bean="property-spec[submitvalue="value"] value="value"]/>

dsp:input type="image" {src|image}=path
   [name="input-name"]
   [bean="property-spec" submitvalue="value""]/>

Attributes

type

Defines the HTML input control—for example, as a checkbox, radio button, or text box, among others. If this attribute is omitted, the default type is text. To learn about input fields, see Setting Property Values in Forms.

You can also define a submit control by setting type to one of these values:

  • submit specifies to display a submit button.

  • image defines a submit control that uses the image specified by the src or page attribute.

name

Assigns a name to this input field, which enables access to it during form processing. If no name is provided, the ATG platform automatically supplies one. For all input types other than radio and checkbox, the assigned name must be unique.

Note: if two or more submit input tags are associated with the same property, each submit input tag must have a unique name attribute.

bean

Specifies the property that this input field updates on form submission: its Nucleus path, component name, and property name. The property specification can also include a tag converter, such as date or null. For more information, see Tag Converters in Chapter 2.

The bean attribute for a submit control can also specify a form handler operation such as cancel or update.

source-spec

Specifies to prepopulate the input field from one of the following sources:

If source-value is omitted, the input field contains the target property’s current value.

checked

If set to true, displays a checkbox or radio button as selected.

default

Specifies a default value to save to the component property if the user neglects to supply a value and none is otherwise provided. Options include true.

priority

Specifies the priority of this input field during form processing, relative to other input fields. This attribute can be especially helpful when making changes to an item’s repository ID and the properties it contains. If you first update the supplemental properties and then the repository ID, the new property values can be flushed when the repository ID change occurs. By default, priority is set to –10.

For more information on how the ATG platform can prioritize tag processing, see Order of Tag Processing

value

Valid only if the type attribute is set to submit, this attribute sets two values:

submitvalue

Sets the target property on activation of the submit control. The value must be a constant. For example:

<dsp:input type="submit" bean="/TestData/Student_01.age" submitvalue="34"
value="Click here"/>

src

Specifies the path and file name of the image to use if submit-control is set to image. You can set src to a relative or absolute path, which is resolved as follows:

page

Specifies the path and file name of the image to use if submit-control is set to image. You can set page to a relative or absolute path, which is resolved as follows:

Usage Notes

dsp:input creates a form control that accepts user input, much like the HTML input tag. dsp:input can create two kinds of controls:

All dsp:input tags must be embedded between <dsp:form>..</dsp:form> tags, which are either in the same JSP or a parent JSP (see Embedding Pages in Forms), so it is subject to the form handler’s submit method.

dsp:input defines the input field—for example, as a text box, radio button group, drop-down list—and the value to save to the specified component property. Initially, the input field can display a value derived either from the target property, another source, or the specified default.

Note:dsp:input uses the iclass attribute in place of the cascading stylesheet class attribute to avoid using a Java reserved word in Java code.

Embedding custom attributes

A dsp:input tag can embed one or more custom attributes through the dsp:tagAttribute tag, as follows:

<dsp:input ...>
   dsp:tagAttribute name="attr-name" value="value"/>
<dsp:input/>

You can use dsp:tagAttribute tags in order to add attributes to the generated HTML beyond the fixed set of attributes supported by the DSP tag library.

Example

<%@ taglib uri="http://www.atg.com/taglibs/daf/dspjspTaglib1_0" prefix="dsp" %>
<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c' %>

<%@ page import="atg.servlet.*"%>
<dsp:page>

<dsp:importbean bean="/atg/TestData/StudentFormHandler"/>

<dsp:form action="<%=ServletUtil.getDynamoRequest(request).getRequestURI()%>"
method="POST">
   <dsp:input bean="StudentFormHandler.updateSuccessURL" type="hidden"
    value="index.jsp"/>
   <dsp:input type="hidden" bean="StudentFormHandler.updateRepositoryId"
    beanvalue="StudentFormHandler.repositoryId" />

   <table border=0 cellpadding=2>
      <tr>
        <td align=right>First Name </td>
        <td><dsp:input type="text" bean="StudentFormHandler.value.firstName"
         maxlength="30" size="30" required="true"/></td>
      </tr>

      <tr>
        <td align=right>Last Name </td>
        <td><dsp:input type="text" bean="StudentFormHandler.value.lastName"
         maxlength="30"size="30" required="true"/></td>
      </tr>

      <tr>
        <td align=right>Address </td>
        <td><dsp:input type="text"
         bean="StudentFormHandler.value.primaryResidence.address"
         maxlength="30" size="30" required="true"/></td>
      </tr>

      <tr>
        <td align=right>City </td>
        <td><dsp:input type="text"
         bean="StudentFormHandler.value.primaryResidence.city"
         maxlength="30" size="30" required="true"/></td>
      </tr>

      <tr valign=top>
        <td align=right>State/Province </td>
        <td><dsp:input type="text"
         bean="StudentFormHandler.value.primaryResidence.state"
         maxlength="30" size="30" required="true"/></td>
      </tr>

      <tr>
        <td align=right>ZIP/Postal Code </td>
        <td><dsp:input type="text"
         bean="StudentFormHandler.value.primaryResidence.postalCode"
         maxlength="10" size="10" required="true"/></td>
      </tr>

      <tr>
        <td align=right>Phone Number </td>
        <td><dsp:input type="text"
         bean="StudentFormHandler.value.primaryResidence.phoneNumber"
         maxlength="20" size="30" required="true"/></td>
      </tr>

      <tr>
        <td align=right>Birthday (MM/DD/YYYY)</td>
        <td><dsp:input bean="StudentFormHandler.value.dateOfBirth"
         date="M/dd/yyyy" maxlength="10" size="10" type="text"/></td>
      </tr>

      <tr>
        <td align=right>Gender </td>
        <td>
          <dsp:input type="radio" bean="StudentFormHandler.value.gender"
           value="male">Male</dsp:input>
          <dsp:input type="radio" bean="StudentFormHandler.value.gender"
           value="female">Female</dsp:input>
        </td>
      </tr>

      <tr>
        <td align=right>Graduation Date </td>
        <td>
          <dsp:select bean="StudentFormHandler.value.gradDate"/>
            <dsp:option value="6/2003">2003</dsp:option>
            <dsp:option value="6/2004">2004</dsp:option>
            <dsp:option value="6/2005">2005</dsp:option>
            <dsp:option value="6/2006" selected="true">2006</dsp:option>
        </td>
      </tr>

      <tr>
        <td align=right>Interests </td>
        <td>
          <dsp:input type="checkbox" bean="StudentFormHandler.value.interests"
           value="drama" checked="true">Drama</dsp:input>
          <dsp:input type="checkbox" bean="StudentFormHandler.value.interests"
           value="art" checked="true">Art</dsp:input>
          <dsp:input type="checkbox" bean="StudentFormHandler.value.interests"
           value="studentGovernement" checked="true" >Student
           Government</dsp:input>
          <dsp:input type="checkbox" bean="StudentFormHandler.value.interests"
           value="sports" checked="true">Sports</dsp:input>
          <dsp:input type="checkbox" bean="StudentFormHandler.value.interests"
           value="band" checked="true">Band</dsp:input>
          <dsp:input type="checkbox" bean="StudentFormHandler.value.interests"
           value="academicTeam" checked="true">Academic Team</dsp:input>
          <dsp:input type="checkbox" bean="StudentFormHandler.value.interests"
           value="singing" checked="true">Singing</dsp:input>
        </td>
      </tr>

      <tr>
        <td align=right>Comments</td>
        <td>
          <dsp:textarea bean="StudentFormHandler.value.comments"/>
        </td>
      </tr>

      <dsp:input type="submit" bean="StudentFormHandler.create" value="Register"/>
</dsp:form>
</dsp:page>

The form in this example might be part of a new student registration page. The page begins with the directive statements that import the DSP tag library and the servlet class. This is followed by an import statement that makes the StudentFormHandler available to the page like other imported items.

The form elements define the default result page as the active page by retrieving the page path and name dynamically from the request objects RequestURI property. The page uses a hidden component to set the StudentFormHandler success property to the index.jsp. Because a failure URL is not provided, the default (current page) is used. A second hidden bean ensures that the repository ID that represents the form remains the same by updating it with the current value.

The dsp:input tags that follow insert text boxes, radio buttons, checkboxes, and extended text fields, that are populated with data when current values exist (implemented by the post action). The first seven text boxes present the student’s first name, last name, street address, city, state, postal code and phone number, and indicate that they must hold valid data in order for the form to process successfully. Each text box saves data to the primaryResidence array of the value Dictionary. The value in the birthday text box is converted so it appears in a format consistent with 1/15/1936.

The form includes a set of radio buttons for documenting the student’s gender (neither are default selected) and a set for specifying is the student’s graduation date. In both cases only one item in each group can be selected. Because most new students are freshmen, the last occurring date is the default. The interests checkbox group saves all selected items to the interests array property. All items are selected by default to encourage students to involve themselves in activities. The extended text box provides a place for free form comments about a student.

The final dsp:input tag inserts a Register button that, when clicked, invokes the submit handler method to process the form.

 
loading table of contents...