• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Accessing an element of a list, whose position is given as URL parameter

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a java object which is in session. It is a list (userList).
I also get an id value in my URL.
I would like to use this id as the position in the list from which to retrieve an element.

Not-working code:

<bean arameter id="idxUser" name="id" />
<bean efine id="test" name="sessionController" property="userList[$(idxUser)]"/>

Working code (where I hardcode a test value):

<bean arameter id="idxUser" name="id" />
<bean efine id="test" name="sessionController" property="userList[0]"/>

Does anyone know how to solve this ?

Thanks,

Stephane

P.S. I am using Struts 1.1, if this is any help ...
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
property="userList[${idxUser}]"/>

might work with bean-el tags.

Also, if you were iterating through a bunch of users to display them all, you wouldn't have to specify the index.
reply
    Bookmark Topic Watch Topic
  • New Topic