Author: apetrelli
Date: Wed Oct  4 04:40:27 2006
New Revision: 452855

URL: http://svn.apache.org/viewvc?view=rev&rev=452855
Log:
SB-50

Added proof-of-concept to show how to replace controllerClass and controllerUrl 
attributes in <tiles:insert>

Added:
    
struts/sandbox/trunk/tiles/tiles-test/src/main/java/org/apache/tiles/test/servlet/IncludingServlet.java
    struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testput_servlet.jsp
Modified:
    struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/web.xml
    struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp

Added: 
struts/sandbox/trunk/tiles/tiles-test/src/main/java/org/apache/tiles/test/servlet/IncludingServlet.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/java/org/apache/tiles/test/servlet/IncludingServlet.java?view=auto&rev=452855
==============================================================================
--- 
struts/sandbox/trunk/tiles/tiles-test/src/main/java/org/apache/tiles/test/servlet/IncludingServlet.java
 (added)
+++ 
struts/sandbox/trunk/tiles/tiles-test/src/main/java/org/apache/tiles/test/servlet/IncludingServlet.java
 Wed Oct  4 04:40:27 2006
@@ -0,0 +1,55 @@
+/*

+ * $Id: ComponentDefinitions.java 307013 2005-10-07 04:49:50Z wsmoak $

+ *

+ * Copyright 1999-2006 The Apache Software Foundation.

+ * 

+ * Licensed 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.tiles.test.servlet;

+

+import java.io.IOException;

+

+import javax.servlet.ServletConfig;

+import javax.servlet.ServletException;

+import javax.servlet.http.HttpServlet;

+import javax.servlet.http.HttpServletRequest;

+import javax.servlet.http.HttpServletResponse;

+

+/**

+ * Sample servlet that includes a page specified by the <code>include</code>

+ * init parameter.

+ * 

+ * @version $Rev: 307013 $ $Date: 2005-10-07 06:49:50 +0200 (ven, 07 ott 2005) 
$ 

+ */

+public class IncludingServlet extends HttpServlet {

+

+    private String include;

+

+    /**

+     * Initializes the servlet, reading the <code>include</code> init parameter

+     */

+    public void init(ServletConfig config) throws ServletException {

+        super.init(config);

+

+        include = config.getInitParameter("include");

+    }

+

+    /**

+     * Processes the request, including the specified page.

+     */

+    protected void doGet(HttpServletRequest request,

+            HttpServletResponse response) throws ServletException, IOException 
{

+        request.getRequestDispatcher(include).include(request, response);

+    }

+}


Modified: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/web.xml?view=diff&rev=452855&r1=452854&r2=452855
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/web.xml 
(original)
+++ struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/web.xml Wed 
Oct  4 04:40:27 2006
@@ -17,9 +17,24 @@
     </init-param>
     <load-on-startup>2</load-on-startup>
  </servlet>
+  
+  <!-- Standard Action Servlet Configuration -->
+  <servlet>
+    <servlet-name>layoutServlet</servlet-name>
+    
<servlet-class>org.apache.tiles.test.servlet.IncludingServlet</servlet-class>
+    <init-param>
+      <param-name>include</param-name>
+      <param-value>/layout.jsp</param-value>
+    </init-param>
+ </servlet>
 
   <welcome-file-list>
     <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
+  
+  <servlet-mapping>
+    <servlet-name>layoutServlet</servlet-name>
+    <url-pattern>/servlets/layoutServlet</url-pattern>
+  </servlet-mapping>
 
 </web-app>

Modified: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp?view=diff&rev=452855&r1=452854&r2=452855
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp (original)
+++ struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp Wed Oct  4 
04:40:27 2006
@@ -36,6 +36,7 @@
     <a href="testinsertdefinition_composite_tags.jsp">Test Insert Definition 
that contains another definition inside using JSP tags</a><br/>
     <a href="testinsertdefinition_composite_tags_notype.jsp">Test Insert 
Definition that contains another definition inside using JSP tags without 
types</a><br/>
     <a href="testput.jsp">Test Put Tag</a><br/>
+    <a href="testput_servlet.jsp">Test Put Tag using a servlet mapping as a 
template</a><br/>
     <a href="testimportattribute.jsp">Test importAttribute Tag</a><br/>
     
     <h2>Currently not working tests</h2>

Added: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testput_servlet.jsp
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testput_servlet.jsp?view=auto&rev=452855
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testput_servlet.jsp 
(added)
+++ struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testput_servlet.jsp 
Wed Oct  4 04:40:27 2006
@@ -0,0 +1,7 @@
+<%@ taglib uri="http://struts.apache.org/tags-tiles"; prefix="tiles" %>

+

+<tiles:insert template="/servlets/layoutServlet">

+  <tiles:put name="title"  value="This is the title." />

+  <tiles:put name="header" value="/header.jsp" />

+  <tiles:put name="body"   value="/body.jsp" />

+</tiles:insert>
\ No newline at end of file


Reply via email to