aspose file tools*
The moose likes Struts and the fly likes how to iterate a ArrayList in a session+struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to iterate a ArrayList in a session+struts2" Watch "how to iterate a ArrayList in a session+struts2" New topic
Author

how to iterate a ArrayList in a session+struts2

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
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

Joined: Oct 29, 2001
Posts: 8927
    
    9

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?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

(If it's a multi-select it should be "fruits" :)

Please see ItDoesntWorkIsUseless.

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
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

Joined: Oct 27, 2009
Posts: 336
Can somebody show the correction?I mean the list declaration is incorrect I think...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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.
 
 
subject: how to iterate a ArrayList in a session+struts2