File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts Multiselect to Hidden Field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Multiselect to Hidden Field" Watch "Struts Multiselect to Hidden Field" New topic

Struts Multiselect to Hidden Field

Andy Lileston

Joined: Nov 03, 2008
Posts: 10
Hey guys,

I'm using a the struts select tag for use with multiple select. Like so:

The corresponding bean property is a . I'm submitting that form and on the other side, I am wanting to put that data into a hidden field. Right now, it just puts the object.toString() gobbledygook in for the value. It seems that struts should be able to handle this transparently.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Are you trying to display the value of the string array with an html:hidden tag that is inside of a logic:iterate loop? It sounds like you may NOT be, and the single html:hidden tag is just going to try to display the toString of your array. So you may want to try using an iterate tag to loop through the values. I may be making a bad guess though. It might help to see your getter and setter methods and the jsp code you are using to try to display the value.
Andy Lileston

Joined: Nov 03, 2008
Posts: 10
You're right Tom. I'm not iterating through them, but if I have to, that just seems like bonehead design. I would think that Struts would be able to handle it all transparently. I guess not.

Does anyone have some sample code of a Collection property iteration? I played around with it a bit, but the 'indexed' attribute kept giving me trouble.
I agree. Here's the link:
subject: Struts Multiselect to Hidden Field
jQuery in Action, 3rd edition