Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

The simplest way to inject resource bundle messages into tag attributes is to use the Action's getText method. Another way is to edit the tag templates to use the resource bundle by default.

Calling getText

Code Block
<saf:textfield label="%{getText('label.firstName')}" name="firstName" />

The getText method will look for an entry in the resource bundle with the key "label.firstName", and the value of the "firstName" property will be provided by the Action, or some other object on the Value Stack.

Editing the Templates

If using the resource bundle is the default for your application, you might consider modifying the controlheader-core.ftl template. If the xhtml theme is being used, the original template is found at {{/template/xhtml}.

Code Block
titlecontrolheader-core.ftl
${parameters.label?html}:<#t/>
Code Block
<#assign mm="getText('"+parameters.label?html+"')" /><#t/>
${stack.findValue(mm)}:<#t/>

or

Code Block
${stack.findValue("getText('"+parameters.label?html+"')")}

After making the change, tags with a label attribute will use the value you set as a key.

Code Block
<saf:textfield label="label.firstName" name="firstName" />