You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by dd...@apache.org on 2006/11/10 00:29:51 UTC
svn commit: r473138 - in /struts/struts2/trunk:
apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/
apps/showcase/src/main/resources/ apps/showcase/src/main/webapp/
apps/showcase/src/main/webapp/WEB-INF/ apps/showcase/src/main/webapp/WE...
Author: ddewolf
Date: Thu Nov 9 15:29:48 2006
New Revision: 473138
URL: http://svn.apache.org/viewvc?view=rev&rev=473138
Log:
Updating tiles plugin to utilize new snapshot. Adding a tiles showcase
Added:
struts/struts2/trunk/apps/showcase/src/main/resources/struts-tiles.xml
struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/tiles.xml (with props)
struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/
struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/body.jsp (with props)
struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/header.jsp (with props)
struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/layout.jsp (with props)
struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java (with props)
struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java
- copied, changed from r473024, struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesUtilImpl.java
Removed:
struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesListener.java
struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesUtilImpl.java
Modified:
struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java
struts/struts2/trunk/apps/showcase/src/main/resources/struts.xml
struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators.xml
struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml
struts/struts2/trunk/apps/showcase/src/main/webapp/showcase.jsp
struts/struts2/trunk/plugins/tiles/pom.xml
struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
Modified: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java?view=diff&rev=473138&r1=473137&r2=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java (original)
+++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/fileupload/MultipleFileUploadUsingListAction.java Thu Nov 9 15:29:48 2006
@@ -18,7 +18,12 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.struts2.showcase.fileupload;
import com.opensymphony.xwork2.ActionSupport;
+
+import java.io.File;
+import java.util.List;
+import java.util.ArrayList;
/**
* Showcase action - multiple file upload using List
Added: struts/struts2/trunk/apps/showcase/src/main/resources/struts-tiles.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts-tiles.xml?view=auto&rev=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/resources/struts-tiles.xml (added)
+++ struts/struts2/trunk/apps/showcase/src/main/resources/struts-tiles.xml Thu Nov 9 15:29:48 2006
@@ -0,0 +1,23 @@
+<?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="tiles" extends="tiles-default" namespace="/tiles">
+ <default-action-ref name="index"/>
+
+ <action name="index">
+ <result type="tiles">showcase.index</result>
+ <result name="success" type="tiles">showcase.index</result>
+ </action>
+
+ <action name="sanity">
+ <result type="redirect">/tiles/layout.jsp</result>
+ <result type="redirect" name="success">/tiles/layout.jsp</result>
+ </action>
+ </package>
+</struts>
+
+
Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts.xml?view=diff&rev=473138&r1=473137&r2=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/resources/struts.xml (original)
+++ struts/struts2/trunk/apps/showcase/src/main/resources/struts.xml Thu Nov 9 15:29:48 2006
@@ -41,6 +41,8 @@
<include file="struts-freemarker.xml" />
+ <include file="struts-tiles.xml" />
+
<package name="default" extends="struts-default">
<interceptors>
<interceptor-stack name="crudStack">
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators.xml?view=diff&rev=473138&r1=473137&r2=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators.xml (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators.xml Thu Nov 9 15:29:48 2006
@@ -16,6 +16,7 @@
<pattern>/chat/ajax/*</pattern>
<pattern>/hangman/ajax/*</pattern>
<pattern>/nodecorate/*</pattern>
+ <pattern>/tiles/*</pattern>
</excludes>
<decorator name="main" page="main.jsp">
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp?view=diff&rev=473138&r1=473137&r2=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp Thu Nov 9 15:29:48 2006
@@ -96,6 +96,7 @@
<li><a href="<s:url value="/chat/index.jsp"/>">Chat (AJAX)</a>
<li><a href="<s:url action="hangmanMenu" namespace="/hangman"/>">Hangman</a></li>
<li><a href="<s:url value="/fileupload" />">Fileupload</a></li>
+ <li><a href="<s:url value="/tiles/index.action" />">Tiles</a></li>
<li class="last"><a href="<s:url value="/help.jsp"/>">Help</a></li>
</ul>
</div>
Added: struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/tiles.xml?view=auto&rev=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/tiles.xml (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/tiles.xml Thu Nov 9 15:29:48 2006
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+-->
+
+ <!DOCTYPE tiles-definitions PUBLIC
+ "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/tiles-config_2_0.dtd">
+
+<tiles-definitions>
+
+ <definition name="showcase.index" template="/tiles/layout.jsp">
+ <put name="title" value="Tiles Showcase" />
+ <put name="header" value="/tiles/header.jsp" />
+ <put name="body" value="/tiles/body.jsp" />
+ </definition>
+
+</tiles-definitions>
Propchange: struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml?view=diff&rev=473138&r1=473137&r2=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml Thu Nov 9 15:29:48 2006
@@ -5,6 +5,11 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts Showcase Application</display-name>
+
+ <context-param>
+ <param-name>org.apache.tiles.CONTAINER_FACTORY</param-name>
+ <param-value>org.apache.struts2.tiles.StrutsTilesContainerFactory</param-value>
+ </context-param>
<filter>
<filter-name>struts-cleanup</filter-name>
@@ -43,6 +48,12 @@
<listener>
<listener-class>
org.apache.myfaces.webapp.StartupServletContextListener
+ </listener-class>
+ </listener>
+
+ <listener>
+ <listener-class>
+ org.apache.tiles.listener.TilesListener
</listener-class>
</listener>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/showcase.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/showcase.jsp?view=diff&rev=473138&r1=473137&r2=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/showcase.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/showcase.jsp Thu Nov 9 15:29:48 2006
@@ -75,6 +75,9 @@
<!-- Hangman (AJAX and Non AJAX) Example -->
<li><s:url id="url" action="hangmanMenu" namespace="/hangman"/><s:a href="%{#url}">Hangman (AJAX and Non AJAX) Example</s:a>
+ <!-- Tiles Example -->
+ <li><s:url id="url" action="index" namespace="/tiles"/><s:a href="%{#url}">Tiles Example</s:a>
+
</ul>
</p>
Added: struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/body.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/body.jsp?view=auto&rev=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/body.jsp (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/body.jsp Thu Nov 9 15:29:48 2006
@@ -0,0 +1,3 @@
+<div>
+ This content was generated by <code>/tiles/body.jsp</code>
+</div>
\ No newline at end of file
Propchange: struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/body.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/body.jsp
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/header.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/header.jsp?view=auto&rev=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/header.jsp (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/header.jsp Thu Nov 9 15:29:48 2006
@@ -0,0 +1,3 @@
+<div class="header">
+ This content was generated by <code>/tiles/header.jsp</code>
+</div>
\ No newline at end of file
Propchange: struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/header.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/header.jsp
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/layout.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/layout.jsp?view=auto&rev=473138
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/layout.jsp (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/layout.jsp Thu Nov 9 15:29:48 2006
@@ -0,0 +1,35 @@
+<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
+<html>
+<head>
+ <title>Tiles Showcase</title>
+ <style type="text/css">
+ .header {
+ background-color: #006633;
+ color: white;
+ }
+
+ .body {
+ border: 1px solid black;
+ }
+ </style>
+</head>
+<body>
+<table>
+ <tr>
+ <td><strong>
+ <tiles:getAsString name="title"/>
+ </strong></td>
+ </tr>
+ <tr>
+ <td>
+ <tiles:attribute name="header"/>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <tiles:attribute name="body"/>
+ </td>
+ </tr>
+</table>
+</body>
+</html>
Propchange: struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/layout.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/struts2/trunk/apps/showcase/src/main/webapp/tiles/layout.jsp
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Modified: struts/struts2/trunk/plugins/tiles/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/tiles/pom.xml?view=diff&rev=473138&r1=473137&r2=473138
==============================================================================
--- struts/struts2/trunk/plugins/tiles/pom.xml (original)
+++ struts/struts2/trunk/plugins/tiles/pom.xml Thu Nov 9 15:29:48 2006
@@ -22,7 +22,7 @@
<dependency>
<groupId>org.apache.struts.tiles</groupId>
<artifactId>tiles-core</artifactId>
- <version>2.0-r468346-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Added: struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java?view=auto&rev=473138
==============================================================================
--- struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java (added)
+++ struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java Thu Nov 9 15:29:48 2006
@@ -0,0 +1,106 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.tiles;
+
+import org.apache.tiles.TilesApplicationContext;
+import org.apache.tiles.TilesException;
+import org.apache.tiles.context.TilesContextFactory;
+import org.apache.tiles.context.TilesRequestContext;
+import org.apache.tiles.definition.DefinitionsFactory;
+import org.apache.tiles.factory.TilesContainerFactory;
+import org.apache.tiles.impl.BasicTilesContainer;
+import org.apache.tiles.preparer.PreparerFactory;
+
+import javax.servlet.jsp.PageContext;
+import java.util.Map;
+
+
+public class StrutsTilesContainerFactory extends TilesContainerFactory {
+
+ /**
+ * Initialize the container in a struts specific manner.
+ *
+ * @param context
+ * @param container
+ * @throws TilesException
+ */
+ public void initializeContainer(Object context,
+ BasicTilesContainer container)
+ throws TilesException {
+
+ TilesContextFactory contextFactory = (TilesContextFactory)
+ TilesContainerFactory.createFactory(
+ context, TilesContainerFactory.CONTEXT_FACTORY_INIT_PARAM);
+
+ contextFactory = new StrutsTilesContextFactory(contextFactory);
+
+ DefinitionsFactory defsFactory = (DefinitionsFactory)
+ TilesContainerFactory.createFactory(
+ context, TilesContainerFactory.DEFINITIONS_FACTORY_INIT_PARAM);
+
+ PreparerFactory prepFactory =
+ (PreparerFactory) TilesContainerFactory.createFactory(
+ context, TilesContainerFactory.PREPARER_FACTORY_INIT_PARAM);
+
+ TilesApplicationContext tilesContext =
+ contextFactory.createApplicationContext(context);
+
+ container.setDefinitionsFactory(defsFactory);
+ container.setContextFactory(contextFactory);
+ container.setPreparerFactory(prepFactory);
+ container.setApplicationContext(tilesContext);
+
+ container.init(getInitParameterMap(context));
+
+ }
+
+ /**
+ * Wrapper factory, used to wrap the TilesRequestContext with a
+ * FreemarkerResult aware version.
+ *
+ */
+ class StrutsTilesContextFactory implements TilesContextFactory {
+
+ private TilesContextFactory factory;
+
+ public StrutsTilesContextFactory(TilesContextFactory factory) {
+ this.factory = factory;
+ }
+
+ public void init(Map map) {
+ factory.init(map);
+ }
+
+ public TilesApplicationContext createApplicationContext(Object context) {
+ return factory.createApplicationContext(context);
+ }
+
+ public TilesRequestContext createRequestContext(TilesApplicationContext tilesApplicationContext, Object request, Object response) {
+ TilesRequestContext context = factory.createRequestContext(tilesApplicationContext, request, response);
+ return new StrutsTilesRequestContext(context);
+ }
+
+ public TilesRequestContext createRequestContext(TilesApplicationContext tilesApplicationContext, PageContext pageContext) {
+ TilesRequestContext context = factory.createRequestContext(tilesApplicationContext, pageContext);
+ return new StrutsTilesRequestContext(context);
+ }
+ }
+}
Propchange: struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Copied: struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java (from r473024, struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesUtilImpl.java)
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java?view=diff&rev=473138&p1=struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesUtilImpl.java&r1=473024&p2=struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java&r2=473138
==============================================================================
--- struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesUtilImpl.java (original)
+++ struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesRequestContext.java Thu Nov 9 15:29:48 2006
@@ -20,11 +20,13 @@
*/
package org.apache.struts2.tiles;
-import org.apache.tiles.TilesUtilImpl;
+import org.apache.tiles.context.TilesRequestContext;
+import org.apache.tiles.context.TilesRequestContextWrapper;
import org.apache.struts2.views.freemarker.FreemarkerResult;
import org.apache.struts2.ServletActionContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
-import javax.servlet.jsp.PageContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@@ -45,7 +47,10 @@
* @version $Id$
*
*/
-public class StrutsTilesUtilImpl extends TilesUtilImpl {
+public class StrutsTilesRequestContext extends TilesRequestContextWrapper {
+
+ private static final Log LOG =
+ LogFactory.getLog(StrutsTilesRequestContext.class);
/**
* The mask used to detect requests which should be intercepted.
@@ -55,16 +60,20 @@
/**
* Default constructor.
* Sets the mask to '.ftl'
+ * @param context
*/
- public StrutsTilesUtilImpl() {
- mask = ".ftl";
+ public StrutsTilesRequestContext(TilesRequestContext context) {
+ this(context, ".ftl");
}
/**
* Optional constructor used to specify a specific mask.
* @param mask
+ * @param context
*/
- public StrutsTilesUtilImpl(String mask) {
+ public StrutsTilesRequestContext(TilesRequestContext context,
+ String mask) {
+ super(context);
this.mask = mask;
}
@@ -73,27 +82,28 @@
* templates to be intercepted so that the FreemarkerResult can
* be used in order to setup the appropriate model.
*
- * @param string the included resource
- * @param pageContext the current page context
- * @param b whether or not a flush should occur
* @throws IOException
* @throws ServletException
* @throws Exception
*/
- public void doInclude(String string, PageContext pageContext, boolean b) throws Exception {
- if(string.endsWith(".ftl")) {
- HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
- ActionInvocation invocation = ServletActionContext.getActionContext(request).getActionInvocation();
+ public void include(String include) throws Exception {
+ if(include.endsWith(mask)) {
+ HttpServletRequest request = (HttpServletRequest)getRequest();
+
+ ActionInvocation invocation =
+ ServletActionContext.getActionContext(request).getActionInvocation();
+
FreemarkerResult result = new FreemarkerResult();
+
try {
- result.doExecute(string, invocation);
+ result.doExecute(include, invocation);
} catch (TemplateException e) {
- log.error("Error invoking Freemarker template", e);
- throw new ServletException("Error invoking Freemarker template.", e);
+ LOG.error("Error invoking Freemarker template", e);
+ throw new Exception("Error invoking Freemarker template.", e);
}
}
else {
- super.doInclude(string, pageContext, b);
+ super.include(include);
}
}
}
Modified: struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java?view=diff&rev=473138&r1=473137&r2=473138
==============================================================================
--- struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java (original)
+++ struts/struts2/trunk/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java Thu Nov 9 15:29:48 2006
@@ -32,6 +32,7 @@
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.ServletDispatcherResult;
import org.apache.tiles.*;
+import org.apache.tiles.access.TilesAccess;
import org.apache.tiles.context.BasicTilesContextFactory;
import com.opensymphony.xwork2.ActionInvocation;
@@ -80,12 +81,7 @@
*/
public class TilesResult extends ServletDispatcherResult {
- private static final long serialVersionUID = -3806939435493086243L;
-
- private static final Log log = LogFactory.getLog(TilesResult.class);
-
- protected ActionInvocation invocation;
- private DefinitionsFactory definitionsFactory;
+ private static final long serialVersionUID = -3806939435493086244L;
public TilesResult() {
super();
@@ -105,128 +101,13 @@
*/
public void doExecute(String location, ActionInvocation invocation) throws Exception {
setLocation(location);
- this.invocation = invocation;
- HttpServletRequest request = ServletActionContext.getRequest();
- HttpServletResponse response = ServletActionContext.getResponse();
ServletContext servletContext = ServletActionContext.getServletContext();
- TilesRequestContext tilesContext =
- new BasicTilesContextFactory().createRequestContext(servletContext,
- request, response);
-
- this.definitionsFactory =
- (DefinitionsFactory) servletContext.getAttribute(TilesUtilImpl.DEFINITIONS_FACTORY);
-
- // get component definition
- ComponentDefinition definition = getComponentDefinition(location, this.definitionsFactory, request);
- if (definition == null) {
- throw new ServletException("No Tiles definition found for name '" + location + "'");
- }
-
- // get current component context
- ComponentContext context = getComponentContext(definition, tilesContext);
- ComponentContext.setContext(context, tilesContext);
-
- // execute component controller associated with definition, if any
- ViewPreparer controller = getController(definition, request);
- if (controller != null) {
- if (log.isDebugEnabled()) {
- log.debug("Executing Tiles controller [" + controller + "]");
- }
- executeController(controller, context, tilesContext);
- }
-
- // determine the path of the definition
- String path = getDispatcherPath(definition, request);
- if (path == null) {
- throw new ServletException(
- "Could not determine a path for Tiles definition '" + definition.getName() + "'");
- }
-
- super.doExecute(path, invocation);
- }
-
- protected Locale deduceLocale(HttpServletRequest request) {
- if (invocation.getAction() instanceof LocaleProvider) {
- return ((LocaleProvider) invocation.getAction()).getLocale();
- } else {
- return request.getLocale();
- }
- }
+ TilesContainer container = TilesAccess.getContainer(servletContext);
- /**
- * Determine the Tiles component definition for the given Tiles
- * definitions factory.
- *
- * @param factory the Tiles definitions factory
- * @param request current HTTP request
- * @return the component definition
- */
- protected ComponentDefinition getComponentDefinition(String location, DefinitionsFactory factory, HttpServletRequest request)
- throws Exception {
- ComponentDefinitions definitions = factory.readDefinitions();
- return definitions.getDefinition(location, deduceLocale(request));
- }
-
- /**
- * Determine the Tiles component context for the given Tiles definition.
- *
- * @param definition the Tiles definition to render
- * @param tilesContext current TilesContext
- * @return the component context
- * @throws Exception if preparations failed
- */
- protected ComponentContext getComponentContext(ComponentDefinition definition, TilesRequestContext tilesContext)
- throws Exception {
- ComponentContext context = ComponentContext.getContext(tilesContext);
- if (context == null) {
- context = new ComponentContext(definition.getAttributes());
- ComponentContext.setContext(context, tilesContext);
- } else {
- context.addMissing(definition.getAttributes());
- }
- return context;
- }
-
- /**
- * Determine and initialize the Tiles component controller for the
- * given Tiles definition, if any.
- *
- * @param definition the Tiles definition to render
- * @param request current HTTP request
- * @return the component controller to execute, or <code>null</code> if none
- * @throws Exception if preparations failed
- */
- protected ViewPreparer getController(ComponentDefinition definition, HttpServletRequest request)
- throws Exception {
- return definition.getOrCreatePreparer();
- }
-
- /**
- * Execute the given Tiles controller.
- *
- * @param controller the component controller to execute
- * @param context the component context
- * @param tilesContext current tilesContext
- * @throws Exception if controller execution failed
- */
- protected void executeController(
- ViewPreparer controller, ComponentContext context, TilesRequestContext tilesContext)
- throws Exception {
- controller.execute(tilesContext, context);
- }
+ HttpServletRequest request = ServletActionContext.getRequest();
+ HttpServletResponse response = ServletActionContext.getResponse();
- /**
- * Determine the dispatcher path for the given Tiles definition,
- * i.e. the request dispatcher path of the layout page.
- * @param definition the Tiles definition to render
- * @param request current HTTP request
- * @return the path of the layout page to render
- * @throws Exception if preparations failed
- */
- protected String getDispatcherPath(ComponentDefinition definition, HttpServletRequest request)
- throws Exception {
- Object pathAttr = null;
- return (pathAttr != null ? pathAttr.toString() : definition.getPath());
+ container.render(request, response, location);
}
}