Wednesday, October 3, 2012

Html Checkboxes

I always have trouble passing checkboxes to the server and I always forget how to do it again later. For this example we have a check boxe for the field Master . We are calling setters on the server in a Criteria object.

-In the Criteria Object

void setMaster( Boolean master ) {
this.master = master;
Boolean getMaster() {
return this.master;

-In the velocity page

<input type="checkbox" name="criteria.master" value="true">

This ensures we send true when the checkbox is checked, instead of the default "on"
If the checkbox is not checked we send nothing to the server Criteria object.

No comments:

Post a Comment