7 Replies Latest reply on Mar 24, 2014 6:46 AM by Frank Langelage

    JSF not work correctly

    timtasse Newbie

      hi,

       

      i test wildfly and would like to deploy an easy default JSF app.

      the app starts normally but the backing bean is never invoked.

      i found this is a problem in mojarra and is fixed in version 2.2.7, the current master uses only 2.2.6.

       

      can you update to 2.2.7 ?

       

      here is the link to the mojarra bug:

      https://java.net/jira/browse/JAVASERVERFACES-3189

       

      or is there some other way to fix this issue (special jboss-web.xml or faces-config.xml) ?

       

      regards

        • 1. Re: JSF not work correctly
          Frank Langelage Master

          The mentioned mojarra bug is not your problem. This only appears, when you have more than one web app deployed on undeploy / stop of server. And before the applications work.

          And as long as 2.2.7 is not yet available and update of WildFly is not possible.

          But Farah Juma who participated on the mentioned mojarra bug will sent a pull request when available.

           

          You application is completely new or did it work before on other servers / versions / configurations?

          No data binding at all, no call of any action methods?

           

          To get more help you have to give us more information.

          • 2. Re: JSF not work correctly
            timtasse Newbie

            i have downloaded the current nightly build und start it.

            then i create a JSF application in netbeans8.

            one backing bean with one method:

            @Model

            public class Test {

                public String bla() {

                    System.out.println("bla is returned");

                    return "bla";

                }

            }

             

            then the default index.xhtml use this backing bean:

            #{test.bla}

             

            then i deployed this app to wildfly.

            this is filelist of the war:

            META-INFWEB-INFindex.xhtml

            standalone/deployments/WebApplication1.war/META-INF:

            MANIFEST.MF

            standalone/deployments/WebApplication1.war/WEB-INF:

            classesweb.xml

            standalone/deployments/WebApplication1.war/WEB-INF/classes:

            Test.class

             

            i think its really simple, but the test.bla is not called, no output in the log, that this method was called.

            i run the wildfly with the JDK8 official release.

            • 3. Re: JSF not work correctly
              Frank Langelage Master

              No faces-config.xml and no beans.xml.

              I don't know if they are mandatory for this purpose or not, I never tried to build CDI based web-app without them.

               

              How you use #{test.bla} in index.xhtml and what's the html source of the page you see in the browser?

              You have other content in index.xhtml that makes sure that your page is really rendered?

              It would be helpful to zip together all sources and provide them here to shorten this ping pong.

               

              In this case test.bla is a method, not a property. This can be used for action attribute of h:commandButton or h:comamndLink for instance.

              Otherwise you need method getBla() for value attribute of h:outputText (<h:outputText value="#{test.bla}"/>).

              • 4. Re: Re: JSF not work correctly
                timtasse Newbie

                ok i have created beans.xml and faces-config.xml but same problem.

                i think both are optional in EE7.

                i have changed the index.xhtml and use test.bla(), this should not the problem, i think JSF looks for methods without parameter and calls them, if it is no property.

                 

                i have the war file attached, so you can test it.

                if i deploy this war file to glassfish4 , all works.

                • 5. Re: JSF not work correctly
                  Frank Langelage Master

                  I still not understand what you expect to happen or what's happening on GF when using "#[test.bla}" with or without the () brackets.

                  I changed to <h:commandButton value="Test" action="#{test.bla()}"/>

                  Then you're required to add <h:form/> around it.

                  Hitting the button I get "javax.el.PropertyNotFoundException: /index.xhtml @12,67 action="#{test.bla()}": Target Unreachable, identifier 'test' resolved to null".

                   

                  You only gave us the compiled class not the source code.

                  Your bean is still only annotated with @Model? I never used, but from what I read it's a replacement of the combination of @Named and @RequestScoped.

                  This should be enough to be used by the JSF view.

                  Next thing I'd try would be to replace @Model by @javax.inject.Named + @javax.enterprise.context.RequestScoped.

                  But I see no reason why @Model should not work.

                  • 6. Re: Re: JSF not work correctly
                    timtasse Newbie

                    in JSF you can only paste #{test.bla()} in the source code of the index.xhtml and JSF will call the method and place return value in the spource code of the generated page.

                    the full source code of the Test.java file is the same as i have already pasted.

                     

                    on glassfish the page work as expected, the method is called and the return value is pasted.

                    the generated page is then:

                    Hello from Facelets

                    bla


                    on wildfly only the first line is generated.

                    • 7. Re: Re: JSF not work correctly
                      Frank Langelage Master

                      I know that you can simply use #{test.bla()}.

                       

                      But as I said the core problem is, that the test bean is not instantiated.

                       

                      I used annotations javax.inject.Named and javax.enterprise.context.RequestScoped instead of javax.enterprise.inject.Model. Then the application works.

                      From what I read Model should be the same as Named + RequestScoped.

                       

                      So for me it's a bug in the CDI module or its integration into WildFly.

                      You might create a bug report in Jira and reference this thread.