myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Connolly <stephen.alan.conno...@gmail.com>
Subject [SOLVED] Re: JSF2 f:metadata and templates what the feck am I doing wrong?
Date Fri, 29 Apr 2011 09:10:12 GMT
Ok, I just found the/a solution.

that was to remove

  <context-param>
    <param-name>com.sun.faces.validateXml</param-name>
    <param-value>true</param-value>
  </context-param>

from the web.xml

For some reason this completely ruins the f:metadata tag

Not sure if that is a bug or a "feature" but might as well post the solution
anyway so that others might benefit

-Stephen

On 29 April 2011 10:08, Stephen Connolly <stephen.alan.connolly@gmail.com>wrote:

> Myfaces 2.0.5.
>
> I have been reading the JSF docs on the f:metadata tag..., e.g.
> http://javaserverfaces.java.net/nonav/docs/2.0/vdldocs/facelets/f/metadata.htmland
> http://myfaces.apache.org/core20/myfaces-impl/tlddoc-facelets/index.html
>
> I cannot seem to get f:metadata to work, e.g.
>
> */WEB-INF/templates/basic.xhtml*
>
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
>      xmlns:ui="http://java.sun.com/jsf/facelets"
>      xmlns:h="http://java.sun.com/jsf/html"
>      xmlns:f="http://java.sun.com/jsf/core"
>        >
> <h:head>
>    <ui:insert name="header"/>
> </h:head>
> <h:body>
>    <f:view>
>        <ui:insert name="metadata"/>
>        <ui:insert name="content"/>
>    </f:view>
> </h:body>
> </html>
>
>
> and then reference that template
>
> */test.xhtml*
> <?xml version="1.0" encoding="utf-8"?>
> <ui:composition xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:ui="http://java.sun.com/jsf/facelets"
>      xmlns:h="http://java.sun.com/jsf/html"
>       xmlns:f="http://java.sun.com/jsf/core"
>      template="/WEB-INF/templates/basic.xhtml">
>    <ui:define name="metadata">
>       <f:metadata>
>        <f:viewParam name="id"/>
>      </f:metadata>
>    </ui:define>
>    <ui:define name="content">
>        <h1>The big news stories of the day</h1>
>    </ui:define>
> </ui:composition>
>
>
> whenever i try to access the test.xhtml view I get the following:
>
> *[In Jetty 8.0.0.M2]
> *
>
> HTTP ERROR 500
>
> Problem accessing /test.xhtml. Reason:
>
>    /test.xhtml at line 8 and column 19 <f:metadata> Parent UIComponent
> j_id1187866547_41aebe2a should be instance of UIViewRoot
> Caused by:
>
> javax.faces.view.facelets.TagException: /test.xhtml at line 8 and column 19
> <f:metadata> Parent UIComponent j_id1187866547_41aebe2a should be instance
> of UIViewRoot
>  at
> org.apache.myfaces.view.facelets.tag.jsf.core.ViewMetadataHandler.apply(ViewMetadataHandler.java:61)
> at
> org.apache.myfaces.view.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:86)
>  at
> org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:167)
> at
> org.apache.myfaces.view.facelets.impl.TemplateContextImpl$TemplateManagerImpl.apply(TemplateContextImpl.java:128)
>  at
> org.apache.myfaces.view.facelets.impl.TemplateContextImpl.includeDefinition(TemplateContextImpl.java:92)
> at
> org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:433)
>  at
> org.apache.myfaces.view.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:93)
> at
> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
>  at
> org.apache.myfaces.view.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:156)
> at
> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:59)
>  at
> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:324)
> at
> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:54)
>  at
> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
> at
> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:57)
>  at
> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
> at
> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:45)
>  at
> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:322)
> at
> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:369)
>  at
> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:347)
> at
> org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:215)
>  at
> org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:140)
> at
> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:57)
>  at
> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:45)
> at
> org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:143)
>  at
> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:327)
> at
> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:66)
>  at
> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
>  at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:546)
> at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:483)
>  at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
> at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:516)
>  at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:230)
> at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:956)
>  at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:411)
> at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:188)
>  at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:891)
> at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
>  at
> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:247)
> at
> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:151)
>  at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:114)
> at org.eclipse.jetty.server.Server.handle(Server.java:353)
>  at
> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:598)
> at
> org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1059)
>  at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:590)
> at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:212)
>  at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:427)
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:510)
>  at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.access$000(SelectChannelEndPoint.java:34)
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
>  at
> org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:450)
> at java.lang.Thread.run(Thread.java:680)
>
>
> [In Tomcat 7.0.12]
>
> HTTP Status 500 -
>
> type Exception report
>
> message
>
> description The server encountered an internal error () that prevented it
> from fulfilling this request.
>
> exception
>
> javax.servlet.ServletException: /test.xhtml at line 8 and column 19
> <f:metadata> Parent UIComponent j_id1187866547_41aebe2a should be instance
> of UIViewRoot
>  javax.faces.webapp.FacesServlet.service(FacesServlet.java:205)
> root cause
>
> javax.faces.view.facelets.TagException: /test.xhtml at line 8 and column 19
> <f:metadata> Parent UIComponent j_id1187866547_41aebe2a should be instance
> of UIViewRoot
> org.apache.myfaces.view.facelets.tag.jsf.core.ViewMetadataHandler.apply(ViewMetadataHandler.java:61)
>
> org.apache.myfaces.view.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:86)
> org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:167)
>
> org.apache.myfaces.view.facelets.impl.TemplateContextImpl$TemplateManagerImpl.apply(TemplateContextImpl.java:128)
> org.apache.myfaces.view.facelets.impl.TemplateContextImpl.includeDefinition(TemplateContextImpl.java:92)
>
> org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:433)
> org.apache.myfaces.view.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:93)
>
> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
> org.apache.myfaces.view.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:156)
>
> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:59)
> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:324)
>
> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:54)
> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
>
> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:57)
> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
>
> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:45)
> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:322)
>
> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:369)
> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:347)
>
> org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:215)
> org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:140)
>
> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:57)
> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:45)
>
> org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:143)
> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:327)
>
> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:66)
>  org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
> javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
> note The full stack trace of the root cause is available in the Apache
> Tomcat/7.0.12 logs.
>
> Apache Tomcat/7.0.12
>
>
> Which says it's not the container...
>
> If I try direct with no template, e.g.
>
> test2.xhtml
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:ui="http://java.sun.com/jsf/facelets"
>       xmlns:h="http://java.sun.com/jsf/html"
>       xmlns:f="http://java.sun.com/jsf/core"
>         >
> <h:head>
>     <ui:insert name="header"/>
> </h:head>
> <h:body>
>     <f:view>
>         <f:metadata>
>           <f:viewParam name="id"/>
>         </f:metadata>
>         <h1>The big news stories of the day</h1>
>     </f:view>
> </h:body>
> </html>
>
> Then I get:
>
> javax.servlet.ServletException: /test2.xhtml at line 14 and column 21 <f:metadata>
Parent UIComponent j_id1723811066_66bf44b9 should be instance of UIViewRoot
> 	javax.faces.webapp.FacesServlet.service(FacesServlet.java:205)
>
>
> Which tells me I must be reading
> http://javaserverfaces.java.net/nonav/docs/2.0/vdldocs/facelets/f/metadata.htmlseriously
wrong
>
> Oh, before I forget, here is my web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
>   <context-param>
>     <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
>     <param-value>server</param-value>
>   </context-param>
>   <context-param>
>     <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
>     <param-value>.xhtml</param-value>
>   </context-param>
>   <context-param>
>     <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
>     <param-value>true</param-value>
>   </context-param>
>   <context-param>
>     <param-name>javax.faces.PROJECT_STAGE</param-name>
>     <!--<param-value>Production</param-value>-->
>     <param-value>Development</param-value>
>   </context-param>
>   <context-param>
>     <param-name>com.sun.faces.validateXml</param-name>
>     <param-value>true</param-value>
>   </context-param>
>   <listener>
>
> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
>   </listener>
>
>   <servlet>
>     <servlet-name>Faces Servlet</servlet-name>
>     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
>     <load-on-startup>1</load-on-startup>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>Faces Servlet</servlet-name>
>     <url-pattern>*.xhtml</url-pattern>
>   </servlet-mapping>
>
>   <session-config>
>     <session-timeout>60</session-timeout>
>   </session-config>
> </web-app>
>
> Any and all help appreciated
>
> -Stephen
>

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