1 Reply Latest reply on Apr 10, 2010 1:15 PM by Pjot Andreev

    programmatically bind a component to a context variable?

    Chun Shin Newbie

      Hi,


      The following is from the Seam 2.2.0.GA reference document (Seam 2.2.0.GA Reference):





      ...You can also programmatically bind a component to a context variable. This is useful if a particular component serves more than one role in the system. For example, the currently logged in User might be bound to the currentUser session context variable, while a User that is the subject of some administration functionality might be bound to the user conversation context variable. ...

      Can someone please explain me what the above means in code?


      Thanks for your help!

        • 1. Re: programmatically bind a component to a context variable?
          Pjot Andreev Newbie

          "You can also programmatically bind a component to a context variable" means for instance:


          Contexts.getSessionContext().set("currentUser", user);



          "This is useful if a particular component serves more than one role in the system. For example, the currently logged in User might be bound to the currentUser session context variable" means:


          @Name("user")
          @Role(name = "currentUser", scope = ScopeType.SESSION)
          public class User {}



          The third option is to outject some component/value for example while navigation in the page.xml:


          <out name="currentUser" value="#{user}" scope="SESSION"/>



          I hope it helps