File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes how to fire struts2 action from tiles2 definition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to fire struts2 action from tiles2 definition" Watch "how to fire struts2 action from tiles2 definition" New topic
Author

how to fire struts2 action from tiles2 definition

Ramesh David
Greenhorn

Joined: Jan 28, 2008
Posts: 1
Hi All,
I was not able to call struts2 action from tiles 2 definition. Basically i'm calling index.jsp and that calls welcome.action. After welcome.action is done and suppose to call st2action.action (another struts 2 action) from tiles definition but it is not. I'm getting following error message. Please see below information

The requested resource (/struts1/s2action) is not available

Thanks in advance,
Ramesh

web.xml

<web-app>
<filter>
<filter-name>webwork</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
<filter-name>webwork</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>

<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
.....
.....
</web-app>

index.jsp
<%@ page contentType="text/html" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<c:redirect url="http://localhost:8080/struts1/welcome.action"/>

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>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<package name="Webtest" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<action name="st2action" class="com.action.st2Action" >
<result name="SUCCESS">/jsp/st2/st2.jsp</result>
</action>
<action name="welcome" class="com.action.welcome" >
<result name="SUCCESS" type="tiles">both</result>
</action>
</package>
</struts>

tiles.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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="both" template="/jsp/st2/layout.jsp">
<put-attribute name="title" value="This is the title."/>
<put-attribute name="header" value="/jsp/header.jsp"/>
<put-attribute name="body" value="st2action.action"/>
<put-attribute name="footer" value="/jsp/footer.jsp"/>
</definition>
</tiles-definitions>


Env: Apache tomcat6/struts2.0.5/tiles 2.04
Chan Yan
Greenhorn

Joined: Oct 21, 2005
Posts: 15
Hello, Ramesh David,

Did you figure out how to fire action in tiels.xml (in struts2/tiles2)? I have same problems now.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to fire struts2 action from tiles2 definition
 
Similar Threads
Facing an issue trying to use Struts 2.0.14 with Tiles 2.0.
Error with Struts 2 and Tiles 2
There is no Action mapped for namespace / and action name welcomeLink. - [unknown location]
struts 2: tiles problem
struts2 action from tiles definition fired multiple times