You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Dunn <Gr...@nisc.coop> on 2006/02/01 18:05:19 UTC

RE: Conditionally checking an html:checkbox field

Still no joy using String instead of Boolean.  I must be doing something
wrong.  What are common mistakes related to checkboxes?

-----Original Message-----
From: kalpesh modi [mailto:modi_kalpesh@yahoo.com] 
Sent: Tuesday, January 31, 2006 1:11 PM
To: Struts Users Mailing List
Subject: RE: Conditionally checking an html:checkbox field

You need to set it to the value that gets submitted when you check a
checkbox and submit the form. 


		
---------------------------------
Bring words and photos together (easily) with
 PhotoMail  - it's free and works with Yahoo! Mail.



-----Original Message-----
From: Greg Dunn [mailto:Greg.Dunn@nisc.coop] 
Sent: Tuesday, January 31, 2006 12:57 PM
To: Struts Users Mailing List
Subject: RE: Conditionally checking an html:checkbox field


I need to conditionally set a checkbox field when presented to the user
depending on application configuration settings.  I'm using an Action to
load the form and attempt to set the checkbox field.  No matter what I
do I cannot get the checkbox state to change from its default, whether
that be true, false or no value (shows false). 

I've Google'ed, searched the list archive and various FAQ's to no avail.



In my ValidatorForm bean:  (This particular field is not validated)

    private boolean shutoff;

    public boolean getShutoff () {
        return shutoff;
    }

    public void setShutoff (boolean shutoff) {
        this.shutoff = shutoff;
    }

    public void reset(ActionMapping mapping, HttpServletRequest request)
{
        this.shutoff = boolean.FALSE;
    }

In my Action:

    if (checkTheBox.equals("yes")) {  //config. option, confirmed
working
        regForm.setShutoff(true);
    }

    [Then it immediately forwards to the form JSP.]



I also tried setting the value of the checkbox via another property in
the form bean.

I appreciate any corrections or suggestions.

Greg

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org