8 Replies Latest reply on Mar 15, 2006 11:56 PM by Gavin King

    Suggestions on Scope

    Magnus Sandberg Novice

      After some pondering, coding and some enlighment (thanks Gavin!), I have two suggestions.

      I have found myself wanting to keep per-page state, just as you would do in ye olde days by putting the complete state in the URL-arguments. This can now easily be done by useing PAGE-scoped data. I however want to keep the page-state intact even if I don't use the PAGE-scoped data during an action. Therefore I suggest that a new Scope is intruduced; the CONTINUOUS_PAGE scope, by this I mean that the data should be added to the next PAGE-scope even if the data is not outjected, just as it would in a CONVERSATION. The same can today be achieved by adding

      @In @Out
      private PageScopedComponent pageScopedComponent;
      

      to all action-beans.

      The second Scope I'd like to see is a STATIC_CONVERSATION scope. What I mean with this is a Scope connected to a trail of page (conversation) but it behaves like the Session-scope; it's just there and it cannot be started or stopped with @Begin/@End. I think that this could be very usefull, especially if the kill-all-conversations() method is intruduced.

      Just my 5c,
      /Magnus


        • 1. Re: Suggestions on Scope
          Gavin King Master

          Your CONTINUOUS_PAGE context is just an ordinary conversation with client-side state saving.

          YOUR STATIC_CONVERSATION context is just a conversation that never gets ended.

          I am -1 on both these things, they seem to complexify the model with very little added capability.

          • 2. Re: Suggestions on Scope
            Magnus Sandberg Novice

            1. yes you're right but since you cannot mix to have some conversational objects on the server while others are on the client this seems like an good idéa to me. Not important sice I can solve this with @In @Out.

            2. Again true but when you start doing kill-all-conversations() will it be possible to kill all but the "top" conversation? Again not imortant but would help me in a few cases.

            • 3. Re: Suggestions on Scope
              ryan dewell Novice

              As long as we're on the topic, I could really use a scope that sits between Application and Session. I implemented a quasi-scope myself using an Application scoped bean + a Map, though it's not as clean as using a pure Seam scope.

              This is a specific case I realize, but maybe it would be cool if we could have "custom scopes". These custom scopes of course would define their own ID to determine when and where they were active. Actually, I don't have a specific solution to implementing this in Seam -- just thinking out loud.

              Ryan

              • 4. Re: Suggestions on Scope
                Jens Weintraut Apprentice

                I could really use a CONTINOUS scope, too. Right now I'm trying to do this by @In @Out. But it doesn't work. I've two fields annotated with @In @Out. These fields were injected by another component and if I make a request on this component, Seam tells me it couldn't inject those fields, because a value was needed. So I would be happy with a CONTINOUS scope assuring that variables in this scope are available over several requests.

                • 5. Re: Suggestions on Scope
                  Magnus Sandberg Novice

                  Use @In(create=true) to have seam create it for you as needed.

                  • 6. Re: Suggestions on Scope
                    Jens Weintraut Apprentice

                    @emsa: "Specifies that a component should be instantiated if the context variable is null.". I want to keep the values of the fields. If I use @In(create=true) I don't get null any more, but the values are lost.

                    • 7. Re: Suggestions on Scope
                      Jens Weintraut Apprentice

                      The funny thing is, if I use @In(create=true) I get this:

                      In attribute requires value for component:


                      I wanna outject a field from Component A and inject it into Component B during a request. This works. From this time on, the injected field should keep its value during all the next requests. But because the value isn't in the context any more, Seam tries to inject null. So I've to use @In(required=false) to avoid the exception. But this way, Seam injects null, overwriting the existing value. To avoid this, I thought "Let's outject the field", and annotated it @Out. But it doesn't work. Seam furthermore tries to inject null.

                      • 8. Re: Suggestions on Scope
                        Gavin King Master

                         

                        "rdewell" wrote:
                        As long as we're on the topic, I could really use a scope that sits between Application and Session. I implemented a quasi-scope myself using an Application scoped bean + a Map, though it's not as clean as using a pure Seam scope.

                        This is a specific case I realize, but maybe it would be cool if we could have "custom scopes". These custom scopes of course would define their own ID to determine when and where they were active. Actually, I don't have a specific solution to implementing this in Seam -- just thinking out loud.


                        A "custom scope" is just a namespace inside one of the "true" scopes. Any component is a custom scope.