I have a (simple) question:
I want to use a definition with an inline content. This content contains jsf
tags. This doesn't work. If I use the value attribute of tiles:putAttribute
and insert the content of another file, everything works fine.
I've pasted the file with inline content (welcome.jsp) and with included
content (welcome2.jsp and body.jsp)
I'm getting the following stacktrace:
02.11.2007 18:31:57 org.apache.tiles.jsp.taglib.RenderTagSupport doCatch
SCHWERWIEGEND: Error during rendering
javax.servlet.jsp.JspException: java.lang.IllegalStateException: Component
[EMAIL PROTECTED] not expected type. Expected:
javax.faces.component.UIOutput. Perhaps you're missing a tag?
at
com.sun.faces.taglib.html_basic.OutputTextTag.doStartTag(OutputTextTag.java:
170)
at
org.apache.jsp.welcome_jsp._jspx_meth_h_005foutputText_005f0(welcome_jsp.jav
a:195)
at
org.apache.jsp.welcome_jsp._jspx_meth_tiles_005fputAttribute_005f0(welcome_j
sp.java:157)
at
org.apache.jsp.welcome_jsp._jspx_meth_tiles_005finsertDefinition_005f0(welco
me_jsp.java:108)
at org.apache.jsp.welcome_jsp._jspService(welcome_jsp.java:68)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
93)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.
java:654)
at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDis
patcher.java:445)
at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatch
er.java:379)
at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher
.java:292)
at
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:
415)
at
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandler
Impl.java:458)
at
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:12
6)
at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java
:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:584)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalStateException: Component
[EMAIL PROTECTED] not expected type. Expected:
javax.faces.component.UIOutput. Perhaps you're missing a tag?
at
com.sun.faces.taglib.html_basic.OutputTextTag.setProperties(OutputTextTag.ja
va:126)
at
javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassi
cTagBase.java:614)
at
javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTa
gBase.java:1136)
at
com.sun.faces.taglib.html_basic.OutputTextTag.doStartTag(OutputTextTag.java:
164)
... 35 more
My file welcome.jsp (which doesn'work):
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertDefinition name="default.definition" >
<tiles:putAttribute name="body">
<h:outputText value="hOutputText !!!!"></h:outputText>
<h1>test</h1>
<h5>H5</h5>
</tiles:putAttribute>
</tiles:insertDefinition>
My file welcome2.jsp (works)
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertDefinition name="default.definition" >
<tiles:putAttribute name="body" value="/body.jsp" />
</tiles:insertDefinition>
My file body.jsp (works)
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ page import="java.util.Date;" %>
<h:outputText value="hOutputText !!!!"></h:outputText>
<h1>testH1</h1>
<h5>H5</h5>
<%= new Date() %>
And my file layout.jsp
<%@ page session="false" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<f:view>
<html>
<head>
<f:subview id="htmlheader">
<tiles:insertAttribute name="htmlheader" flush="false"/>
</f:subview>
</head>
<body>
<h:panelGrid columns="1">
<f:facet name="header">
<f:subview id="header">
<tiles:insertAttribute name="header"
flush="false"/>
</f:subview>
</f:facet>
<f:subview id="body">
<tiles:insertAttribute name="body"
flush="false"/>
</f:subview>
<f:facet name="footer">
<f:subview id="footer">
<tiles:insertAttribute name="footer"
flush="false"/>
</f:subview>
</f:facet>
</h:panelGrid>
</body>
</html>
</f:view>
My file Tiles-defs.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="default.definition" template="/layout/layout.jsp">
<put-attribute name="htmlheader" value="/inc/htmlhead.jsp"/>
<put-attribute name="header" value="/inc/header.jsp"/>
<put-attribute name="body" value="/home2.jsp"/>
<put-attribute name="footer" value="/inc/footer.jsp"/>
</definition>
</tiles-definitions>
Of course someone knows the cause of this problem. It seems to be that the
inline content is modified by tiles2 ?!
Holger