3 Replies Latest reply on Jul 16, 2007 5:29 AM by Ning Zhao

    @DataModel(scope=CONVERSATION) banned, why?

    Ning Zhao Apprentice

      I attempted to write @DataModel(scope=CONVERSATION) but was banned when building, only UNSPECIFIED and PAGE are allowed. Why cannot @DataModel be conversation scoped? Thanks in advance!


        • 1. Re: @DataModel(scope=CONVERSATION) banned, why?
          Dan Allen Master

          I believe it has to do with the fact that a DataModel is either attached to the scope of the owning component or it is placed in PAGE context when used on a stateless component. The restriction has to do with how Seam maintains the row selection. It isn't meant to be tossed out into the great wide open.

          • 2. Re: @DataModel(scope=CONVERSATION) banned, why?
            Adrian Mitev Master

            And i don't see a reason @DataModel to be in converstation scope, you need it on one page only.

            • 3. Re: @DataModel(scope=CONVERSATION) banned, why?
              Ning Zhao Apprentice

              well, there was problem when I use facelet composition (2 levels templating) and my @DataModel private Map myMap was not tied to a proxy-based collection. The map can be displayed in a table at the first time when the composed page was rendered. But I wanted such control: there was a s:button in the same page calling showFacts() which will set the

              boolean renderMyMapTable
              to true. If I click this button and load (in fact) the same page, the map table was not loaded any more. Seam might treat them as two different pages....

              There is a work around to this. Put all the Map.Entry in myMap to a list (type: List<Map.Entry<MyKey, MyValue>>) and make the list conversation bean managed. Write a getter for this list and expose the getter in business interface. Ask <h:dataTable> to iterate the myMapEntryList if the boolean render flag is set to true. This way the map table can be shown/folded as many times as the user wishes. Tested it and it works well.