Return-Path: X-Original-To: apmail-myfaces-users-archive@www.apache.org Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4313B258B for ; Fri, 29 Apr 2011 12:07:02 +0000 (UTC) Received: (qmail 14320 invoked by uid 500); 29 Apr 2011 12:07:01 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 14283 invoked by uid 500); 29 Apr 2011 12:07:01 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 14275 invoked by uid 99); 29 Apr 2011 12:07:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Apr 2011 12:07:01 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [80.86.184.202] (HELO s13.pixelx.de) (80.86.184.202) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Apr 2011 12:06:56 +0000 Received: from etech01 (chello212017079122.13.15.vie.surfer.at [212.17.79.122]) by s13.pixelx.de (s13.pixelx.de) with ESMTPA id D0FE8CF4287 for ; Fri, 29 Apr 2011 14:06:33 +0200 (CEST) From: "Ing. Thomas Kernstock" To: "'MyFaces Discussion'" References: Subject: AW: [NOT SOLVED] Re: JSF2 f:metadata and templates what the feck am I doing wrong? Date: Fri, 29 Apr 2011 14:06:14 +0200 Message-ID: <6834229796B647879E3413623521E9F0@etech01> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6090 Thread-Index: AcwGXeH7FzM0VNMnSVquBCM6Z65i8QABy/0w In-Reply-To: Hi Stephen,=20 an additional example with the use of templates would be -> = template.xhtml : =20 ................................. =20 you can then decide on every page if you need the metatdata or not -> pageX.xhtml: .......... best regards Thomas -----Urspr=FCngliche Nachricht----- Von: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] Im = Auftrag von Jakob Korherr Gesendet: Freitag, 29. April 2011 13:09 An: MyFaces Discussion Betreff: Re: [NOT SOLVED] Re: JSF2 f:metadata and templates what the = feck am I doing wrong? Hi Stephen, This actually is a very common mistake people make with JSF 2. The = problem is the following: As you correctly pointed out, f:metadata needs to be a direct child of f:view. However, with facelets f:view is handled very differently then = with JSP. In JSP you need f:view as the root tag for every other JSF tag, but = in facelets the UIViewRoot is always the xml root tag (the most outer tag = with the xmlns attributes). Thus in JSF 2 when using facelets, UIViewRoot is = most certainly created by the following code: This means that you have to place f:metadata as a direct child of the = above root element, for example: .... This will make it work ;) Also, as an explanation why there still is a f:view tag for facelets also: Since you need some kind of way to set the attributes of f:view = (like e.g. locale), you still need the f:view tag. However, it does not create = an additional UIViewRoot, but only pass through the attributes to the = already existing UIViewRoot. Thus you will use it in this way: .... ... ... I hope this helps ;) Regards, Jakob 2011/4/29 Stephen Connolly : > If I change the template to > > */WEB-INF/templates/basic.xhtml* > > "-//W3C//DTD XHTML 1.0 Transitional//EN" > =A0 =A0 =A0 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > http://java.sun.com/jsf/facelets" > > =A0 =A0 xmlns:h=3D"http://java.sun.com/jsf/html" xmlns:f=3D" > http://java.sun.com/jsf/core"> > > > > =A0 > > > =A0 =A0 =A0 > > > > > > Then it seems to work... but the tagdocs on=20 > http://javaserverfaces.java.net/nonav/docs/2.0/vdldocs/facelets/f/meta > data.html > say > it should work the way I had things originally.... strange > > On 29 April 2011 10:23, Stephen Connolly wrote: > >> Spoke too soon >> >> :-( >> >> I'd been checking to see if it was the servlet mapping that was=20 >> causing the issues, so I changed the mapping from *.xhtml to=20 >> *.faces... and I'd forgotten to change the url in my browser, so I=20 >> was being served the raw .xhtml which was rendering the

as a =

... >> >> removing the com.sun.faces.validateXml had no effect >> >> The problem still exists! >> >> HELP! >> >> -Stephen >> >> >> On 29 April 2011 10:10, Stephen Connolly wrote: >> >>> Ok, I just found the/a solution. >>> >>> that was to remove >>> >>> =A0 >>> =A0 =A0 com.sun.faces.validateXml >>> =A0 =A0 true >>> =A0 >>> >>> 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=20 >>> solution anyway so that others might benefit >>> >>> -Stephen >>> >>> On 29 April 2011 10:08, Stephen Connolly=20 >>> >> > 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/m >>>> etadata.htmland=20 >>>> 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* >>>> >>>> >>> "-//W3C//DTD XHTML 1.0 Transitional//EN" >>>> =A0 =A0 =A0 = =A0"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >>>> >>> =A0 =A0 =A0xmlns:ui=3D"http://java.sun.com/jsf/facelets" >>>> =A0 =A0 =A0xmlns:h=3D"http://java.sun.com/jsf/html" >>>> =A0 =A0 =A0xmlns:f=3D"http://java.sun.com/jsf/core" >>>> =A0 =A0 =A0 =A0> >>>> >>>> =A0 =A0 >>>> >>>> >>>> =A0 =A0 >>>> =A0 =A0 =A0 =A0 >>>> =A0 =A0 =A0 =A0 >>>> =A0 =A0 >>>> >>>> >>>> >>>> >>>> and then reference that template >>>> >>>> */test.xhtml* >>>> >>> xmlns=3D"http://www.w3.org/1999/xhtml" >>>> =A0 =A0 =A0 xmlns:ui=3D"http://java.sun.com/jsf/facelets" >>>> =A0 =A0 =A0xmlns:h=3D"http://java.sun.com/jsf/html" >>>> =A0 =A0 =A0 xmlns:f=3D"http://java.sun.com/jsf/core" >>>> =A0 =A0 =A0template=3D"/WEB-INF/templates/basic.xhtml"> >>>> =A0 =A0 >>>> =A0 =A0 =A0 >>>> =A0 =A0 =A0 =A0 >>>> =A0 =A0 =A0 >>>> =A0 =A0 >>>> =A0 =A0 >>>> =A0 =A0 =A0 =A0

The big news stories of the day

>>>> =A0 =A0
>>>> >>>> >>>> >>>> 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: >>>> >>>> =A0 =A0/test.xhtml at line 8 and column 19 Parent=20 >>>> UIComponent j_id1187866547_41aebe2a should be instance of=20 >>>> UIViewRoot Caused by: >>>> >>>> javax.faces.view.facelets.TagException: /test.xhtml at line 8 and=20 >>>> column >>>> 19 Parent UIComponent j_id1187866547_41aebe2a should=20 >>>> be instance of UIViewRoot >>>> =A0at >>>> org.apache.myfaces.view.facelets.tag.jsf.core.ViewMetadataHandler.a >>>> pply(ViewMetadataHandler.java:61) >>>> at >>>> org.apache.myfaces.view.facelets.tag.ui.DefineHandler.applyDefiniti >>>> on(DefineHandler.java:86) >>>> =A0at >>>> org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(Co >>>> mpositionHandler.java:167) >>>> at >>>> org.apache.myfaces.view.facelets.impl.TemplateContextImpl$TemplateM >>>> anagerImpl.apply(TemplateContextImpl.java:128) >>>> =A0at >>>> org.apache.myfaces.view.facelets.impl.TemplateContextImpl.includeDe >>>> finition(TemplateContextImpl.java:92) >>>> at >>>> org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.include >>>> Definition(DefaultFaceletContext.java:433) >>>> =A0at >>>> org.apache.myfaces.view.facelets.tag.ui.InsertHandler.apply(InsertH >>>> andler.java:93) >>>> at >>>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFa >>>> celetHandler.java:51) >>>> =A0at >>>> org.apache.myfaces.view.facelets.tag.jsf.core.ViewHandler.apply(Vie >>>> wHandler.java:156) >>>> at >>>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler >>>> (DelegatingMetaTagHandler.java:59) >>>> =A0at >>>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegat >>>> e.apply(ComponentTagHandlerDelegate.java:324) >>>> at >>>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(Delegating >>>> MetaTagHandler.java:54) >>>> =A0at >>>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFa >>>> celetHandler.java:51) >>>> at >>>> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(Na >>>> mespaceHandler.java:57) >>>> =A0at >>>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFa >>>> celetHandler.java:51) >>>> at >>>> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(Enc >>>> odingHandler.java:45) >>>> =A0at >>>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(Defaul >>>> tFacelet.java:322) >>>> at >>>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(Defaul >>>> tFacelet.java:369) >>>> =A0at >>>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(Defaul >>>> tFacelet.java:347) >>>> at >>>> org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.include >>>> Facelet(DefaultFaceletContext.java:215) >>>> =A0at >>>> org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(Co >>>> mpositionHandler.java:140) >>>> at >>>> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(Na >>>> mespaceHandler.java:57) >>>> =A0at >>>> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(Enc >>>> odingHandler.java:45) >>>> at >>>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultF >>>> acelet.java:143) >>>> =A0at >>>> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.bui >>>> ldView(FaceletViewDeclarationLanguage.java:327) >>>> at >>>> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderR >>>> esponseExecutor.java:66) >>>> =A0at >>>> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.jav >>>> a:239) at=20 >>>> javax.faces.webapp.FacesServlet.service(FacesServlet.java:191) >>>> =A0at >>>> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:5 >>>> 46) >>>> at >>>> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.ja >>>> va:483) >>>> =A0at >>>> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler >>>> .java:119) >>>> at >>>> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.j >>>> ava:516) >>>> =A0at >>>> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHan >>>> dler.java:230) >>>> at >>>> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHan >>>> dler.java:956) >>>> =A0at >>>> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.jav >>>> a:411) >>>> at >>>> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHand >>>> ler.java:188) >>>> =A0at >>>> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHand >>>> ler.java:891) >>>> at >>>> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler >>>> .java:117) >>>> =A0at >>>> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(Co >>>> ntextHandlerCollection.java:247) >>>> at >>>> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCo >>>> llection.java:151) >>>> =A0at >>>> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapp >>>> er.java:114) at=20 >>>> org.eclipse.jetty.server.Server.handle(Server.java:353) >>>> =A0at >>>> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnectio >>>> n.java:598) >>>> at >>>> org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComple >>>> te(HttpConnection.java:1059) >>>> =A0at=20 >>>> org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:590) >>>> at=20 >>>> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:21 >>>> 2) >>>> =A0at >>>> org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java: >>>> 427) >>>> at >>>> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannel >>>> EndPoint.java:510) >>>> =A0at >>>> org.eclipse.jetty.io.nio.SelectChannelEndPoint.access$000(SelectCha >>>> nnelEndPoint.java:34) >>>> at >>>> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelE >>>> ndPoint.java:40) >>>> =A0at >>>> org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPo >>>> ol.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=20 >>>> prevented it from fulfilling this request. >>>> >>>> exception >>>> >>>> javax.servlet.ServletException: /test.xhtml at line 8 and column 19 = >>>> Parent UIComponent j_id1187866547_41aebe2a should be=20 >>>> instance of UIViewRoot >>>> =A0javax.faces.webapp.FacesServlet.service(FacesServlet.java:205) >>>> root cause >>>> >>>> javax.faces.view.facelets.TagException: /test.xhtml at line 8 and=20 >>>> column >>>> 19 Parent UIComponent j_id1187866547_41aebe2a should=20 >>>> be instance of UIViewRoot >>>> org.apache.myfaces.view.facelets.tag.jsf.core.ViewMetadataHandler.a >>>> pply(ViewMetadataHandler.java:61) >>>> >>>> org.apache.myfaces.view.facelets.tag.ui.DefineHandler.applyDefiniti >>>> on(DefineHandler.java:86) >>>> org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(Co >>>> mpositionHandler.java:167) >>>> >>>> org.apache.myfaces.view.facelets.impl.TemplateContextImpl$TemplateM >>>> anagerImpl.apply(TemplateContextImpl.java:128) >>>> org.apache.myfaces.view.facelets.impl.TemplateContextImpl.includeDe >>>> finition(TemplateContextImpl.java:92) >>>> >>>> org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.include >>>> Definition(DefaultFaceletContext.java:433) >>>> org.apache.myfaces.view.facelets.tag.ui.InsertHandler.apply(InsertH >>>> andler.java:93) >>>> >>>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFa >>>> celetHandler.java:51) >>>> org.apache.myfaces.view.facelets.tag.jsf.core.ViewHandler.apply(Vie >>>> wHandler.java:156) >>>> >>>> javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler >>>> (DelegatingMetaTagHandler.java:59) >>>> org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegat >>>> e.apply(ComponentTagHandlerDelegate.java:324) >>>> >>>> javax.faces.view.facelets.DelegatingMetaTagHandler.apply(Delegating >>>> MetaTagHandler.java:54) >>>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFa >>>> celetHandler.java:51) >>>> >>>> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(Na >>>> mespaceHandler.java:57) >>>> javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFa >>>> celetHandler.java:51) >>>> >>>> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(Enc >>>> odingHandler.java:45) >>>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(Defaul >>>> tFacelet.java:322) >>>> >>>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(Defaul >>>> tFacelet.java:369) >>>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(Defaul >>>> tFacelet.java:347) >>>> >>>> org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.include >>>> Facelet(DefaultFaceletContext.java:215) >>>> org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(Co >>>> mpositionHandler.java:140) >>>> >>>> org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(Na >>>> mespaceHandler.java:57) >>>> org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(Enc >>>> odingHandler.java:45) >>>> >>>> org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultF >>>> acelet.java:143) >>>> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.bui >>>> ldView(FaceletViewDeclarationLanguage.java:327) >>>> >>>> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderR >>>> esponseExecutor.java:66) >>>> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.jav >>>> a:239) >>>> javax.faces.webapp.FacesServlet.service(FacesServlet.java:191) >>>> note The full stack trace of the root cause is available in the=20 >>>> 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 >>>> >>> "-//W3C//DTD XHTML 1.0 Transitional//EN" >>>> =A0 =A0 =A0 =A0 = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >>>> >>> =A0 =A0 =A0 xmlns:ui=3D"http://java.sun.com/jsf/facelets" >>>> =A0 =A0 =A0 xmlns:h=3D"http://java.sun.com/jsf/html" >>>> =A0 =A0 =A0 xmlns:f=3D"http://java.sun.com/jsf/core" >>>> =A0 =A0 =A0 =A0 =A0> >>>> >>>> =A0 =A0 >>>> >>>> >>>> =A0 =A0 >>>> =A0 =A0 =A0 =A0 >>>> =A0 =A0 =A0 =A0 =A0 >>>> =A0 =A0 =A0 =A0 >>>> =A0 =A0 =A0 =A0

The big news stories of the day

>>>> =A0 =A0
>>>>
>>>> >>>> >>>> Then I get: >>>> >>>> javax.servlet.ServletException: /test2.xhtml at line 14 and column=20 >>>> 21 Parent UIComponent j_id1723811066_66bf44b9 should=20 >>>> be instance of UIViewRoot >>>> =A0 =A0 = 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/m >>>> etadata.htmlseriously wrong >>>> >>>> Oh, before I forget, here is my web.xml >>>> >>>> >>> xmlns=3D"http://java.sun.com/xml/ns/javaee" >>>> =A0 =A0 =A0 =A0 = =A0xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" >>>> =A0 =A0 =A0 =A0 = =A0xsi:schemaLocation=3D"http://java.sun.com/xml/ns/javaee >>>> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> >>>> =A0 >>>> =A0 =A0 javax.faces.STATE_SAVING_METHOD >>>> =A0 =A0 server >>>> =A0 >>>> =A0 >>>> =A0 =A0 javax.faces.DEFAULT_SUFFIX >>>> =A0 =A0 .xhtml >>>> =A0 >>>> =A0 >>>> =A0 =A0 javax.faces.FACELETS_SKIP_COMMENTS >>>> =A0 =A0 true >>>> =A0 >>>> =A0 >>>> =A0 =A0 javax.faces.PROJECT_STAGE >>>> =A0 =A0 >>>> =A0 =A0 Development >>>> =A0 >>>> =A0 >>>> =A0 =A0 com.sun.faces.validateXml >>>> =A0 =A0 true >>>> =A0 >>>> =A0 >>>> >>>> org.apache.myfaces.webapp.StartupServletContextList >>>> ener >>>> =A0 >>>> >>>> =A0 >>>> =A0 =A0 Faces Servlet >>>> =A0 =A0 = javax.faces.webapp.FacesServlet >>>> =A0 =A0 1 >>>> =A0 >>>> =A0 >>>> =A0 =A0 Faces Servlet >>>> =A0 =A0 *.xhtml >>>> =A0 >>>> >>>> =A0 >>>> =A0 =A0 60 >>>> =A0 >>>> >>>> >>>> Any and all help appreciated >>>> >>>> -Stephen >>>> >>> >>> >> > -- Jakob Korherr blog: http://www.jakobk.com twitter: http://twitter.com/jakobkorherr work: http://www.irian.at