The checkbox tag represents a check box that can be mapped to an action form’s property of type boolean or java.lang.Boolean. Table 3.9 lists the attributes for this tag.
| Attribute | Description | Possible Value(s) |
|---|---|---|
| indexed | Indicates whether the value assigned to the name attribute is indexed. | true or false |
| name | The scoped variable containing the property specified by the property attribute. If the name attribute is not present, the value of the name attribute of the enclosing form tag will be used. | string |
| property* | The property of the action form mapped to the enclosing form tag that will be associated with the rendered HTML input field, unless overridden by the value attribute. | string |
| value | A constant value that will become the value of the rendered check box. | string |
Table 3.9: The checkbox tag’s attributes
Here is an example of the checkbox tag.
<html:checkbox property="subscribe"/>
This is translated into the following input element.
<input type="checkbox" name="subscribe" value="on">
In this example, if the check box is selected when the containing form is submitted, a request parameter named subscribe with the value on is sent to the server. Upon receiving this request parameter, Struts sets the corresponding boolean property to true. If the check box is not selected, no request parameter named subscribe is sent, and the associated property remains false.