2 Replies Latest reply on Jun 5, 2008 11:09 AM by Karl Neumann

    bind a component to some other context variable by programmatic API call

    Karl Neumann Newbie

      Hi Guys!


      I found this sentence in the Seam Reference Document:


      However, again like JSF, it is possible
      for the application to bind a component to some other context variable by programmatic API call.


      Does anybody know how to do this?


      I want to build user interface components like Master/Detail, ... and it occurs that i need the same ui component in the same conversation n-times. Now the stateful sb which handles the ui component should also exist n-times in the conversation. It would be very cool if this could work with seam.


      cheers
      Karl

        • 1. Re: bind a component to some other context variable by programmatic API call
          Nicklas Karlsson Master

          Well, I'm not sure I understood your requirements but there is always the


          Contexts.getConversationContext()...



          etc but most stuff can be done with


          @Out(scope=CONVERSATION)



          etc.

          • 2. Re: bind a component to some other context variable by programmatic API call
            Karl Neumann Newbie

            Hi Nicklas,


            thanks for your reply!!


            I ll try to explain better(although its not exactly my biggest strength ;-)).


            I would need a mechanism which lets me bind names dynamically to a seam component as i have no idea which roles a seam component can have at coding time.


            I thought of writing my own Factory which uses Contexts.get...Context() and write the object myself on the appropriate context.
            This factory would be a stateless sb. I have serveral issues with this aproach:


            1. How do i create a seam component from a normal stateful sb without @Name annotation?


            2. How do i synchronize the creation of Objects for a user?


            3. I don't like this approach at all. I would like to use normal injection/outjection mechanism. But as i understood seam this is somehow against its concept.


            To solve issue 2 i could make this Factory stateful and use a synchronized map for it but then i would have to manage the objects myself and i would like to let seam do the job. Anyhow i don't like this idea very much.
            Maybe i could use the reflection api to add a new role. But i have no idea when seam evaluates the Annotation and it would be again a somehow strange solution.


            Right now we have a solution which uses one Stateful sb per screen  and i want to split it up into one Stateful sb per screen component (which is e.g. a Detail screen of a person or a list of persons) and just glue them together.


            I hope it got more clear...


            thanks once more
            Karl