I want Tiles to resolve ognl from the struts2 value stack. How to do this?
Using tiles 2.2.2 (although if a later version such as 3 could be used that is fine)
Here it mentions the new feature:
http://tiles.apache.org/2.2/framework/whats-new.html
Here it shows how to implement it: http://tiles.apache.org/2.2/framework/tutorial/advanced/el-support.html#OGNL_Support
But I’m not certain how to go about that in my project. Does anyone have tiles3 working in their struts2 project? I remember reading about some way to turn on all new features in tiles 3 by default but I can’t find a link to that page.
If configuration can be done in anyway with spring that is fine (if that helps, if not it is not an issue).
I love the tiles tempate system because it is simple and straight forward, with Tiles 2.2.2 you can have wild card support to push your struts2 conventions right into the template system and now there is OGNL too!
Steps to add tiles 2.2.2 with OGNL support within tiles (Currently using Struts 2.3.1.2):
1) Add the struts2-tiles-plugin
2) Add the tiles 2.2.2 jars including the jars which add ognl support. Assumes maven: ALL group ids are: org.apache.tiles ALL versions are 2.2.2, the following are artifact ids :
Also needed to add the following:
log4j, log4j, 1.2.14 (Should already be part of the basic setup: http://struts.apache.org/2.x/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html)
slf4j-api, org.slf4j, 1.6.4
By using the org.apache.tiles.extras.complete.CompleteAutoloadTilesListener you get Wild Cards, EL, OGNL, MVEL support in your tiles.xml
Example web.xml:
struts.xml for a demo: The demo uses OGNL from struts to display a hard coded greeting message. Three action mappings exist “”, “test”, and “package/*” the value that follows the slash will be used by tiles to set a new title. A very trivial example but does show some useful features.
tiles.xml
/WEB-INF/content/tiles/body.jsp
/WEB-INF/content/tiles/footer.jsp
/WEB-INF/content/tiles/header.jsp
/WEB-INF/content/tiles/template.jsp
Test.java Action
That should now be enough to get tiles working for your application.