Hi,
I am using
Struts 1.1. My requirement is as follows:
1. I have 2 multi select drop down box S1 and S2 next to each other with a left button and a right button between the 2 select boxes.
2. The labels displayed should be different from the values within the option tag for both select boxes S1 and S2.
3. Now only the first select box S1 is populated with predefined values from the database. The right select box S2 is initially empty.
4. On selecting one or more values from the left select box (S1) and click of the left button, the selected values should move to the right select box S2.
5. Similiarly, when the values on the right select box S2 are selected and on click of the right button, the values from the right select box S2 should move to the left select box S1.
6. Also on struts validation errors, when my page with the select boxes is displayed, it should display the correct values in both the select boxes S1 and S2. i.e S1 should be displayed with all data except those present on the right select box S2. Similiarly, right select box S2 should display the earlier selected values which were moved into this box before the submit.
7. Both select boxes S1 and S2 should maintain different values and labels (i.e option tag - value and label are not same). I do not want the values and labels to be the same data.
e.g This is what i want the select box to look like
select box S1 - pre-populated with values from the database
<select name="S1">
<option value="TC">Tom Cruise</option>
<option value="TJ">John Travolta</option>
<option value="GG">Gretta Garbo</option>
<option value="JR">Julia Roberts</option>
<option value="MR">Meg Ryan</option>
</select>
select box S2 initially empty, but on click of the button, values from S1 to be transferred to S2
<select name="S2">
<option value="TC">Tom Cruise</option>
<option value="TJ">John Travolta</option>
</select>
and now S1 will only have
<select name="S1">
<option value="GG">Gretta Garbo</option>
<option value="JR">Julia Roberts</option>
<option value="MR">Meg Ryan</option>
</select>
Issues:
I am able to implement almost all the points except point 6 and point 7.
For S1: I have done the following-
1. On ActionForm, corresponding to S1, i have a List S1List (setS1List and getS1List methods) which will contain the values from the database. This pre-population is done in the Action class using struts class LabelValueBean
i.e
LabelValueBean l1 = new LabelValueBean("Tom Cruise", "TC");
LabelValueBean l2 = new LabelValueBean("John Travolta", "TJ");
and so on.. these are added to the List and set on the ActionForm via setS1List method.
in my
jsp i am able to get the select box S1 like this:
<html:select name="myForm" property="S1List" multiple="multiple">
<logic:notEmpty name="myForm" property="S1List" scope="session">
<html

ptionsCollection property="S1List" value="value"
label="label"/>
</logic:notEmpty>
</html:select>
Question 1: What do i need to do to implement the select box for S2 ? Note that S2 which actually holds the value to be saved in the database, is a
String array (String[]) on the ActionForm.
I tried different ways since 2 days, but i was not able to implement different value and labels for S2.
Question 2: On validation errors, when my page is displayed with the select boxes, in order to achive point 6, i was thinking of using the body onload event to remove the values from S1 which are already present on S2. Is there any other better way to achieve this ??
Any help for the above 2 points would be greatly appreciated..
Thanks in advance,