Tuesday, June 27, 2006

WebWork 2 and Internationalization

I've been super keen on WebWork of late. Years ago I had friends mention WebWork to me but I didn't even give it the remotest looking. I was working with Struts 1 all day everyday and that's all I did.

Anyway, today I wanted to try Internationalization with WebWork and was stuck. To my rescue in the WebWork Forums came Philip Luppens. I wouldn't have gotten anywhere without his help and want to share the fruit of the results here.

Update: I am using the I18nInterceptor because I want the ability to change locales to others than what the browser is telling the server. It's not needed if you want the server to simply pick up the appropriate properties file based on the browsers locale. Thanks to Jason Carreira for pointing that out to me.

Step One : Make sure you have I18nInterceptor available

In xwork.xml I have the default package and the defaultStack set.



Step Two : Set properties file in webwork.properties



Step Three : Set label values in properties files



Step Four : Use tags to getTexts

Update: I'm using i18n tags because I want the ability to change locales. If not the server would know the locale, pick up the appropriate properties file and allow me to use straight ww:property or ww:text tags.



My Login JSP



Login JSP after changing Locale

Added parameter : ?request_locale=pl




Bingo!

Sunday, June 11, 2006

Deploying WebWork 2 Portlet into Jetspeed 2 Portal

A quick step by step guide.

1) Download Jetspeed 2.0 installation binary here.

2) Download WebWork 2.2.2 here.

3) Run the Ant build. (It may take a while for Ivy to download the required jar files.)

4) Run the Ant build for the WebWork sample Portlet, it's under the 'webapps' directory. The command is 'ant build-portlet'.

5) A 'webwork-portlet.war' will appear under the 'webapps/dist' directory but you will need to check that the 'WebWork-2.2.2.jar' is under the '/WEB-INF/lib' in the war file.

6) Copy the 'webwork-portlet.war' to the '<jetspeed2-server-directory>/webapps/jetspeed/WEB-INF/deploy' directory.

7) Add the following to 'default-page.psml' under the '<jetspeed2-server-directory>/webapps/jetspeed/WEB-INF/pages' directory.



<fragment id=“dp-8” type=“portlet” name=“webwork-portlet::WebWorkPortlet”>
<property layout=“TwoColumns” name=“row” value="“1” />
<property layout=“TwoColumns” name=“column” value=“0” />
</fragment>



(of course not conflicting with any used fragment id or anything that might be using the same row or column)

8) A couple refreshes on the page and the Portlet showed up nicely.

Matt