The input tag for a form submit control can have one of these two formats:
<dsp:input type="submit"
[
bean="
prop-spec
"
[
submitvalue="
value
"
]
value="
value
"
]
/>
dsp:input type="image"
{
src|image
}
=path
[
bean="
prop-spec
" submitvalue="
value
""
]
/>
The type
setting determines whether the submit control displays as a button or image. If set to submit
, the tag specifies to display a submit button; if set to image
, it defines a submit control that uses the image specified by the src
or page
attribute.
You can also specify one of the following attributes:
bean
specifies a component property to set when the user clicks the submit control.value
specifies the text to display on the submit button, iftype
is set tosubmit
. If the attributesubmitvalue
is omitted, the value is also used to set thebean
-specified property. This attribute is not valid iftype
is set toimage
.submitvalue
specifies value to set on thebean
-specified value when the user clicks on this submit control. Iftype
is set tosubmit
, this attribute overrides thevalue
-specified value, which is otherwise used to set the property.
Using Submit Controls to Set Property Values
A submit control can set the bean
-specified property through the standard value
attribute. The control can override its own value
setting through the non-standard submitvalue
attribute. Used together, value
specifies only the button label text (if the input type
is set to submit
), and submitvalue
sets the property value. For example, the following tag creates a submit button with the label Click Here, and specifies to set Student_01.age
to 34
:
<dsp:input type="submit" bean="/samples/Student_01.age" submitvalue="34"
value="Click Here"/>
You typically set property values through data entry inputs and hidden inputs. Occasionally, however, you might want to associate property settings with submit controls. For example, a form might have multiple submit buttons, where each sets the same property to a different value. The following input tags define two submit buttons, each specifying the Boolean property Student_01.emailOK
:
<dsp:input type="submit" bean="/samples/Student_01.emailOK"
value="Send email" submitvalue="true" name="OK"/>
<dsp:input type="submit" bean="/samples/Student_01.emailOK"
value="Do not send email" submitvalue="false" name="notOK"/>
The first submit button sets the property to true; the second to false. Because the two input tags specify the same property, each requires a unique name
attribute.
Note: In general, two controls cannot be associated with the same property. In the previous example, the submit buttons can be associated with the same property because only one of them can be executed for a given form submission.
Using Images as Submit Controls
An image can act as a submit control. When the user clicks the image, the image input submits the form. The src
or image
attribute specifies the pathname of the image file. As with a submit button, the bean
attribute specifies a property to set on form submission, and submitvalue
specifies the value. For example:
<dsp:input bean="/samples/Student_01.emailOK" type="image"
src="clickpic.gif" submitvalue="true"/>
If you omit the submitvalue
attribute, the image pixel coordinates are submitted as the value.