aspose file tools*
The moose likes Struts and the fly likes Multiple selections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple selections" Watch "Multiple selections" New topic
Author

Multiple selections

Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
I'm trying to use a select box, with multiple selections.

I originally had the input types on my form all set to String. With this it would only give me the first item selected from the box. I assumed this was because the tag returns a String[]. When I change the form to accept a String[] it errors out. Can anyone please point me to an example using this, or an explaination. Thank you.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
String[] is the correct type to use with an <html:select> tag that allows multiple selection. Make sure that both your getter and setter use this type. Also make sure that it is not null. You should declare it something like this:

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

or else put the following statement in your reset() method:

myselect = new String[0];

If you've tried these suggestions and it still doesn't work, please tell us the error message you're getting and post relevant portions of the jsp and struts-config.xml file.


Merrill
Consultant, Sima Solutions
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
When I add a project, via my add form it only adds the first item in the list, not any selected items following. When I use the edit form it resets the field to null, no matter what is selected. Code snippets follow.

Add Form:
-declaration

-reset

-getters and setters


Add Action:


Edit Form:


Edit Action:


Value Object (ProjectImpl):


Utility:

[ September 12, 2006: Message edited by: Chris Novindus ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple selections