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?
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’: