while reading books, examples i have found only "Hello World" examples, but now i need to start a project with "Real World" scenario.
there is a description of a problem that i want so solve:
every page should have the same navigational menu
the menu is dynamic, fetched from DB
i want to construct menu in S2 Action or Interceptor
i choose SiteMesh for templating. i have created a SimeMesh decorator and try to use OGNL or S2 tags (yes, i have included S2 taglib page directive) in it but none of them works.
i looked at this:
http://www.opensymphony.com/sitemesh/flow.html and now it seems logical that i can not use OGNL or S2 tags in SimeMesh decorators - they are never executed. only originally requested resource gets executed (the one referred as <decorator:body />), then the result is handed to SiteMesh Filter.. then i have a question - what is the point of using SiteMesh if it can only add some static information?
please point me correct way to implement what i am trying to do.
Joined: Oct 31, 2009
i have found out that Struts2 tags actually are processed in the SiteMesh decorators.
the problem is that ValueStack seems to be unaccessible. for example, if originally requested Action contains "message" property, then i am able to see it in main JSP (that referred by <decorator:body/>) using:
but not in decorator...
Joined: Oct 31, 2009
i have managed to make it work.
for those who may be strugling with Struts2-SiteMesh integration, there i provide some guideslines:
1. make sure that you declare Filters in web.xml in this order: first there must be a ActionContextCleanUp Struts2 filter, then SiteMeshFilter and lastly Struts2. (i provided my web.xml below)
2. sitemesh filter mapping may need additional dispatchers: FORWARD, INCLUDE. default is only REQUEST. (i provided my web.xml below)
3. you may need to add library struts2-sitemesh-plugin-*.jar which comes bundled with struts2.
by the way, it looks that in new version of Struts2, com.opensymphony.sitemesh.webapp.SiteMeshFilter is changed with org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter, and org.apache.struts2.dispatcher.FilterDispatcher with org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.