You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sanjana <sa...@strandgenomics.com> on 2002/10/25 11:16:55 UTC

multibox : problem with preselected array

Hi,
 
I have been trying to use multibox and am facing a strange problem. I want a few values to be preselected
when I load the form. If I initialize my selected string array in default constructor of the form then 
everything works properly and I can see those checkboxes as selected when the form loads. On the other hand
if the selected string array is populated in an overloaded constructor then no checkbox is selected ??????
Even setting the selected string array in Action class doesn't help :-(
 
Anyone........ where am I going wrong ? 
______________________________________
The form has :
 
 private String[] selectedItems;
 private String[] items;
 
 public void reset(ActionMapping mapping,
                  javax.servlet.http.HttpServletRequest request) {
  selectedItems = new String[0];
 }
 
 public TestForm(boolean flag)
 {
  if(flag)
  {
   selectedItems = new String[1];
   selectedItems[0] = "FedEx";
   items = new String[3];
   items[0] = "FedEx";
   items[1] = "UPS";
   items[2] = "Airborne";
  }
 }
 
 and the corresponding getter ad setter methods.

the jsp has the following code :

<logic:iterate id="item" name="f" property="items">
  <html:multibox property="selectedItems">
   <bean:write name="item"/> 
  </html:multibox> 
   <bean:write name="item"/> 
</logic:iterate>


Thanks,
Sanjana