You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2007/12/04 02:15:25 UTC

svn commit: r600759 - in /myfaces/tomahawk/trunk: core/ core/src/main/java/org/apache/myfaces/tomahawk/application/jsp/ examples/tiles/ examples/tiles/src/main/webapp/WEB-INF/ examples/tiles/src/main/webapp/template/

Author: mmarinschek
Date: Mon Dec  3 17:15:24 2007
New Revision: 600759

URL: http://svn.apache.org/viewvc?rev=600759&view=rev
Log:
fix for https://issues.apache.org/jira/browse/TOMAHAWK-1160 (TOMAHAWK-1160): enable tiles-2 support in MyFaces

Added:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/application/jsp/JspTilesTwoViewHandlerImpl.java
Modified:
    myfaces/tomahawk/trunk/core/pom.xml
    myfaces/tomahawk/trunk/examples/tiles/pom.xml
    myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/WEB-INF/tiles.xml
    myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template.jsp
    myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template2.jsp

Modified: myfaces/tomahawk/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/pom.xml?rev=600759&r1=600758&r2=600759&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/pom.xml (original)
+++ myfaces/tomahawk/trunk/core/pom.xml Mon Dec  3 17:15:24 2007
@@ -60,6 +60,14 @@
     </dependency>
 
     <dependency>
+        <groupId>org.apache.tiles</groupId>
+        <artifactId>tiles-core</artifactId>
+        <version>2.0.5</version>
+        <scope>compile</scope>
+        <optional>true</optional>        
+    </dependency>
+
+    <dependency>
       <groupId>commons-el</groupId>
       <artifactId>commons-el</artifactId>
       <version>1.0</version>

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/application/jsp/JspTilesTwoViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/application/jsp/JspTilesTwoViewHandlerImpl.java?rev=600759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/application/jsp/JspTilesTwoViewHandlerImpl.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/tomahawk/application/jsp/JspTilesTwoViewHandlerImpl.java Mon Dec  3 17:15:24 2007
@@ -0,0 +1,271 @@
+package org.apache.myfaces.tomahawk.application.jsp;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.factory.TilesContainerFactory;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.TilesException;
+import org.apache.myfaces.shared_tomahawk.webapp.webxml.ServletMapping;
+import org.apache.myfaces.shared_tomahawk.webapp.webxml.WebXml;
+
+import javax.faces.application.ViewHandler;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.FacesException;
+import javax.faces.component.UIViewRoot;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.ServletResponse;
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author Martin Marinschek
+ * @version $Revision: 472792 $ $Date: 2006-11-09 07:34:47 +0100 (Do, 09 Nov 2006) $
+ */
+public class JspTilesTwoViewHandlerImpl
+        extends ViewHandler {
+    private ViewHandler _viewHandler;
+
+    private static final Log log = LogFactory.getLog(JspTilesTwoViewHandlerImpl.class);
+    private static final String TILES_DEF_EXT = ".tiles";
+
+    private String tilesExtension = TILES_DEF_EXT;
+
+    public JspTilesTwoViewHandlerImpl(ViewHandler viewHandler)
+    {
+        _viewHandler = viewHandler;
+    }
+
+    private void initContainer(ExternalContext context) {
+
+        if(TilesAccess.getContainer(context.getContext())==null) {
+            try
+            {
+                TilesContainerFactory factory = TilesContainerFactory.getFactory(context.getContext());
+                TilesContainer container = factory.createTilesContainer(context.getContext());
+                TilesAccess.setContainer(context.getContext(),container);
+            }
+            catch (Exception e)
+            {
+                throw new FacesException("Error reading tiles definitions : " + e.getMessage(), e);
+            }
+        }
+    }
+
+    public void renderView(FacesContext facesContext, UIViewRoot viewToRender) throws IOException, FacesException
+    {
+        if (viewToRender == null)
+        {
+            log.fatal("viewToRender must not be null");
+            throw new NullPointerException("viewToRender must not be null");
+        }
+
+        ExternalContext externalContext = facesContext.getExternalContext();
+
+        String viewId = deriveViewId(externalContext, viewToRender.getViewId());
+
+        if(viewId==null) {
+            //deriving view-id made clear we are not responsible for this view-id - call the delegate
+            _viewHandler.renderView(facesContext, viewToRender);
+            return;
+        }
+
+
+        initContainer(externalContext);
+
+        String tilesId = deriveTileFromViewId(viewId);
+
+        TilesContainer container = TilesAccess.getContainer(externalContext.getContext());
+
+        Object[] requestObjects = {externalContext.getRequest(), externalContext.getResponse()};
+
+        if(container.isValidDefinition(tilesId, requestObjects)) {
+
+            //propagate our new view-id to wherever it makes sense
+            setViewId(viewToRender, viewId, facesContext);
+
+            handleCharacterEncoding(viewId, externalContext, viewToRender);
+
+            container.startContext(requestObjects);
+            try {
+                container.render(tilesId,requestObjects);
+            } catch (TilesException e) {
+                throw new FacesException(e);
+            }
+            finally {
+                container.endContext(requestObjects);
+            }
+
+            handleCharacterEncodingPostDispatch(externalContext);
+        }
+        else {
+            //we're not using tiles as no valid definition has been found
+            //just call the delegate view-handler to let it do its thing
+            _viewHandler.renderView(facesContext, viewToRender);
+        }
+    }
+
+    private void setViewId(UIViewRoot viewToRender, String viewId, FacesContext facesContext) {
+        viewToRender.setViewId(viewId);
+        if(facesContext.getViewRoot()!=null) {
+            facesContext.getViewRoot().setViewId(viewId);
+        }
+    }
+
+    private String deriveTileFromViewId(String viewId) {
+        String tilesId = viewId;
+        int idx = tilesId.lastIndexOf('.');
+        if (idx > 0)
+        {
+            tilesId = tilesId.substring(0, idx) + tilesExtension;
+        }
+        else
+        {
+            tilesId = tilesId  + tilesExtension;
+        }
+        return tilesId;
+    }
+
+    private String deriveViewId(ExternalContext externalContext, String viewId) {
+        ServletMapping servletMapping = getServletMapping(externalContext);
+
+        String defaultSuffix = externalContext.getInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME);
+        String suffix = defaultSuffix != null ? defaultSuffix : ViewHandler.DEFAULT_SUFFIX;
+        if (servletMapping.isExtensionMapping())
+        {
+            if (!viewId.endsWith(suffix))
+            {
+                int dot = viewId.lastIndexOf('.');
+                if (dot == -1)
+                {
+                    if (log.isTraceEnabled()) log.trace("Current viewId has no extension, appending default suffix " + suffix);
+                    return viewId + suffix;
+                }
+                else
+                {
+                    if (log.isTraceEnabled()) log.trace("Replacing extension of current viewId by suffix " + suffix);
+                    return viewId.substring(0, dot) + suffix;
+                }
+            }
+
+            //extension-mapped page ends with proper suffix - all ok
+            return viewId;
+        }
+        else if (!viewId.endsWith(suffix))
+        {
+            // path-mapping used, but suffix is no default-suffix
+            return null;
+        }
+        else {
+            //path-mapping used, suffix is default-suffix - all ok
+            return viewId;
+        }
+    }
+
+    private void handleCharacterEncodingPostDispatch(ExternalContext externalContext) {
+        // handle character encoding as of section 2.5.2.2 of JSF 1.1
+        if (externalContext.getRequest() instanceof HttpServletRequest) {
+            HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
+            HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
+            HttpSession session = request.getSession(false);
+
+            if (session != null) {
+                session.setAttribute(ViewHandler.CHARACTER_ENCODING_KEY, response.getCharacterEncoding());
+            }
+        }
+    }
+
+    private void handleCharacterEncoding(String viewId, ExternalContext externalContext, UIViewRoot viewToRender) {
+        if (log.isTraceEnabled()) log.trace("Dispatching to " + viewId);
+
+        // handle character encoding as of section 2.5.2.2 of JSF 1.1
+        if (externalContext.getResponse() instanceof ServletResponse) {
+            ServletResponse response = (ServletResponse) externalContext.getResponse();
+            response.setLocale(viewToRender.getLocale());
+        }
+    }
+
+    private static ServletMapping getServletMapping(ExternalContext externalContext)
+    {
+        String servletPath = externalContext.getRequestServletPath();
+        String requestPathInfo = externalContext.getRequestPathInfo();
+
+        WebXml webxml = WebXml.getWebXml(externalContext);
+        List mappings = webxml.getFacesServletMappings();
+
+        boolean isExtensionMapping = requestPathInfo == null;
+
+        for (int i = 0, size = mappings.size(); i < size; i++)
+        {
+            ServletMapping servletMapping = (ServletMapping) mappings.get(i);
+            if (servletMapping.isExtensionMapping() == isExtensionMapping)
+            {
+                String urlpattern = servletMapping.getUrlPattern();
+                if (isExtensionMapping)
+                {
+                    String extension = urlpattern.substring(1, urlpattern.length());
+                    if (servletPath.endsWith(extension))
+                    {
+                        return servletMapping;
+                    }
+                }
+                else
+                {
+                    urlpattern = urlpattern.substring(0, urlpattern.length() - 2);
+                    // servletPath starts with "/" except in the case where the
+                    // request is matched with the "/*" pattern, in which case
+                    // it is the empty string (see Servlet Sepc 2.3 SRV4.4)
+                    if (servletPath.equals(urlpattern))
+                    {
+                        return servletMapping;
+                    }
+                }
+            }
+        }
+        log.error("could not find pathMapping for servletPath = " + servletPath +
+                  " requestPathInfo = " + requestPathInfo);
+        throw new IllegalArgumentException("could not find pathMapping for servletPath = " + servletPath +
+                  " requestPathInfo = " + requestPathInfo);
+    }
+
+
+    public Locale calculateLocale(FacesContext context)
+    {
+        return _viewHandler.calculateLocale(context);
+    }
+
+    public String calculateRenderKitId(FacesContext context)
+    {
+        return _viewHandler.calculateRenderKitId(context);
+    }
+
+    public UIViewRoot createView(FacesContext context, String viewId)
+    {
+        return _viewHandler.createView(context, viewId);
+    }
+
+    public String getActionURL(FacesContext context, String viewId)
+    {
+        return _viewHandler.getActionURL(context, viewId);
+    }
+
+    public String getResourceURL(FacesContext context, String path)
+    {
+        return _viewHandler.getResourceURL(context, path);
+    }
+
+    public UIViewRoot restoreView(FacesContext context, String viewId)
+    {
+        return _viewHandler.restoreView(context, viewId);
+    }
+
+    public void writeState(FacesContext context) throws IOException
+    {
+        _viewHandler.writeState(context);
+    }
+
+}

Modified: myfaces/tomahawk/trunk/examples/tiles/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/tiles/pom.xml?rev=600759&r1=600758&r2=600759&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/tiles/pom.xml (original)
+++ myfaces/tomahawk/trunk/examples/tiles/pom.xml Mon Dec  3 17:15:24 2007
@@ -55,18 +55,28 @@
     </profiles>
     
     <dependencies>
-        <dependency>
+        <!--dependency>
             <groupId>struts</groupId>
             <artifactId>struts</artifactId>
             <version>1.2.8</version>
             <scope>compile</scope>
-            <!--exclusions>
-            <exclusion>
-            <groupId>xalan</groupId>
-            <artifactId>xalan</artifactId>
-            </exclusion>
-            </exclusions-->
+            <exclusions>
+                <exclusion>
+                    <groupId>xalan</groupId>
+                    <artifactId>xalan</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency-->
+        <dependency>
+            <groupId>org.apache.tiles</groupId>
+            <artifactId>tiles-core</artifactId>
+            <version>2.0.5</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.tiles</groupId>
+            <artifactId>tiles-jsp</artifactId>
+            <version>2.0.5</version>
+        </dependency>        
     </dependencies>
   
 </project>

Modified: myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/WEB-INF/tiles.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/WEB-INF/tiles.xml?rev=600759&r1=600758&r2=600759&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/WEB-INF/tiles.xml (original)
+++ myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/WEB-INF/tiles.xml Mon Dec  3 17:15:24 2007
@@ -1,73 +1,91 @@
+
 <!DOCTYPE tiles-definitions
     [
-        <!ELEMENT component-definitions (definition+)>
-        <!ELEMENT tiles-definitions (definition+)>
-        <!ELEMENT definition (put*, putList*)>
-        <!ATTLIST definition
-            name CDATA #REQUIRED
-            page CDATA #IMPLIED
-            path CDATA #IMPLIED
-            extends CDATA #IMPLIED
-            role CDATA #IMPLIED
-            template CDATA #IMPLIED
-            controllerClass CDATA #IMPLIED
-            controllerUrl CDATA #IMPLIED>
-        <!ELEMENT put (#PCDATA)>
-        <!ATTLIST put
-            name CDATA #REQUIRED
-            value CDATA #IMPLIED
-            type (string | page | template | definition) #IMPLIED
-            content CDATA #IMPLIED
-            direct (true | false) #IMPLIED>
-        <!ELEMENT putList ( (add* | item* | bean* | putList*)+) >
-        <!ATTLIST putList
-            name CDATA #REQUIRED>
-        <!ELEMENT putListElements (add | item | bean)>
-        <!ELEMENT add (#PCDATA)>
-        <!ATTLIST add
-            value CDATA #IMPLIED
-            type (string | page | template | definition) #IMPLIED
-            content CDATA #IMPLIED
-            direct (true | false) #IMPLIED>
-        <!ELEMENT bean (#PCDATA)>
-        <!ATTLIST bean
-            classtype CDATA #REQUIRED>
-        <!ELEMENT item (#PCDATA)>
-        <!ATTLIST item
-            value CDATA #REQUIRED
-            link CDATA #REQUIRED
-            classtype CDATA #IMPLIED
-            icon CDATA #IMPLIED
-            tooltip CDATA #IMPLIED>
+            <!ENTITY % Boolean "(true|false)">
+            <!ENTITY % ContentType "(string|template|definition|object)">
+            <!ENTITY % ClassName "CDATA">
+            <!ENTITY % RequestPath "CDATA">
+            <!ENTITY % DefinitionName "CDATA">
+            <!ENTITY % BeanName "CDATA">
+            <!ENTITY % PropName "CDATA">
+            <!ENTITY % Location "#PCDATA">
+            <!ELEMENT tiles-definitions (definition+)>
+            <!ELEMENT definition (icon?, display-name?, description?, put-attribute*, put-list-attribute*)>
+            <!ATTLIST definition       id               ID               #IMPLIED>
+            <!ATTLIST definition       preparer         CDATA      #IMPLIED>
+            <!ATTLIST definition       extends          CDATA #IMPLIED>
+            <!ATTLIST definition       name             CDATA #REQUIRED>
+            <!ATTLIST definition       role             CDATA            #IMPLIED>
+            <!ATTLIST definition       template         CDATA    #IMPLIED>
+            <!ELEMENT put-attribute (#PCDATA)>
+            <!ATTLIST put-attribute     id               ID              #IMPLIED>
+            <!ATTLIST put-attribute     name             CDATA           #REQUIRED>
+            <!ATTLIST put-attribute     type             (string|template|definition|object)   #IMPLIED>
+            <!ATTLIST put-attribute     value            CDATA           #IMPLIED>
+            <!ATTLIST put-attribute     role             CDATA            #IMPLIED>
+            <!ELEMENT put-list-attribute ( (add-attribute* | item* | bean* | add-list-attribute*)+) >
+            <!ATTLIST put-list-attribute id               ID              #IMPLIED>
+            <!ATTLIST put-list-attribute name             CDATA           #REQUIRED>
+            <!ATTLIST put-list-attribute role             CDATA            #IMPLIED>
+            <!ELEMENT add-attribute (#PCDATA)>
+            <!ATTLIST add-attribute              id               ID              #IMPLIED>
+            <!ATTLIST add-attribute              type             (string|template|definition|object)   #IMPLIED>
+            <!ATTLIST add-attribute              value            CDATA           #IMPLIED>
+            <!ATTLIST add-attribute              role             CDATA            #IMPLIED>
+            <!ELEMENT add-list-attribute ( (add-attribute* | item* | bean* | add-list-attribute*)+) >
+            <!ATTLIST add-list-attribute id               ID              #IMPLIED>
+            <!ATTLIST add-list-attribute role             CDATA            #IMPLIED>
+            <!ELEMENT bean (set-property*)>
+            <!ATTLIST bean             id               ID              #IMPLIED>
+            <!ATTLIST bean             classtype        CDATA     #REQUIRED>
+            <!ELEMENT set-property   EMPTY>
+            <!ATTLIST set-property   id             ID              #IMPLIED>
+            <!ATTLIST set-property   property       CDATA      #REQUIRED>
+            <!ATTLIST set-property   value          CDATA           #REQUIRED>
+            <!ELEMENT item (#PCDATA)>
+            <!ATTLIST item             id               ID              #IMPLIED>
+            <!ATTLIST item             classtype        CDATA     #IMPLIED>
+            <!ATTLIST item             icon             CDATA           #IMPLIED>
+            <!ATTLIST item             link             CDATA           #REQUIRED>
+            <!ATTLIST item             tooltip          CDATA           #IMPLIED>
+            <!ATTLIST item             value            CDATA           #REQUIRED>
+            <!ELEMENT description    (#PCDATA)>
+            <!ATTLIST description    id             ID              #IMPLIED>
+            <!ELEMENT display-name (#PCDATA)>
+            <!ATTLIST display-name   id             ID              #IMPLIED>
+            <!ELEMENT icon           (small-icon?, large-icon?)>
+            <!ATTLIST icon           id             ID              #IMPLIED>
+            <!ELEMENT large-icon     (#PCDATA)>
+            <!ATTLIST large-icon     id             ID              #IMPLIED>
+            <!ELEMENT small-icon     (#PCDATA)>
+            <!ATTLIST small-icon     id             ID              #IMPLIED>
+
     ]>
 
 <tiles-definitions>
-    <definition name="layout.example" path="/template/template.jsp" >
-        <put name="header" value="/common/header.jsp" />
-        <put name="menu" value="/common/navigation.jsp" />
+    <definition name="layout.example" template="/template/template.jsp" >
+        <put-attribute name="header" value="/common/header.jsp" />
+        <put-attribute name="menu" value="/common/navigation.jsp" />
     </definition>
 
     <definition name="/page1.tiles" extends="layout.example" >
-        <put name="body" value="/page1.jsp" />
+        <put-attribute name="body" value="/page1.jsp" />
     </definition>
 
     <definition name="/page2.tiles" extends="layout.example" >
-        <put name="body" value="/page2.jsp" />
+        <put-attribute name="body" value="/page2.jsp" />
     </definition>
 
 <!-- workaround for non-tiles JSF pages-->
-    <definition name="non.tiles1" path="/non-tile.jsp" />	
+    <definition name="non.tiles1" template="/non-tile.jsp" />
 
 <!-- nested tiles definition -->
-    <definition name="nested.example" path="/template/template2.jsp" >
-        <put name="nested1" value="/common/nested1.jsp" />
-        <put name="nested2" value="/common/nested2.jsp" />
+    <definition name="nested.example" template="/template/template2.jsp" >
+        <put-attribute name="nested1" value="/common/nested1.jsp" />
+        <put-attribute name="nested2" value="/common/nested2.jsp" />
     </definition>
     <definition name="/page4.tiles" extends="layout.example" >
-        <put name="body" value="nested.example" />
+        <put-attribute name="body" value="nested.example" />
     </definition>
-
-
-
 
 </tiles-definitions>

Modified: myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template.jsp?rev=600759&r1=600758&r2=600759&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template.jsp (original)
+++ myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template.jsp Mon Dec  3 17:15:24 2007
@@ -1,8 +1,8 @@
 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
 <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
 <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
-<%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles"
- %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" 
+%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <head>
   <meta http-equiv="Content-Type" content="text/html;CHARSET=iso-8859-1" />
   <title>Myfaces - Tiles</title>
@@ -12,19 +12,19 @@
 <body>
   <div id="lftBar">
     <f:subview id="menu">
-      <tiles:insert attribute="menu" flush="false" />
+      <tiles:insertAttribute name="menu" flush="false" />
     </f:subview>
   </div>
   <div id="level0">
     <div id="level1">
        <div id="topBar">
           <f:subview id="header">
-            <tiles:insert attribute="header" flush="false"/>
+            <tiles:insertAttribute name="header" flush="false"/>
           </f:subview>
        </div>
        <div id="level2">
          <f:subview id="content">
-            <tiles:insert attribute="body" flush="false"/>
+            <tiles:insertAttribute name="body" flush="false"/>
          </f:subview>
       </div>
     </div>

Modified: myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template2.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template2.jsp?rev=600759&r1=600758&r2=600759&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template2.jsp (original)
+++ myfaces/tomahawk/trunk/examples/tiles/src/main/webapp/template/template2.jsp Mon Dec  3 17:15:24 2007
@@ -1,19 +1,19 @@
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
-<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
-<%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles"%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@
+        taglib prefix="f" uri="http://java.sun.com/jsf/core" %><%@
+        taglib prefix="h" uri="http://java.sun.com/jsf/html" %><%@
+        taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
 
 
 <table border="2">
 <tr>
 <td>
 <f:subview id="nested1">
-  <tiles:insert attribute="nested1" flush="false" />
+  <tiles:insertAttribute name="nested1" flush="false" />
 </f:subview>
 </td>
 <td>
 <f:subview id="nested2"> 
-  <tiles:insert attribute="nested2" flush="false"/>
+  <tiles:insertAttribute name="nested2" flush="false"/>
 </f:subview>
 </td>
 </tr>