Meaningless Drivel is fun!*
The moose likes Struts and the fly likes How to retain value in multiple select box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to retain value in multiple select box" Watch "How to retain value in multiple select box" New topic
Author

How to retain value in multiple select box

aneesh vijayakumar
Greenhorn

Joined: Jul 01, 2008
Posts: 13
Hello,

I am doing an edit page. The edit page contains multiple select box. I have no issue while saving the form.
The issue is while the user updates the details.

i was able to retain the values in text field's etc, but I don,t know how to retain the value in multiple select box.

I gave the multiple select like



i tried to retain theselected values by giving

but in vain...

any help to solve this will be appreciated.

thanks in adavance.
Aneesh

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Are you using struts??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
aneesh vijayakumar
Greenhorn

Joined: Jul 01, 2008
Posts: 13
yes...i am using struts 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Please post Struts questions in the Struts forum. I've moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You'll need to provide more details, like the relevant properties of the action class (specifically the property being saved to, and the property being used to do the pre-selects, and how the pre-select values are loaded by the action) at the very least as well as the complete tag usage.
aneesh vijayakumar
Greenhorn

Joined: Jul 01, 2008
Posts: 13
i am using the struts library tags..


the multiple select is inside form tag..


I have some select box and some multiple select box in it.


i want to retain the value of this multiple select box while doing an update.

the user goes to the edit page to update details using a edit url, through which i am passing the id as a parameter.

in doing so, i am getting the object there by using the method



i am able to retain the values of checkbox's and textfield's in the page. but when it comes to select box, i am not able to retain their values.

since this page is used by the user to update his previously entered details, all the entries must be populated.

any help to solve this will be appreciated.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't understand why the "list" attribute is an empty list; I thought the "list" attribute was used to populate the dropdown.
aneesh vijayakumar
Greenhorn

Joined: Jul 01, 2008
Posts: 13
Actually I got it working...



the list was left empty..

this would have worked fine for the edit...
but while updating , now i checked whether any ehicle types exist in database for the object of reference and i had to give like



and it works fine

Thanks all

Aneesh

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retain value in multiple select box