Child pages
  • text
Skip to end of metadata
Go to start of metadata

Please make sure you have read the Tag Syntax document and understand how tag attribute syntax works.

Description

{snippet:id=javadoc|javadoc=true|url=org.apache.struts2.components.Text}

For more details on using resource bundles with Struts 2 read the localization guide.

Parameters

{snippet:id=tagattributes|javadoc=false|url=struts2-tags/text.html}

Examples

{snippet:id=exdescription|lang=none|javadoc=true|url=org.apache.struts2.components.Text} {snippet:id=example|lang=xml|javadoc=true|url=org.apache.struts2.components.Text}

Other example

xml <s:text name="format.money"><s:param name="value" value="myMoneyValue"/></s:text>

where the following is in a regular (possibly locale-specific) properties file:

format.money={0,number,currency}

For more about formatting text, see

  1. http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html
  2. http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html

If you wish to use i18n in your tag attributes

This will not work:

xml <s:textfield name="lastName" label="<s:text name="person.lastName"/>" ../>

Instead, you should use the getText() method that you inherit when your Action extends XWork's ActionSupport:

xml <s:textfield name="lastName" label="getText('person.lastName')" ../>
  • No labels

1 Comment

  1. Actually the syntax proposed is not exact, at least for a button. The following syntax gave me the expected result : <s:submit name="Create" value="%

    Unknown macro: {getText('domain.management.button.create')}

    " method="prepareCreateDomain"/>