To use a multibox, you need a getter and setter method in your form-bean
that returns/sets a String array.
Each element in this String array  corresponds to the value of a checked
check-box.

Let's say you have a multibox coded like this:

<logic:iterate name="myFormForm" property="dataBaseRecords" id="record">
<html:multibox name="myFormBean" property="selectedDataBaseRecords">
    <bean:write name="record" property="description"/>
</html:multibox>
</logic:iterate>

ie
1)  myFormBean has a method 'getDataBaseRecords' that returns a collection.
2)  Each object in the 'getDataBaseRecords' collection has a method
'getDescription', which is used to set the value of (and display against)
the checkbox.
3) myFormBean has methods 'get/setSelectedDataBaseRecords' coded as
follows:

  private String[] selectedDataBaseRecords = new String[0];

  public String[] getSelectedDataBaseRecords() { return
selectedDataBaseRecords;  }
  public void setSelectedDataBaseRecords(String[] value) {
selectedDataBaseRecords = value; }


The effect of the above will be to generate html as follows:

<input type="checkbox" name="selectedDataBaseRecords" value="[description
1]">
<input type="checkbox" name="selectedDataBaseRecords" value="[description
2]">
<input type="checkbox" name="selectedDataBaseRecords" value="[description
3]">
<input type="checkbox" name="selectedDataBaseRecords" value="[description
4]">
etc.

Initially none of the check-boxes are checked because I've coded
'getSelectedDataBaseRecords' to return a zero length array.
If you were to check the second and third check-boxes and submit the form,
'getSelectedDataBaseRecords' would then return an array of 2 elements, with
the values '[description 2]' and '[description 3]'.



Regards,
John

[EMAIL PROTECTED]
Ph (09) 372-5010


|---------+------------------------------->
|         |           Jignesh Kapadia     |
|         |           <jignesh_kapadia2003|
|         |           @yahoo.com>         |
|         |                               |
|         |           18/08/2004 12:33 PM |
|         |           Please respond to   |
|         |           "Struts Users       |
|         |           Mailing List"       |
|         |                               |
|---------+------------------------------->
  
>--------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                          |
  |       To:       [EMAIL PROTECTED]                                                  
                     |
  |       cc:                                                                          
                          |
  |       Subject:  multiple checkboxes                                                
                          |
  
>--------------------------------------------------------------------------------------------------------------|




Hi ,
      I have a scenario in our aplication which we are developing with
      Struts1.1.  on first screen we are displaying bunch of records
      retrieved from database. Each record will have checkbox in first
      column. This check box wil be initially checked or unchecked
      depending upon the value of a bean attribute. A user can chsnge this
      .He/She can check or uncheck any check boxes for any records.On the
      next screen it should show me the updated records. i.e. records which
      are unchecked on previous page should be seen as unchecked and
      records which are checked on previous page should be shown as
      checked.
I tried this using <html:multibox       tag but it is not working.

can somebody give a suggestion on this? It will be good help from your side
if you can give your expert feedback ASAP.

Thanks,
Jignesh Kapadia



---------------------------------
 Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now.



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

Reply via email to