• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts2 Action/OGNL in SiteMesh decorator

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

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?

    but then i read this:
    http://www.opensymphony.com/sitemesh/decorators.html
    and i see include JSP directives in decorator... and i don't understand, how can they be processed. i can think of only one case - SM filter uses dispatcher to forward... please explain...

    please point me correct way to implement what i am trying to do.

    thank you
     
    Raigedas Lietuvis
    Greenhorn
    Posts: 16
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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...
     
    Raigedas Lietuvis
    Greenhorn
    Posts: 16
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.

    my web.xml:



    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.

    good luck
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic