Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Instead, the recommended approach is to use Java's built-in date formatting features via use of the webworks:text tag.

The webworks:text tag should be used for all i18n values. It will look up the properties file for your action, and from that select the value for the key that you specify. This is best illustrated in an example:

Code Block
<!-- display the number of items in a cart -->
<webwork<s:text name="'cart.items'" value0="cartItems" />

...

Needless to say, this can get a lot more elaborate, with the ability to specify both date and number formatting. Let us consider another example. The goal here is to display a greeting to the user, as well as the date of their last visit.

Code Block
<webwork<s:text name="'last.visit'" value0="userName" value1="lastVisit(userName)" />

...

Info
titlevalue0 interface deprecated

The examples above pass in the values as:

Code Block
<webwork<s:text name="'text.message'" value0="userName"/>

These values should now (>2.1.7?) be passed as params:

Code Block
<webwork<s:text name="'text.message'"> 
    <webwork<s:param value="'userName'"/>
</webworks:text>
Tip
titleSome message format examples

Here are some examples of formatting in the properties file:

Code Block
format.date = {0,date,MM/dd/yy}
format.time = {0,date,MM/dd/yy ha}
format.percent = {0,number,##0.00'%'}
format.money = {0,number,$##0.00}