• 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

Struts 2 - Internationalize Submit Text

 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to internationalize the text in a submit button using package.properties file. The properties file works for all other fields but seems to be ignored in submit/reset buttons. I've tried a number of combinations including:
<s:submit value="widgetform.submit"/>
<s:submit value="${widgetform.submit}"/>
<s:submit value="#{widgetform.submit}"/>
<s:submit label="widgetform.submit"/>
<s:submit name="widgetform.submit"/>
Where "widget.submit" is a key to a text value defined in my properties file. Most of these end up with the button value displaying "widgetform.submit". Am I missing an obvious combination or is this a broken feature?

The long (invalid) form for what I'd like is:
<s:submit value="<s:text name="widgetform.submit"/>"/>
If anyone has a solution using the long form that doesn't throw a compilation error due to the embedded tag, I'll take that too.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) That would try to get a value from an action property.
2) Same, but would fall back to a JEE scoped attribute if no action property.
3) That's JSF (or unified) EL, or whatever it's called.
4) I don't think submit buttons have labels.
5) Similar to #1.

Personally I'd go the route of the other tags first and try the "key" attribute.

If that failed, I'd use OGNL's method call support:

 
Scott Selikoff
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, "key" worked. I still feel like this is a guessing game. I mean many of the other fields use name to establish the same thing, it feels like submit/reset should use name as well.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, they don't: "name" defines the action property used to fill an input element and the name of the element that will be submitted (and stored into the action property). It doesn't have anything to do with I18N--it's just defining the form element name and, if there's no "value" attribute, will pre-load the input element w/ the action property's value.

The "label" property is expecting a string to use as the text element's label: submit buttons, however, don't have a separate label. Labels are the things that appear next to the form fields; submit-type things are different because labeling them would be a little redundant. The string used as the label can be immediate (the default) or the result of an arbitrary method call--in the example I provided I used ActionSupport's getText() I18N support.

The "key" property is just shorthand for a set of name/value/localized label attributes; it's the only attribute that automagically does I18N.
 
Scott Selikoff
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So all the places I'm using 'name' that happens to resolve the i18n should be 'key'? I don't disagree that "key" is the way to go for submit/reset buttons, but it seems like confused redundancy that "name" does i18n throughout a dozen other tags, and not these two.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What version of S2 are you using? I don't see that behavior under S2.1, although it may work in S2.0.
 
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic