You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Becky Moyer <ju...@hotmail.com> on 2001/06/19 21:44:57 UTC

Multibox confusion after reading Struts mail-archive

Hi all...
   I've read all I can find in the archives about the html:multibox tag, and 
I have gotten farther, but I still would like to ask for some help.

In my jsp, I have the following:

<logic:iterate id="item1" name="entryData">
   <html:multibox name="item1" property="subscriptionStatus" value="true"/>
</logic:iterate>

Where entryData is an ArrayList of class EntryInfo, that has a 
getSubscriptionStatus() which returns a boolean.  This displays properly, 
and i see the appropriate boxes checked.


The associated Form bean has a boolean[] subscriptionStatus field with the 
associated getter and setter methods.  When I try to evaluate the form in my 
ActionClass, the result of form.getSubscriptionStatus() is null.

I have also implemented the reset() method in my form where I iterate 
through the subscriptionStatus array in the Form and set all values to null.

My questions are...

1) I thought the "property" Attribute in the multibox tag refered to
   the property in the form that would be submitted.  I may very well
   be mistaken, but it seems from my experiments, the property
   attrubute specifies which value will be displayed.  How does this
   work?  If it represents which value will be displayed, how do you get
   the information into your form?

2) As in the struts-exercise-taglib webapp, it appears that when you
   use a multibox, you use an array of foo as the parameter that stores
   the result in the form.  Is this right?  My confusion about this
   seems to be one of my possible downfalls with getting information
   into my form.

Thanks so much for reading my rambles, and any thoughts or clarifications 
would be excitedly welcomed.

   -Becky-
    beckym678@yahoo.com








_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


Re: Multibox confusion after reading Struts mail-archive

Posted by Steve A Drake <sa...@comet.ucar.edu>.
On Tue, 19 Jun 2001, Becky Moyer wrote:

> Hi all...
>    I've read all I can find in the archives about the html:multibox tag, and
> I have gotten farther, but I still would like to ask for some help.
>
> In my jsp, I have the following:
>
> <logic:iterate id="item1" name="entryData">
>    <html:multibox name="item1" property="subscriptionStatus" value="true"/>
> </logic:iterate>
>
> Where entryData is an ArrayList of class EntryInfo, that has a
> getSubscriptionStatus() which returns a boolean.  This displays properly,
> and i see the appropriate boxes checked.
>
>
> The associated Form bean has a boolean[] subscriptionStatus field with the
> associated getter and setter methods.  When I try to evaluate the form in my
> ActionClass, the result of form.getSubscriptionStatus() is null.
>
> I have also implemented the reset() method in my form where I iterate
> through the subscriptionStatus array in the Form and set all values to null.
>
> My questions are...
>
> 1) I thought the "property" Attribute in the multibox tag refered to
>    the property in the form that would be submitted.  I may very well
>    be mistaken, but it seems from my experiments, the property
>    attrubute specifies which value will be displayed.  How does this
>    work?  If it represents which value will be displayed, how do you get
>    the information into your form?
>
> 2) As in the struts-exercise-taglib webapp, it appears that when you
>    use a multibox, you use an array of foo as the parameter that stores
>    the result in the form.  Is this right?  My confusion about this
>    seems to be one of my possible downfalls with getting information
>    into my form.
>
> Thanks so much for reading my rambles, and any thoughts or clarifications
> would be excitedly welcomed.
>
>    -Becky-
>     beckym678@yahoo.com

 Hello Becky. I flailed around with multibox myself before I found
something that worked. In the example below, I implemented two String[]
arrays in the ActionForm, "findAssets" and "selectedAssets". findAssets
maintains all of the possible values and selectedAssets maintains the
currently selected values. Iterate over all the possible values to print
the checkbox name and use the property setting of the selected values to
set the checkboxes.

<logic:iterate name="advancedQueryForm" property="findAssets" id="element">
 <html:multibox property="selectedAssets">
  <bean:write name="element" />
 </html:multibox>
 <bean:write name="element" />
 <br />
</logic:iterate>


Hope this helps.