You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by jj...@lexmark.com on 2000/08/08 16:43:35 UTC

How to use struts:checkbox?

I have a form with a boolean value "enabled", and I have the proper getEnabled()
and setEnabled() methods.

I created a struts:checkbox like this:   <struts:checkbox property="enabled"/>

When enabled=true, the checkbox is correctly displayed checked.  If I uncheck it
and submit, the from bean's setEnabled(false) is NOT called.

I dumped the parameter names and values in the ActionForm Bean's perform and I
guess I knew that the checkbox is only posted when it's checked, but I was
expecting struts to keep the enabled property set correctly anyway.

The guy in the next office isn't using struts, but is using a home-grown
architecture where each JSP is paired with a bean.  He has had similar problems
when a text field is cleared.

How do people code for these situations?  Does your ActionForm Bean's perform()
method directly check for the field in the request and call setEnabled(false)
itself?

Thanks,
-Jeff