| |||||||
FRAMES NO FRAMES |
Implements an HTML tag that generates form fields of type <input type=" checkbox"/>. Since a single checkbox widget on a HTML page can have only a single value, the value tag attribute must always resolve to a scalar value which will be converted to a String using the Stripes Formatting system, or by caling toString() if an appropriate Formatter is not found.
Checkboxes are commonly used in two ways. The first and simplest case uses a single checkbox to set a boolean or Boolean value on the ActionBean. To do this use the following syntax:
<stripes:checkbox name="likesChocolate"/>
When the value attribute is omitted, as above, the checkbox defaults to the simple behaviour of sending "true" to the server when checked and nothing to the server when unchecked. For this reason it is best to use boolean values, or Boolean values initialized to Boolean.FALSE.
The other common usage is to use checkboxes in a manner similar to a multi-select. For example:
<stripes:checkbox name="likes" value="chocolate"/> <stripes:checkbox name="likes" value="marshmallows"/> <stripes:checkbox name="likes" value="ice cream"/>
In this case there are multiple checkboxes each with the same name, but different values. A value is submitted to the server for each checked checkbox, and normally bound to an array or List property on the ActionBean.
Checkboxes perform automatic (re-)population of state. They prefer, in order, values in the HttpServletRequest, values in the ActionBean and lastly values set using checked="" on the page. The "checked" attribute is a complex attribute and may be a Collection, an Array or a scalar Java Object. In the first two cases a check is performed to see if the value in the value="foo" attribute is one of the elements in the checked collection or array. In the last case, the value is matched directly against the String form of the checked attribute. If in any case a checkbox's value matches then a checked="checked" attribute will be added to the HTML written.
The tag may include a body and if present the body is converted to a String and overrides the checked tag attribute.
Tag Information | |
Tag Class | net.sourceforge.stripes.tag.InputCheckBoxTag |
TagExtraInfo Class | None |
Body Content | JSP |
Display Name | checkbox |
Attributes | ||||
Name | Required | Request-time | Type | Description |
checked | false | true | java.lang.Object | References either a scalar object/String or an Array or a Collection. If the value of the checkbox is found to equal or be contained by the 'checked' object then the checkbox will default to rendering as checked. |
formatType | false | true | java.lang.String | The type used to format the object. If the value is a date, valid values are 'date', 'time' and 'datetime'. If the value is a Number, valid values are 'number', 'percentage' and 'currency'. |
formatPattern | false | true | java.lang.String | The pattern to apply. Can be either a named pattern or an actual pattern as understood by java.text.DateFormat or java.text.NumberFormat as appropriate for the type of object being formatted. |
value | false | true | java.lang.Object | The value that will be submitted to the server if this checkbox is in the checked state when clicked. If no value is specified, the value defaults to true (or more correctly Boolean.TRUE). While other inputs like text and password repopulate their state into the value attribute, this is not the case with checkbox, where the value is an invariant. |
name | true | true | java.lang.String | The name of the form field. |
size | false | true | java.lang.String | The size of the form field. (HTML Pass-through) |
disabled | false | true | java.lang.String | Disables the input element when it first loads so that the user can not write text in it, or select it. (HTML Pass-through) |
accesskey | false | true | java.lang.String | Keyboard shortcut to access the element. (HTML Pass-through) |
class | false | true | java.lang.String | The CSS class to be applied to the element. (HTML Pass-through) |
dir | false | true | java.lang.String | Text direction. (HTML Pass-through) |
id | false | true | java.lang.String | A unique identifier for the HTML tag on the page. (HTML Pass-through) |
lang | false | true | java.lang.String | The language code of the element. (HTML Pass-through) |
onblur | false | true | java.lang.String | Scripting code run when the element loses focus. (HTML Pass-through) |
onchange | false | true | java.lang.String | Scripting code run when the element changes. (HTML Pass-through) |
onclick | false | true | java.lang.String | Scripting code run on each mouse click. (HTML Pass-through) |
ondblclick | false | true | java.lang.String | Scripting code run on a double-click of the mouse. (HTML Pass-through) |
onfocus | false | true | java.lang.String | Scripting code run when the element acquires focus. (HTML Pass-through) |
onkeydown | false | true | java.lang.String | Scripting code run when a key is depressed. (HTML Pass-through) |
onkeypress | false | true | java.lang.String | Scripting code run when a key is pressed and released. (HTML Pass-through) |
onkeyup | false | true | java.lang.String | Scripting code run when a key is released. (HTML Pass-through) |
onmousedown | false | true | java.lang.String | Scripting code run when a mouse button is depressed. (HTML Pass-through) |
onmousemove | false | true | java.lang.String | Scripting code run when the mouse pointer is moved. (HTML Pass-through) |
onmouseout | false | true | java.lang.String | Scripting code run when the mouse pointer moves out of the element. (HTML Pass-through) |
onmouseover | false | true | java.lang.String | Scripting code run when the mouse pointer moves over the element. (HTML Pass-through) |
onmouseup | false | true | java.lang.String | Scripting code run when a mouse button is released. (HTML Pass-through) |
onselect | false | true | java.lang.String | Scripting code run when an element is selected. (HTML Pass-through) |
style | false | true | java.lang.String | Inline CSS style fragment that applies to the element (HTML Pass-through) |
tabindex | false | true | java.lang.String | The tab order of the element. (HTML Pass-through) |
title | false | true | java.lang.String | Tool-tip text for the element. (HTML Pass-through) |
Variables | No Variables Defined. |
| |||||||
FRAMES NO FRAMES |