validation - Validate struts2 checkbox is checked -


i validate struts2 checkbox selected (boolean property) validation fails @ moment. here have:

<s:checkbox key="agreetc" fieldvalue="agreedtc"             label="i have read , agree terms , conditions"/>  <field name="agreetc">     <field-validator type="fieldexpression">         <param name="expression">agreetc == true</param>         <message>you must agree terms , conditions</message>     </field-validator> </field> 

the value of agreetc in action false because setter field never gets called. if add string called test getter/setter , s:textfield value picked can't values s:radio, s:select or s:checkbox in action. other actions have been successful s:radio , s:select.

does have ideas?

if want receive value string fieldvalue attribute make agreedtc variable string type not boolean. validation should work.

but if want boolean in action class remove fieldvalue attribute <s:checkbox> tag , change validation expression to:

<field name="agreetc">     <field-validator type="fieldexpression">         <param name="expression">agreetc</param>         <message>you must agree terms , conditions</message>     </field-validator> </field> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -