On Tuesday 10 June 2003 14:11, Bjørn T Johansen wrote:
> You are missing my point! If I just could set the checkbox value to
> false in the reset method, everything is fine. But there are times when
> that value has to be reset to true and not false and if I do that in my
> reset method, I am not able to see of the user unchek the checkbox,
> because the boolean variable is still true after the form has been
> posted!

No, actually *YOU* are missing the point!  Several people have tried to 
explain how this works to you.

So, for one last effort....

<IMPORTANT>
DO *NOT* SET THE FIELDS YOU INTENT TO USE AS CHECKBOXES (booleans) TO TRUE IN 
THE RESET METHOD!!!!!  
</IMPORTANT>

If you want the field to be true when the page is rendered, set it to true 
from your action class, NOT in the reset of your formbean.

I hope that clears it up for you.


>
>
> BTJ
>
> On Tue, 2003-06-10 at 19:22, Tor Henrik Hanken wrote:
> > [EMAIL PROTECTED]
> >
> > | Yes, but to clarify...
> > | I am showing a jsp page with values read from a database. If the
> > | checkbox value is true, how do I then make the checkbox on my jsp-page
> > | checked and how do I then find out if the checkbox has been unchecked?
> > | Do I have to manually read the posted data and see if the checkbox
> > | attribute is missing or is there a better way?
> >
> > I assume that you are using an Action with an ActionForm.
> >
> > To make the value of the checkbox come up correctly, import
> > struts tags into your jsp-page:
> >
> > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="strb" %>
> > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="strh" %>
> > <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="strl" %>
> >
> > Then use the Struts checkbox tag:
> >
> > <strh:checkbox property="done"/>
> >
> > Assuming that your form has the methods getDone and setDone,
> > these methods will be used to render the value of the checkbox
> > correctly.
> >
> > As to the question of boolean values that are set to false by the
> > user: You don't have to parse the posted data manually.  The
> > method reset() in ActionForm is run before the posted data is
> > used to populate the form.  Write your own reset() method where
> > you set the boolean fields to false.

-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org
770-822-3359
AIM:jmitchtx



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to