7 Replies Latest reply on Nov 30, 2006 11:44 PM by Gavin King

    @Out and default ScopeType

    Andrew Apprentice

      I have a question regarding @Out and its use without the scope parameter.


      ScopeType.UNSPECIFIED: Indicates that the scope is implied.

      So, I assumed wrongly that this would use the scope of the managed bean that it is in:

      public class MyBean
       @Out(required=false, value="someJsfName")
       private SomeObject myobject;

      I thought that given the JavaDoc that "someJsfName" should be stored in the conversation, but it doesn't seem to be. When I posted back, the variable was not set in the APPLY_REQUEST_VALUES phase. This leads me to think the default is acually EVENT in behavior. When I explicitly set "scope=ScopeType.CONVERSATION" it worked fine.

      The documentation on the @Out attribute doesn't really say what the default is.

      What is the bevaiour, and if I may suggest, can this be updated in the documentation (both JavaDoc and the manual)?


        • 1. Re: @Out and default ScopeType
          Gavin King Master

          The default behavior has changed in Seam 1.1, so that it would behave the way you describe. And the JavaDoc now specifies the rules clearly.

          • 2. Re: @Out and default ScopeType
            Andrew Apprentice

            Great news. Thank you. Can't wait for 1.1, looks like it has a lot of nice new functionality

            • 3. Re: @Out and default ScopeType
              Dan Allen Master

              Gavin et al,

              I am still a bit confused about which scope to use for the @Out annotation. Let me provide a brief example and hopeful it demonstrates my misunderstanding.

              I have the following stub backing bean:

              @Name( "userManager" )
              public class UserManagerBean {
               @In( required = false )
               @Out( required = false, scope = CONVERSATION )
               private User user;
               public String create() {
               return "/user/new.jspx";
               public String view() {
               return "/user/view.jspx";
               public String save() {
               assert user != null;
               // do whatever to save...
               return view();
               // ...other supporting methods, including @Begin and @End methods

              Assume that the flow is: request create -> enter info -> save -> view and that the conversation is being created around this process by some other methods (meaning I know that I have a working conversation).

              I am curious to know why I need ScopeType.CONVERSATION on the @Out annotation. The assertion in the save() method passes, so I know at that point that the property "user" does indeed have a value. However, if I don't set the scope on the @Out annotation, by the time I get to view.jspx, the EL variables that reference "user" (such as #{user.name}) are all empty.

              Is it always necessary to use ScopeType.CONVERSATION for the @Out annotation if the component itself is in conversation scope?

              • 4. Re: @Out and default ScopeType
                Dan Allen Master

                I suppose I should also mention that in this case, the "user" is also annotated with @DataModelSelection.

                • 5. Re: @Out and default ScopeType
                  Gavin King Master

                  In Seam 1.1, @Out defaults to the scope of the component with the annotation when the thing being outjected is not a Seam component. So no, you do not need it, at least not in 1.1.

                  • 6. Re: @Out and default ScopeType
                    Dan Allen Master

                    I understand my problem. In this particular case, my entity being outjected is a Seam component but not marked with a scope. Therefore, it is taking on the default EVENT scope. If I don't specify the scope on the @Out annotation, my data is placed in the event context, and thus the data does not survive past the redirect. If I add @Scope(CONVERSATION) atop the User class, then it works as expected.

                    So the point is that it is required to add @Scope(CONVERSATION) either on the entity or on the scope attribute of the @Out annotation for the data to be included in the conversation context if the data IS a seam component. If the User class was not a Seam component, then it would default to the scope of the component outjecting the data. I managed to find myself right between the two scenarios, and hence out of luck.

                    • 7. Re: @Out and default ScopeType
                      Gavin King Master

                      Correct, but the defaulting rules changed in Seam 1.1. You would not need to explicitly specify CONVERSATION in 1.1.