You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

SiteMesh can be found at http://www.opensymphony.com/sitemesh

Integrating WebWork with SiteMesh is amazingly simple: you don't have to do anything in fact. WebWork stores all its value stack information in the request attributes, meaning that if you wish to display data that is in the stack (or even the ActionContext) you can do so by using the normal tag libraries that come with WebWork. That's it!

Passing data around

One thing to note is when you want to pass a value from a decorated page to a decorator using the <ww:set> tag, you need to specify a scope (request, session, application) if the decorated page is invoked directly (not a result of an action). By default if no action has been executed and no scope was specified, the set value will only availlable from the same PageContext.

Localization

In WebWork 2.1.7, support was added that makes using i18n in decorators much easier. Now using the <ww:text/> tag works seemlessly. In the rare event where you need to reference an i18n string, use the id attribute as documented in the Text tag.

An example of such situation is given below. Typically embedding i18n in to form elements would be done using the following:

<ww:textfield label="getText('com.acme.login.text')" name="'login'"/>

However, due to the way WebWork and SiteMesh work, you would need to seperate the above code in to two tags.

<ww:text id="login" name="'com.acme.login.text'"/>
<ww:textfield label="#login" name="'login'"/>

SiteMesh, Velocity, and WebWork

If you are using Velocity for your SiteMesh decorators, we recommend not using the WebWorkVelocityServlet or the SiteMeshVelocityServlet. In fact, we don't recommend you use any servlet at all. Instead, try creating a servlet that extends PageFilter and then using that servlet in place of PageFilter in web.xml. In your cusotm servlet, override the applyDecorator() method and then use WebWork's VelocityManager to access your decorator templates. You can use VelocityManager to create a default Context as well, which will include all the WebWork variables such as $stack. Then simply add the Page object to the context and then you can access the page parts using $page.title, $page.body, etc.

  • No labels