Saturday, December 15, 2007

How to Use the I18n messages in Struts and WebWorks

The Diffrence between the Internationalized message Struts, a very popular Java web framework, shares many similarities with WebWork. when we’re building large-scale web applications. eg. consider the case of comparing the tags that both frameworks use to display a an i18n message. In both frameworks, i18n text can be parameterized with dynamic values such as a price, number, and date. Suppose we have a message to display an air ticket confirmation in the following form:
message: "Your {0} ticket(s) for flight {1} have been booked. The total cost is {2}. Your confirmation number is {3}. Your flight leaves at {4} and arrives at {5}"
In Struts, we have a tag for i18n message. Struts only allows messages to be parameterized with five values, so our message should be split into two parts:
bean:message key="confirmation.msg1"arg0="count" arg1="flightNumber" arg2="cost"/
bean:message key="confirmation.msg2"arg0="confirmation" arg1="departure" arg2="arrival"/

In WebWork, is also provide with a tag . so in webworks unlimited paramenter can be used:

ww:text name="confirmation.msg"
ww:param value="count"/
ww:param value="flightNumber"/
ww:param value="cost"/
ww:param value="confirmation"/ ww:param value="departure"/
ww:param value="arrival"/
/ww:text

so both the frameworks are used in the tradebeam

No comments: