Struts 2 > Text tag |

Struts 2
Text tag
Edit Page Browse Space Add Page Add News
Added by casey, last edited by Ted Husted on Sep 05, 2006 (view change)

### <ww:text />

Print out an internationalized string. It is used in conjuction with the i18n tag. The text tag gets a specific message from the bundle specified in the surrounding i18n tag. Values can be passed into the message for parsing, for instance to format a date or currency. If the text tag is not used in conjuction with a i18n tag, it will search through the class hierarchy. Please look at Localization for more details.

Attributes

Name | Required | Description
--- | --- | ---
name | yes | Name of property to fetch
id | no | When specified, causes output to be stored in the ActionContext using the id as the key rather than printing out the text
value0 | no | Pass data to param 0 in message
value1 | no | Pass data to param 1 in message
value2 | no | Pass data to param 2 in message
value3 | no | Pass data to param 3 in message

Sample Usages

    Accessing messages from a given bundle (the i18n Shop example bundle in this case)<br>
    <ww:i18n name="'webwork.action.test.i18n.Shop'">
      <ww:text name="'main.title'"/>
    </ww:i18n>

    <ww:i18n id="foo" name="'webwork.action.test.i18n.Shop'">
      <ww:text name="'main.title'"/>
    </ww:i18n>
    <ww:property value="#foo"/>

Note that instead of using value0..value4, you may also:

    <ww:text name="'someKey'">
        <ww:param value="'Hello'"/>
    </ww:text>

OR

    <ww:text name="'someKey'">
        <ww:param>Hello</ww:param>
    </ww:text>

> The last format is particularly good when you are embedding HTML in to the message, since you don't need to worry about escaping the various quotes that might be there.