Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple selections

 
Chris Boldon
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chris Boldon
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic