Hi,

(Note: I have read some threads on this list about the same topic, but I found no answer. If I missed the right thread, I'm sorry. Furthermore, this might be a struts- and not a tiles question. I am not sure about that.)

I am trying to figure out how to do this the "right" way:

I have a struts action which returns a tile as a result. This tile has an attribute which points to another tile, which uses another action as template:

   <definition name="layout" template="layout.jsp" >
     <put-attribute name="menu" value="menu" />
   </definition>

   <definition name="menu" template="/menu.action"  />

layout.jsp contains the line:

   <tiles:insertAttribute name="menu" />

At first I got the error message:

   The requested resource (/s2demo/menu.action) is not available

(This text was printed where the menu should have gone)
Somewhere on this list I found that I should add the struts filter dispatcher like this:

  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>...FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
  </filter-mapping>

  (filter class name truncated for shortness)

After I did this, everything seemed fine at first - the menu rendered.

First question: is this the right way of doing that?

But then I started to use my function taglib. The tag library internally uses ServletActionContext.getRequest() for accessing the HttpServletRequest object.

As soon as layout.jsp contains <tiles:insertAttribute name="menu" />, ServletActionContext.getRequest() returns null in my taglib implementation, when called from layout.jsp like this:

   <tiles:insertAttribute name="menu" />

   <c:if test="${mylib:someThing()}" >...</c:if>

Without the insertAttribute call, the taglib works fine.

Can you help me with this?

Thanks in advance!

Daniel Baldes

Reply via email to