Take the 2-minute tour ×

I'm using Tiles 2.2.2 in my application (Struts 2.2.3). I want to use expressions in order to modify my screen composition depending on some attribute in the request. Basically, I would like to change the extends of a screen depending if there is a header in the request with name "x-requested-with" and the value is "XMLHttpRequest". Is it possible to do that? I've tried to do a simple example with an attribute:

<put-attribute name="test"   expression="OGNL:requestScope"  cascade="true"/>

I've tried different expressions like OGNL:%{#request.headers.referer}, OGNL:#request.headers.referer, OGNL:requestScope.headers.referer , etc. But it always returns null. I haven't found any documentation on how the OGNL expressions works on Tiles, so I'm working based on how I would do it with Struts. But it doesn't seem to work.

Any ideas?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

How are you initializing Tiles? If you're using the StrutsTilesListener, OGNL expressions in tiles.xml won't be evaluated.

In my Struts2 app, I am using the org.apache.tiles.extras.complete.CompleteAutoloadTilesListener in web.xml and OGNL evaluation is working:


In my case, I have a custom TilesResult with a property called 'content':

<put-attribute name="content" expression="OGNL:content" />
share|improve this answer
Humm, I have to try that. You mention you have a custom TilesResult. Why don't you use the one provided by the Struts2-Tiles plugin? –  Jose L Martinez-Avial Nov 2 '12 at 18:02
I extend the provided org.apache.struts2.views.tiles.TilesResult and add some custom properties to be set via an Action's @Result annotation parameters. –  Brando_Calrissian Nov 5 '12 at 13:42
add comment

Your Answer


