Versions Compared

Key

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

Overview

SiteMesh is a

...

web-page

...

layout

...

and

...

decoration

...

framework

...

and

...

web-

...

application

...

integration

...

framework

...

to

...

aid

...

in

...

creating

...

large

...

sites

...

consisting

...

of

...

many

...

pages

...

for

...

which

...

a

...

consistent

...

look/feel,

...

navigation

...

and

...

layout

...

scheme

...

is

...

required.

...

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. Look here for more information.

Localization

WebWork provides easy to use i18n functionality to SiteMesh decorators. Now using the <ww:text/> tag works seemlessly. In the 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:

Code Block
xml
xml




h2. 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. Look [here|set] for more information.



h2. Localization

WebWork provides easy to use i18n functionality to SiteMesh decorators. Now using the *<ww:text/>* tag works seemlessly. In the 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:
{code:xml}
<ww:textfield label="%{getText('com.acme.login.text')}" name="login"/>
{code}

However,

...

due

...

to

...

the

...

way

...

WebWork

...

and

...

SiteMesh

...

work,

...

you

...

would

...

need

...

to

...

seperate

...

the

...

above

...

code

...

in

...

to

...

two

...

tags.

Code Block
xml
xml


{code:xml}
<ww:text id="login" name="com.acme.login.text"/>

<ww:textfield label="#login" name="login"/>
{code}



h2. Custom Decorators

In 

Custom Decorators

In WebWork's

...

Architecture

...

,

...

the

...

standard

...

filter-chain

...

optionally

...

starts

...

with

...

the

...

ActionContextCleanUp

...

filter,

...

followed

...

by

...

other

...

desired

...

filters.

...

Lastly,

...

the

...

FilterDispatcher

...

handles

...

the

...

request,

...

usually

...

passing

...

it

...

on

...

to

...

the ActionMapper. The primary purpose of the ActionContextCleanUp is for SiteMesh integration. This tells the FilterDispatcher when exactly, to clean-up the request. Otherwise, the ActionContext may be removed before the decorator attempts to access it.

Warning
titleWarning

If ActionContext access is required within the decorators, the ActionContextCleanUp filter must be placed at the beginning of the filter-chain.

Velocity

If you are using Velocity for your SiteMesh decorators, we recommend using the VelocityPageFilter. This is an extension of the SiteMesh PageFilter, which should be placed in the web.xml in between the ActionContextCleanUp and the FilterDispatcher. Now the Velocity decorators will have access to WebWork variables such as $stack and $request.

Code Block
xml
xml
titleweb.xml
 ActionMapper. 

{warning:title=Warning}
_If_ ActionContext access is required within the decorators, the *ActionContextCleanUp* filter _must_ be placed at the beginning of their filter-chain. This tells the FilterDispatcher when, exactly, to clean-up the request. Otherwise, the ActionContext may be removed before the decorator attempts to access it.
{warning}


h3. Velocity 

If you are using Velocity for your SiteMesh decorators, we recommend using the VelocityPageFilter. This is an extension of the SiteMesh PageFilter, which should be placed in the web.xml in between the *ActionContextCleanUp* and the *FilterDispatcher*. Now the Velocity decorators will have access to WebWork variables such as $stack and $request.

{code:xml|title:web.xml}
    <filter>
    	<filter-name>webwork-cleanup</filter-name>
    	<filter-class>com.opensymphony.webwork.dispatcher.ActionContextCleanUp</filter-class>
    </filter>
    <filter>
	<filter-name>sitemesh</filter-name>
	<filter-class>com.opensymphony.webwork.sitemesh.VelocityPageFilter</filter-class>
    </filter>
    <filter>
        <filter-name>webwork</filter-name>
        <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
    </filter>

FreeMarker

If you are using FreeMarker for your SiteMesh decorators, we recommend using the FreeMarkerPageFilter. This is an extension of the SiteMesh PageFilter, which should be placed in the web.xml in between the ActionContextCleanUp and the FilterDispatcher. Now the FreeMarker decorators will have access to WebWork variables such as ${stack} and ${request}.

Code Block
xml
xml
titleweb.xml
{code} 


h3. FreeMarker 

If you are using FreeMarker for your SiteMesh decorators, we recommend using the FreeMarkerPageFilter. This is an extension of the SiteMesh PageFilter, which should be placed in the web.xml in between the *ActionContextCleanUp* and the *FilterDispatcher*. Now the FreeMarker decorators will have access to WebWork variables such as ${stack} and ${request}.

{code:xml|title:web.xml}
    <filter>
    	<filter-name>webwork-cleanup</filter-name>
    	<filter-class>com.opensymphony.webwork.dispatcher.ActionContextCleanUp</filter-class>
    </filter>
    <filter>
	<filter-name>sitemesh</filter-name>
	<filter-class>com.opensymphony.webwork.sitemesh.FreeMarkerPageFilter</filter-class>
    </filter>
    <filter>
        <filter-name>webwork</filter-name>
        <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
    </filter>
{code}