2 Replies Latest reply on Oct 16, 2008 11:16 AM by gothmog

    multiple components with same name in same context

      Hi,


      I have an app that displays multiple datagrids on the same page differing only by a filter on the same underlying data. i.e. they behave the same but operate on a different List. When the user interacts they interact with one at a time, but the logic is backed by the same Seam component.


      When a user interacts with one grid e.g. sorting, editing etc how can I inject just that grids data into the component when I've only got one name to name the binding variable?


      In other words how does one handle this reusable ui component type design when Seam context variables tie you to one instance of a variable by name as I'm struggling to find a pattern in Seam to met this use case.


      Thanks in advance


      Troy

        • 1. Re: multiple components with same name in same context
          lucianofen

          you can use


          @In(value=contextVariableName)
          Specifies the name of the context variable explicitly, instead of using the annotated instance variable name.


          Or also you can use JSF-EL to define the binding


          @In(value=#{expression})


          so the binding between component and field is not 1 to 1


          regards
          Luciano

          • 2. Re: multiple components with same name in same context

            Thanks Luciano,


            I did know about the value attribute specifying a different name for the context variable but I couldn't really see the point as you just shift the one to one relationship from one hard coded name to another.


            Didn't realise you could use EL in the value attribute, I guess you could then make {expression} a page param and have the multiple components send in their appropriate id.


            That might work. You could then retrieve instance data based on that id. Have you tried something like this before. What I am trying to do is have a reusable UI component in a ui:composition and then just drop it on many pages and multiple on the same page and have it interact with the same Seam backend component, with injection handling the instance of the component that is being acted on.


            I have an app that the user can organise many grids on the same page that essentially have the same behaviour but just operate on different instance data.


            Cheers


            Troy