9 Replies Latest reply on Jan 9, 2008 10:18 AM by Stan Silvert

    Reg:FacesContext

    steve alex Newbie

      Hi ppl,


      Does the facescontext gets destroyed,after the end of jsf life cycle


      becoz it was given in wiki, i had a bit doubt on this can u please clarify this for me

        • 1. Re: Reg:FacesContext
          Stan Silvert Master

          With JSFUnit, the FacesContext is not destroyed at the end of the JSF Lifecycle. JSFUnit keeps it alive so that you can examine the state of your system and make assertions in your unit tests. With JSFUnit, the FacesContext is actually destroyed at the beginning of the following request.

          I've changed the wording of this wiki page to make it a bit more clear:
          http://wiki.jboss.org/wiki/JSFServerSessionAPI

          Thanks for the feedback,

          Stan

          • 2. Re: Reg:FacesContext
            steve alex Newbie

            In production, the last thing that happens at the end of the JSF lifecycle is to destroy the FacesContext.



            what do u mean by this.....at the end of the JSF lifecycle the facesContext is gonna be destroyed...but with JSFUnit we can preserve facesContext n use it right.......


            • 3. Re: Reg:FacesContext
              Stan Silvert Master

              Right. JSFUnit preserves the latest FacesContext for use in your test.

              Stan

              • 4. Re: Reg:FacesContext
                steve alex Newbie

                Stan

                clear me on ..does facesContext gets destroyed at the end of lifecyle of JSF...

                • 5. Re: Reg:FacesContext
                  Stan Silvert Master

                  If you are not using JSFUnit then the FacesContext will be destroyed at the end of the lifecycle. More specifically, the JSF spec says that FacesContext.destroy() is called.

                  With JSFUnit, we install a FacesContextFactory that dispenses a JSFUnitFacesContext. When destroy() is called on the JSFUnitFacesContext, it is not actually destroyed. Instead, it is associated with the test thread so that you can use it in your tests. When your test makes another request via the JSFClientSession, the JSFUnitFacesContext from the previous request is then destroyed.

                  Stan

                  • 6. Re: Reg:FacesContext
                    steve alex Newbie

                    Thanks for ur reply..

                    i want to use this theard for all the facescontext related issues......

                    in the example given(HelloJSFIntegrationTest) u have used webconversation (i.e used httpunit)


                    for facescontext can't we use clientSession

                    like

                    JSFClientSession client = new JSFClientSession("/index.faces");
                    
                    
                    JSFServerSession server = new JSFServerSession(client);



                    is there any specific reason in using the httpunit ...can u explain me in detail...

                    Thanks in advance


                    • 7. Re: Reg:FacesContext
                      Stan Silvert Master

                       

                      "kingkon" wrote:


                      i want to use this theard for all the facescontext related issues......


                      I don't understand your question. What FacesContext issue are you seeing? What is the problem?


                      "kingkon" wrote:

                      for facescontext can't we use clientSession


                      There is no FacesContext at the client. JSFClientSession acts as the "browser" in your test.

                      Stan

                      • 8. Re: Reg:FacesContext
                        steve alex Newbie

                        in the HelloJSFIntegrationTest example ...u haven't used

                        JSFServerSession server = new JSFServerSession(client);

                        this line ur code....... i mean to ask u that ..... is it possible to use this n do ..r if we r using facescontext ...is it compulsory that we use httpunit..

                        • 9. Re: Reg:FacesContext
                          Stan Silvert Master

                          HelloJSFIntegrationTest doesn't use the facade package, where JSFClientSession and JSFServerSession reside. They only use raw HttpUnit and the JSFUnit framework package (the "guts" of the product).

                          Yes, you must use HttpUnit, either directly as in HelloJSFIntegrationTest, or indirectly as in the tests using JSFClientSession/JSFServerSession.

                          There is a possibility that we will replace HttpUnit with HtmlUnit or something else in the future though.

                          For future posts please:
                          1) Start a new thread for new topics
                          2) State your questions in complete sentences. I think part of the problem I have answering your questions comes from the fact that you are using shorthand (like ..u ur ..r r n).

                          Stan