I am not an expert on WW, though the normal way to deal with 'missing'
http data is to set a default value for the property and it can be
overridden by the request parameter...

i.e. if you set 

protected boolean newsletter = false;

instead of true, then WW will call the setNewsletter(true) when the
checkbox is checked.

Cam


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]] On 
> Behalf Of Kirk Rasmussen
> Sent: Wednesday, 18 December 2002 12:46 PM
> To: [EMAIL PROTECTED]
> Subject: [OS-webwork] Maintaining checkbox state in feedback loop
> 
> 
> Hello everyone,
> Please excuse this newbie question but I'm still coming up to 
> speed on WW and I've run into a little problem with 
> checkboxes.  There wasn't an example in the distribution that 
> I could find for the following situation.
> 
> On my form I have the following:
> 
> <form action="<webwork:url page="foo.action"/>" method="POST">
>   <ui:textfield label="'Email'" name="'email'" maxlength="100"/>
>   <ui:textfield label="'Confirm email'" 
> name="'confirmedEmail'" maxlength="100"/>
>   <ui:checkbox label="'Check here to receive newsletter'" 
> name="'newsletter'" fieldValue="true"/> </form>
> 
> On initial load I want the checkbox to default to checked.  
> In my Action class I have:
> 
>     protected boolean newsletter = true;
>     protected boolean promotions = true;
> 
>     public boolean getNewsletter()
>     {
>         System.err.println( "getNewsletter()" );
>         
>         return newsletter;
>     }
>     
>     public void setNewsletter( boolean checked )
>     {
>         System.err.println( "setNewsletter()" );
>         
>         this.newsletter = checked;
>     }
> 
> This works fine on initial load (foo!default.action) but 
> fails on the POST feedback loop (e.g. user enters invalid 
> e-mail address) if I deselect the newsletter checkbox.  The 
> checkbox will stay checked because the internal state has 
> already been set to true.
> 
> Since there is no parameter being passed to the WW 
> dispatcher, setNewletter(false) will never get called, right? 
>  How do I handle a "missing" parameter in WW???
> 
> Am I missing something?   
> 
> Thanks,
> Kirk Rasmussen
> Lucasfilm Ltd.
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:
> With Great Power, Comes Great Responsibility 
> Learn to use your power at OSDN's High Performance Computing 
> Channel http://hpc.devchannel.org/ 
> _______________________________________________
> Opensymphony-webwork mailing list 
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> 
> 



-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility 
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to