• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Nested bean tags for dynamic message retrieval

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am hoping that this is a clever way to iterate through a set of messages that will allow me to dynamically pull tags from the applicaiton resource.

This code does not work, but if it did, this would be the functionality I was looking for.



pretty much it iterates over the set of names for the user. It needs to append those onto the end of the message key and print out the resulting label from the application resource.

And help?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using V 1.2 or above, you might try using a scriptlet, as in:

<bean:message key="sacReport.label.<%=colBean.getName()%>"/>

I believe in version 1.2 or above, struts evaluates scriptlets before evaluating the custom tags.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The option suggested by Merrill should work good all versions with a slight modification as,
<bean:message key='<%="sacReport.label."+colBean.getName()%>'/>
as the attributes with RT expr decleared true can have a scriplet for the value, for comatibility the whole value should be a scriplet.

Or else bean-el:message, the version supporting expression language can be used as
<bean-el:message key='sacReport.label.${colBean.name}'/>
 
Gran Roguismo
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys, just what I was looking for.
 
reply
    Bookmark Topic Watch Topic
  • New Topic