tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Stefaniuk <daniel.stefan...@gmail.com>
Subject nesting tiles dynamically
Date Thu, 27 Jan 2011 12:00:33 GMT
I have a main layout where a content attribute is defined as an JSP file to
be included. Inside the content file I want to include a view that is
another JSP file. However an exact view file to be included is defined by a
controller.

Controller:

TilesContainer tc = ServletUtil.getCurrentContainer(request,
request.getSession().getServletContext());
AttributeContext ac = tc.getAttributeContext(request, response);
ac.putAttribute("view", new Attribute("/WEB-INF/views/view.jsp"));

Tiles definition:

<definition name="layout" template="/WEB-INF/layouts/layout.jsp">
    <put-attribute name="content" value="/WEB-INF/layouts/content.jsp" />
</definition>

Layout:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<html>
<head>
</head>
<body>
    <tiles:insertAttribute name="content" />
</body>
</html>

Content:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<div>
    <tiles:insertAttribute name="view" />
</div>

by doing this I get an exception:

org.springframework.web.util.NestedServletException: Request processing
failed; nested exception is org.apache.tiles.impl.CannotRenderException:
ServletException including path '/WEB-INF/layouts/layout.jsp'.

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)

org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

There is no problem to get a view from inside the layout. It looks like
'view' attribute is not visible in the content file. Is there a way to solve
it? I do not want to use <jsp:include>.

How can I nest tiles dynamically?

Thanks

Daniel

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message