0 Replies Latest reply on Aug 5, 2011 2:25 PM by Franek Jop

    ViewScoped problem

    Franek Jop Newbie

      I have simple jsf page with form:



         <h:commandButton value="test" action="#{jsfTest.doit}" >




      With viewScoped class:




      public class JsfTest {



                public JsfTest() {



        public String doit(){


                               FacesContext ctx = FacesContext.getCurrentInstance();

                               UIViewRoot root = ctx.getViewRoot();

                               System.out.println("uiviewRoot: "+root.toString());

                               return null;




      And every time i click the button new UIViewRoot and my JsfTest is created:

      20:18:51,455 INFO  [stdout] (http-- New

      20:18:51,457 INFO  [stdout] (http-- doit

      20:18:51,457 INFO  [stdout] (http-- uiviewRoot: javax.faces.component.UIViewRoot@11b1e39

      20:18:56,548 INFO  [stdout] (http-- New

      20:18:56,548 INFO  [stdout] (http-- doit

      20:18:56,549 INFO  [stdout] (http-- uiviewRoot: javax.faces.component.UIViewRoot@5b56c4


      But JsfTest class is ViewScoped. It shoud stay the same at postback to the same page.


      I cant figure out where is the problem.