Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2: use a property as key in a jsp

 
Sebastien Viale
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Here is my problem:

I have a map "listeRessources.map" in a jsp, I can get a value with a key like this:

<s:property value="listeRessources.map['idconcept']" /> prints Oeuvre224

I have a property file from which I can get the value idconcept:

ID_CONCEPT=idconcept

so in the jsp <s:text name="ID_CONCEPT"/> prints idconcept

I would like to get the value of the key using the property file, I tried

<s:property value="listeRessources.map[<s:text name='ID_CONCEPT'/>]"

but it does not work.

Can you help me please?

thanks

 
Shilpa Tendulkar
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you want to print value and key from map


you may need to convert it to tags you are using >< s : your_iterate_tag >
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Shilpa: Struts 2.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keys shouldn't really be in property files in my opinion, but I'd say the easiest way would be to do a bit more work on the server side.

Obviously you can't nest custom tags like that, but you might also be able to set a JSP var with the value and access it via OGNL.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic