• 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

Passing a bean:message as string to a custom tag?(Struts2)

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am pretty new to struts, so this may sound like a silly question, however in the app i am starting to write I have want to use struts and an ApplicationResource file for internationalisation. The problem I have is with passing a string parameter to a custom tag as s string. Although syntax is wrong (very) the below example should exemplify what I want to achieve.

<menu:menuItem label=" <bean:message key="labels.pfm.menus.admin.ManageVendors"/> " forward="manageVendors.do" />

Question: How do I pass in the string represented by 'labels.pfm.menus.admin.ManageVendors' in the ApplicationResource.properties as a string to the tag?




 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think, you're not allowed to cascade(hope I use correct word) the struts tag into another tag.
Still 2 solutions:
Use single ''' quote instead of double
OR
use(try) EL:


Welcome to JR and please use Code Tags to quote your code.
 
David Glossop
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sagar, thanks for the quick reply, however I think I am missing something as I can't get either solution to work?

The first results in a blank string ("") being passed and the second passes the string '<bean:message key="labels.pfm.menus.admin.ManageVendors"/>' ?


 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, you're saying its Struts 2, so have you checked the S2 docs for the tag similar for <bean:message key=""../>.
I think you can't pass the bean:message output to any tag "value", its associated with the out.print() and thus directed its out put o the HTML text content. So the only suggestion I advise is, modify your custom tag, like

Your label comes between the tag.

If you cant modify the custom tag code, then Use the JavaScript to assign value to the "label" ;)
 
David Glossop
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sagar, thanks again for the advice. i have resolved the problem by taking a moving the problem domain from the jsp to the tag.

In the tag I now use MessageResources to retrieve the key from the ApplicationResource.properties file.





 
David Glossop
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Glossop wrote:Sagar, thanks again for the advice. I have resolved the problem by taking a moving the problem domain from the jsp to the tag.

In the tag I now use MessageResources to retrieve the key from the ApplicationResource.properties file.





 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Glossop wrote:Sagar, thanks again for the advice. i have resolved the problem by taking a moving the problem domain from the jsp to the tag.


Brilliant, it couldn't get any better:thumbup:
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic