I would like to validate that a Struts2 checkbox is selected (boolean property) but the validation always fails at the moment. here is what I have:
<s:checkbox key="agreetc" fieldValue="agreedtc"
label="I have read and agree to the terms and conditions"/>
<field name="agreetc">
<field-validator type="fieldexpression">
<param name="expression">agreetc == true</param>
<message>You must agree to the terms and conditions</message>
</field-validator>
</field>
The value of agreetc
in the action is always false because the setter for the field never gets called. If I add a String called test
with a getter/setter and a s:textfield
then that value is picked but I can't get the values from s:radio
, s:select
or s:checkbox
in this action. Other actions I have been successful with s:radio
and s:select
.
Does anyone have any ideas?