6 Replies Latest reply on Jun 3, 2011 3:23 AM by MIklos Piklos

    With which version of JSF 2 are seam faces tested?

    MIklos Piklos Newbie

      I am using tomcat 7 and jsf 2 mojarra. I added seam-faces, and i am seeing different behaviour of some seam-faces components based on the version of jsf.
      So this code:

           <s:viewAction action="#{loginAction.redirectIfLoggedIn('anId')}" />  

      Behaves differently depending on the jsf 2 version:
      1) With 2.1.0 it breaks as soon as the page is rendered with something like Object not found error message
      2) With 2.1.1-b04 you got some complaints that a tag must be inside a form ??!!??
      3) Finally i found that with version 2.0.3 everything works as specified in the documentation.

      So is there a prefered version of JSF 2? And if so could you please update the documentation and specify which versions of jsf have seam faces been tested against?

      Thank you.

        • 1. Re: With which version of JSF 2 are seam faces tested?
          Lincoln Baxter III Master

          The Mojarra JSF implementation is extremely buggy. You can always try MyFaces.

          • 2. Re: With which version of JSF 2 are seam faces tested?
            MIklos Piklos Newbie

            I tried with myfaces 2.0.6 and 2.1.0 and s:viewAction just doesn't work. I tried messing with it arround, but it never seeems to fire.

            This is my template:

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            <html xmlns="http://www.w3.org/1999/xhtml"
                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    <h:outputStylesheet name="brand/default/style/netxpert.css" />
                    <h:outputStylesheet name="brand/default/style/navmenu.css" />
                    <link rel="shortcut icon" type="image/x-icon"
                          href="../../resources/brand/default/images/icons/favicon.ico" />
                   <h:outputScript name="jsf.js" library="javax.faces" />
                   <h:outputScript name="jquery.js" />
                        <f:viewParam  name="a" value="#{loginAction.a}"/>
                        <s:viewAction action="#{loginAction.redirectIfLoggedIn('/pages/private/viewSystem.xhtml?faces-redirect=true')}" />
                <h:body styleClass="main     ">
                    <div style="width: 100%; height: 100%; overflow: hidden; position: absolute; z-index: 1">
                        <ui:insert name="header">
                            <ui:include src="header/header.xhtml" />
                        <div id="maincontent">
                            <ui:insert name="maincontent">
                                 <ui:insert name="navbar" />
                                    <div id="navcontent">
                                        <ui:insert name="navcontent" />

            this is my page:

            <?xml version="1.0" encoding="UTF-8"?>
            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                 <ui:define name="navcontent">
                      <div id="page">
                           <span class="paragraphtitleshadow"> Please enter your username
                                and password <span class="paragraphtitlefront">Please enter
                                     your username and password</span> </span> <br />
                                <h:panelGrid columns="2"
                                     styleClass="reports_table container-login-controls">
                                     <h:outputText value="Username:" />
                                     <h:inputText value="#{credentials.username}" />
                                     <h:outputText value="Password:" />
                                     <h:inputSecret value="#{credentials.password}" />
                                <h:commandButton styleClass="btnenabled"
                                     value="Login" />

            I must add that

            <s:validateForm />


            • 3. Re: With which version of JSF 2 are seam faces tested?
              Brian Leathem Master

              The specification requires that the f:metadata tag:

              must be a child of the <f:view>. This tag must reside within the top level XHTML file for the given viewId, not in a template

              So try moving the f:metadata tag into the page itself, rather than having it in your template.

              Note: you can put the <s:viewAction> in a separate file and use a <ui:include> tag to include it the page's <f:metadata> tag

              • 4. Re: With which version of JSF 2 are seam faces tested?
                MIklos Piklos Newbie

                Thanks that seemed to be the problem. i must add that i tried messing arround with it for hours, but i haven't succeded in finding out what's wrong.
                This post on myfaces mail list confused me even more:

                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:

                <html xmlns="http://www.w3.org/1999/xhtml";

                This means that you have to place f:metadata as a direct child of the
                above root element, for example:

                <html xmlns="http://www.w3.org/1999/xhtml";

                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:

                <html xmlns="http://www.w3.org/1999/xhtml";
                    <f:view locale="...." />

                I hope this helps ;)

                Because of this post i figured out that you actually need to put the metdata tag on the root page. The guy actually states that (or am i wrong???) you need to put metadata as a direct child of the root element.

                I must admit that is one of biggest gotchas i've seen in years. I think there will be a lot more people with the same problem (me, the myfaces guy, and the guy who asked a question on myfaces mailing list were confused about it), so i think it would be advisable to mark this as a possible gotcha in the documentation. I think the red colour would be appropriate:). It will save other people some headache.


                • 5. Re: With which version of JSF 2 are seam faces tested?
                  Brian Leathem Master

                  I'm glad it solved your problem.  Would you mind checking if it also fixed your Mojarra problems, and posting back your results?

                  And yes, this behavior does need to be better documented.


                  • 6. Re: With which version of JSF 2 are seam faces tested?
                    MIklos Piklos Newbie

                    OK, i tested this without chaning the code, but only switching to mojarra and changing the versions.
                    1) with mojarra 2.0.3 the tag works.
                    2) with mojarra 2.1.0 i get the error message

                    Jun 3, 2011 9:03:20 AM com.sun.faces.application.ApplicationImpl createComponentApplyAnnotations
                    SEVERE: JSF1068: Cannot instantiate component with component-type org.jboss.seam.faces.ViewAction

                    The page doesn't get rendered.

                    The whole stack trace:

                    javax.faces.FacesException: Expression Error: Named Object: org.jboss.seam.faces.ViewAction not found.
                         at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1881)
                         at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1152)
                         at org.jboss.weld.environment.servlet.jsf.ForwardingApplication.createComponent(ForwardingApplication.java:122)
                         at javax.faces.application.ApplicationWrapper.createComponent(ApplicationWrapper.java:594)
                         at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(ComponentTagHandlerDelegateImpl.java:503)
                         at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:157)
                         at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
                         at com.sun.faces.facelets.tag.jsf.core.MetadataHandler.apply(MetadataHandler.java:104)
                         at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
                         at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
                         at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
                         at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
                         at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:116)
                         at org.jboss.seam.faces.view.SeamViewMetadata.createMetadataView(SeamViewMetadata.java:47)
                         at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:230)
                         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
                         at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:113)
                         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
                         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
                         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
                         at biz.netdialog.web.filter.SecurityFilter.doFilter(SecurityFilter.java:51)
                         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
                         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
                         at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
                         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
                         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
                         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
                         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
                         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
                         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
                         at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110)
                         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
                         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
                         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
                         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
                         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
                         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
                         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
                         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
                         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
                         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
                         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
                         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
                         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
                         at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
                         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
                         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
                         at java.lang.Thread.run(Unknown Source)

                    3) with mojarra 2.1.1-b04 i get some message on the page that 'form needs to be enclosed' when I am in development mode. However action gets called and the page is rendered.