• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to iterate a ArrayList in a session+struts2

 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I stored an ArrayList in a session...



in my Jsp I say...

<s:select theme="simple" disabled="true" requiredposition="left"
list="#session.fruits" id="fruitid" name="fruitList" ></s:select>

what should be the correction here?

 
Joe Ess
Bartender
Posts: 9340
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly what is wrong? Are you seeing an error or are you just not getting the expected behavior?
I'd expect disabled="true" to make the control do nothing.
The "name" parameter is going to be the name of the control and also the name of the property on the action that will get set. I would not expect that property to be named "fruitList". I'd expect something like "fruit" or "fruitId".
What does the list fruits contain? Fruit objects or String objects?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(If it's a multi-select it should be "fruits" :)

Please see ItDoesntWorkIsUseless.

 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the list fruits contain? Fruit objects or String objects?


It contains the list of all fruits...

Exactly what is wrong? Are you seeing an error or are you just not getting the expected behavior?


It's saying list="#session.fruits" is not valid declaration... what should it be?
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody show the correction?I mean the list declaration is incorrect I think...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try wrapping it in the %{} OGNL escape. If that doesn't do it, maybe try turning off JSF expression evaluation. If that doesn't do it, post a minimal, complete action/JSP that reproduces the problem, and I'll try it locally. Also, make sure that you can access *any* scoped attributes, preferably both request and session objects, in a *new* JSP page with a new action.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic