3 Replies Latest reply on May 20, 2012 4:05 PM by riboriori

    Producers, injection point and custom context

    riboriori

      Hi all

      i've developed a custom context that is similar to @viewScoped context.

      I have two controllers , say ActionA, ActionB, in order to implements a test wizard.

      This wizard simulate a registration of new user's data.

       


       

       

      {code:java}

      @CustomScoped

      @Named("actionA")

      public class ActionA{

       

      private String var1;

       

      @Produces @Named("var1")

      public String getVar1(){

        return var1;

      }

       

      public void setVar1(String var1){

      this.var1 = var1;

      }

       

       

       

      }

      {code}

       

       

       

      {code:java}

      @CustomScoped

      @Named("actionB")

      public class ActionB{

       

      private String var2;

      @Inject @Named("var1") String var1;

       

      public String getVar2(){

      return var2;

      }

       

      public void setVar2(String var2){

      this.var2 = var2;

      }

       

      public void endWizard(){

      System.out.println("var1 is: " + var1);

      }

       

      }

      {code}

       

       


      Steps:

      1) Go to ActionA, make var1 equals to "var1";

      2) Go to ActionB, make var2 equals to "var2";

      3) Invoke endWizard method of ActionB class and i can read into the consolle "var1 is: var1";

      4) Go back to ActionA and make var1 equals to "var1_second_change";

      5) Go forward to ActionB, invoke endWizard method of ActionB class and i read into the consolle "var1 is: var1", when i expect to read "var1 is: var1_second_change";

       

      In my custom context, instead i can see that var1 field of instance of ActionA controller contains correct value (var1 in fact is equals to "var1_second_change" value).

      I cant understand why that newly value does not be produced.

       

      Can anyone help me?

      P.S. Sorry my english is bad.