Hi,

In Tiles1 I used to be able to import an action using

<tiles:insert page="/somaction.do"></tiles:insert>

In Tiles2 (& struts2) the equivalent should be:

<tiles:insertTemplate template="/someaction.action"></tiles:insertTemplate>

but this only renders the following text:

"The requested resource (/someaction.action) is not available."

See the attached war. Take a look at /s2t2/test.action

The success of test.action maps to tile test.layout:

<definition name="test.layout" template="/testlayout.jsp">
 <put-attribute name="menuclass" value="leftmenu"/>
 <put-attribute name="bottom" value="/bottom.jsp"/>
</definition>

Here is testlayout.jsp, notice the insertTemplate at the end:
---------------------
<%@ taglib uri="http://tiles.apache.org/tags-tiles"; prefix="tiles"%>
<tiles:importAttribute name="menuclass"/>
<html>
<body>
test layout
<hr/>
<tiles:insertAttribute name="menuclass"/>
<hr/>
<tiles:insertTemplate template="/bottom.jsp">
 <tiles:putAttribute name="menuclass" value="${menuclass}"/>
</tiles:insertTemplate>
<hr/>
<tiles:insertTemplate template="/test2.action">
</tiles:insertTemplate>
</body>
</html>


test2.action works, /s2t2/test2.action produces the text "test2layout jsp page".

However, what is rendered is
"The requested resource (/s2t2/test2.action) is not available"
in place of where the action's result should be inserted.

Any thoughts?

The war file is available here:
http://www.speedyshare.com/571330338.html

I'm using struts 2.0.11 and tiles 2.0.5

Dok


================= CONFIG FILES ================

------------------------------------------------------------------------------------------
web.xml
------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app>
  <display-name>struts2-tiles2</display-name>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <listener>
    
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
  </listener>

......... jsps ........

------------------------------------------------------------------------------------------
tiles.xml
------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
        "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
        "http://tiles.apache.org/dtds/tiles-config_2_0.dtd";>

<tiles-definitions>
<definition name="test.layout" template="/testlayout.jsp">
  <put-attribute name="menuclass" value="leftmenu"/>
  <put-attribute name="bottom" value="/bottom.jsp"/>
</definition>
<definition name="test2.layout" template="/test2layout.jsp">
</definition>
</tiles-definitions>

------------------------------------------------------------------------------------------
struts.xml
------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd";>
<struts>
  <package name="default" extends="tiles-default">
    <action name="test" method="execute" class="test.TestAction">
      <result type="tiles">test.layout</result>
    </action>
    <action name="test2" method="execute" class="test.Test2Action">
      <result type="tiles">test2.layout</result>
    </action>
  </package>
</struts>

Reply via email to