Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Struts2: use a property as key in a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2: use a property as key in a jsp" Watch "Struts2: use a property as key in a jsp" New topic
Author

Struts2: use a property as key in a jsp

Sebastien Viale
Greenhorn

Joined: Jun 02, 2010
Posts: 2
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

Joined: Jul 29, 2001
Posts: 75
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

Joined: Sep 29, 2008
Posts: 12617

@Shilpa: Struts 2.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2: use a property as key in a jsp