Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem getting all parameters from multiple select

 
Shawn Kuenzler
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a multiple select option box that's properly displaying all the values. I'm using getParameterValues() to retrieve all of the selections but it only returns a string[] with the first selection made. I'm guessing something is wrong in my JSP.



Here's the servlet snippet:



Thanks!
[ April 16, 2007: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, on first inspection everything seems OK. How about showing us the final renderred HTML rather than the JSP source? That way we can eliminate any masked markup problems.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, everything seems fine. (<- ok this does not help)

Please also show us how you checked that there is only one element in the array.
[ April 16, 2007: Message edited by: Satou kurinosuke ]
 
Shawn Kuenzler
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The debugger clearly shows that the array is only populated with one value, when I have selected two.

Here's that portion of the HTML rendering:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Umm, how are you selecting elements from a disabled control?
 
Shawn Kuenzler
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The select gets enabled when the user chooses the search option that they apply to. I took that bit of code out earlier so as to avoid this question from you guys...forgot to pull it out of the HTML. It is enabled when I make the selections.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Do you have any other elements called "subset" in the same page ?
2. Can you show us why you think there is only one selection being sent ?
 
Shawn Kuenzler
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satou, I thought you had it! I did have another component named "subset", it was the select list itself. I renamed it but no dice.

Other than showing you a screen shot of the debugger, I don't know how to show you that this array only gets populated with the uppermost selection from the list. I set a breakpoint just after this line and clearly see only the top selected ID as a string element in the array.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works without a hitch for me. How about ditching the debugger and trying to log or emit the values?
 
Shawn Kuenzler
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't a logging framework setup on this app. I tried sysout's but they aren't showing up in the JBoss log or command prompt. But I'm confident there is only one value being retrieved. That's all that gets sent into my search filter.

I tried writing another simple multi select and had the same results. How frustrating.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shawn Kuenzler:
There isn't a logging framework setup on this app.


Why not? And, no time like the present.

I coded up a small test JSP page using your most recent example:



which submits to itself.

When both options are selected and the form submitted, the expected result appears:



What happens when you run this file? (Assumes you are up-to-date with JSP 2.0 and JSTL 1.1).
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to throw a real dumb question out there...

How are you selecting more than one value in your select list when you are using this page?
 
Shawn Kuenzler
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben, I click on one and then hold control and click on the other. Both are highlighted before submitting.

Bear, I tried the JSP and when it submits, Tomcat says 'the request resource /main.jsp is available. I need to reconfigure something on the app server I guess.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic