• 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

Putting i18n Value Into Tag

 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want the labels of my submit buttons be taken from the message resource file. However, I cannot nest <bean:message> inside another <html:submit > tag. I know I can use plain HTML code e.g. <input type=submit.. <bean:message...> > where the HTML are cosidered as plain template text. But, what would the best technique if I want to use <html:submit> to render the button?
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try
<html:submit><bean:message key="button.submit"/></html:submit>

here's something to consider though...
why use html:submit or html:button? only makes sense if you are using LookupDispatchAction, but for simple forms, they buy you nothing more than the plain old 'input'. i am not making this argument for the rest of the form, just the buttons.
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thx. But, I checked the online documentation of struts. It seems that <html:submit> is not formally documented to accept a body. Although it seems working as what you advised!
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The documentation is a little vague on this, but for any <html:xxxx> tag, if you include a tag body, it will be used as the "value" attribute.

Here's the URL in the doucmentation:

http://struts.apache.org/api/org/apache/struts/taglib/html/package-summary.html#doc.Form.attributes.struts
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually my generic strategy of putting i18n message into tag's attribute - any attribute, not just <html:submit value=..> - is something like this:

<c:set var="myMsg">
<bean:message key=".."/>
</c:set>

<my:SomeTage attrib="${myMsg}">

Does anyone have a better idea then mine? I am trying to think of a generic coding strategy.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic