public class Checkbox extends AbstractField
Name | Type | Flags | Default | Default Prefix |
---|---|---|---|---|
value | boolean | Required | prop | |
The value to be read or updated. If not bound, the Checkbox will attempt to edit a property of its container whose name matches the component's id. |
In this example, a Checkbox will be used alone to manipulate a property of the page.
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> <body> <h1>View Accounts</h1> <t:form> <t:checkbox t:id="showall" onclick="this.form.submit();"/> <t:label for="showall"/> </t:form> <t:grid t:id="accounts"/> </body> </html>
The Grid component will do most of the work in terms of displaying the account data.
Normally, we should bind the value parameter explicitly; here the component's id, "showAll", matches against a property of the page and the value parameter is automatically bound as a convenience.
A small amount of JavaScript is provided in-line to submit the form when the checkbox is clicked.
All Tapestry form control element components must be enclosed by a Form component.
The Label component is responsible for rendering a
public class ViewAccount { @Property @Persist private boolean showAll; @Inject private AccountDAO accountDAO; public List<Account> getAccounts() { return showAll ? accountDAO.getAllAccounts() : accountDAO.getActiveAccounts(); } }
The component updates the showAll field, and that's used to determine which set of accounts should be provided to the Grid component. As always in Tapestry, you must be careful to mark fields persistent if they need to hold their value between the action request (the form submission) and the render request.
clientId, cssClass, decorator, defaultProvider, disabled, environment, fieldValidationSupport, formSupport, javaScriptSupport, label, request, resources, validationTracker
Constructor and Description |
---|
Checkbox() |
Modifier and Type | Method and Description |
---|---|
protected void |
processSubmission(String controlName)
Method implemented by subclasses to actually do the work of processing the submission of the form.
|
decorateInsideField, getClientId, getControlName, getLabel, isDisabled, isRequired, putPropertyNameIntoBeanValidationContext, removePropertyNameFromBeanValidationContext, setDecorator, setFormSupport
public Checkbox()
protected void processSubmission(String controlName)
AbstractField
disabled
.processSubmission
in class AbstractField
controlName
- the control name of the rendered element (used to find the correct parameter in the request)Copyright © 2003-2013 The Apache Software Foundation.