• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple selections

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic