|Apache Struts 2 Documentation > Home > FAQs > Cookbook > Using Checkboxes|
The W3C specification does not provide a way to submit a "cleared" or "false" checkbox. If the control is clear, the browser will not submit any value for that control. The application is expected to notice that the checkbox was not submitted, and proceed accordingly.
The framework automatically tracks the checkboxes used by a form (so you don't have to). If a checkbox is missing, a default value for the checkbox (usually false) is injected. The checkbox control can then turn on-and-off values as needed,
Our user has a number of priviliges that are stored as a Set of strings. To use checkboxes for these, we have HTML that looks like:
Say a user checks the first 2; the browser will send the query string: user.priv=boss&user.priv=admin.
OGNL will end up calling
You can write this method like:
This example uses a kind-of model-driven action (see Model Driven Interceptor). The action returns a single getter for the User object whose values are populated.