Actually according to Ted inside the reset method your code should be:

marketing = new String[] {};

HTH,
David

----- Original Message ----- 
From: "David Erickson" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, March 17, 2004 1:22 PM
Subject: Re: Multibox problem when defaulted all on


> I'm still a little hazy on when reset is called on forms, but you may want
> to try moving
> marketing = marketingItems;
>
> to the forms constructor, so when the form is created the first time its
> holding the default values.
> And inside the reset method:
>
> marketing = null;
>
> -David
>
> ----- Original Message ----- 
> From: "Wiebe de Jong" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Wednesday, March 17, 2004 1:14 PM
> Subject: Multibox problem when defaulted all on
>
>
> > I am having a problem with multibox. I need to have a set of checkboxes
to
> > default on in my form. I found and followed Ted Husted's "Struts Tip #7
> > <http://husted.com/struts/tips/007.html>  - Use Multibox to manage
> > checkboxes" and everything works well, except in one condition explained
> > below.
> >
> >
> >
> > When everything is defaulted on, and the user checks off the boxes but
> > leaves at least one checked on, everything works as planned. However, if
> all
> > the boxes are defaulted on (as in the code below) and the user checks
all
> > the boxes off, the marketing array is not updated. In this case, the
form
> > ends up telling me that the checkboxes are all on.
> >
> >
> >
> > How do I get it to work properly in this situation?
> >
> >
> >
> > -----
> >
> > Form:
> >
> >
> >
> > public void reset(ActionMapping mapping, HttpServletRequest request) {
> >
> > ...
> >
> >   marketing = marketingItems;
> >
> > }
> >
> >
> >
> > private String[] marketing = {};
> >
> > private String[] marketingItems =
> > {"accountHolder","user2","user3","user4","user5"};
> >
> > public String[] getMarketing() { return this.marketing; }
> >
> > public void setMarketing(String[] marketing) { this.marketing =
> marketing; }
> >
> >
> >
> > -----
> >
> > Jsp:
> >
> >
> >
> > <html:multibox property="marketing" value="accountHolder
> styleClass="form"/>
> >
> > ...
> >
> > <html:multibox property="marketing" value="user2" styleClass="form"/>
> >
> > ...
> >
> > <html:multibox property="marketing" value="user3" styleClass="form"/>
> >
> > ...
> >
> > <html:multibox property="marketing" value="user4" styleClass="form"/>
> >
> > ...
> >
> > <html:multibox property="marketing" value="user5" styleClass="form"/>
> >
> >
> >
> > -----
> >
> > Action:
> >
> >
> >
> > String[] marketing = form.getMarketing();
> >
> > log.debug("marketing " + marketing.length);
> >
> >
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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

Reply via email to