Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Problem in getting selected values from multiselect list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem in getting selected values from multiselect list" Watch "Problem in getting selected values from multiselect list" New topic
Author

Problem in getting selected values from multiselect list

R Laksh
Greenhorn

Joined: Aug 27, 2003
Posts: 25
Hi,

I have two multiselect listboxes in my page. In List1 the data will be retrieved from DB and listed.I will have buttons to move the values from List1 to List2 and viceversa.

After selecting the needed values,I can rearrange them in List2 using some buttons. I have coded this moving and reordering using javascript.

What happens is while submitting the page I want the values from list2 which are rearranged. But im getting the order in which I moved from list1 to list2.

I am using html:selectfor both lists

List1
------
<html:select name="CustForm" property="custName" multiple="true" size="10">
<html ptionsCollection property="CustomerNames" value="custName" label="id"/>
</html:select>


I am having a customer form which has a arraylist CustomerNames. This arraylist has customer bean which has proeprties custName and id. The custForm also has a String custName.


List2
------
<html:select name="CustForm" property="selectedCustName" multiple="true" size="10">
<html ption value=""/>
</html:select>

The custForm also has a String[] selectedCustNames from where I get the selected values in list2


Please let me know what am I doing wrong here.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I've used a similar technique in letting users select values, but I have not had this problem. The only thing I might suggest is to make sure that your javascript causes all the options to be selected before submitting the form, as only selected values will be submitted. If you're already doing that, try unselecting all of them, then re-selecting them in the proper order.

Here is the function that I use to select all options:



Merrill
Consultant, Sima Solutions
R Laksh
Greenhorn

Joined: Aug 27, 2003
Posts: 25
yeah I have did this to select all the values from list2.

Actually while moving items up and down in list 2,in the script,I have swapped the text but didnt exchange the values. That was the problem and its fixed now.

Thanks a lot !!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in getting selected values from multiselect list
 
Similar Threads
DynaValidator reset options being reset.
Using logic:iterate in select box
how to set arrayList property in form from view
Problem with html:select - Cannot find bean
Problem with html:select - Cannot find bean