3 Replies Latest reply on Jul 11, 2010 9:34 AM by wu haixing

    seam-faces view scope problems

    Aleksandar Pejovic Newbie


      While using seam-faces I’ve identified the following problems with the view scope

      1. View scope should behave like normal scope, but client proxies aren’t being used. For example, consider the case in which we have two views which are referencing a request scoped bean, which in turn is referencing a view scoped bean. Now, if we navigate from view1 to view2, I would expect that during a render response phase of current request, a request scoped bean would hold a reference to a bean from newly created view scope (view2), but that’s not the case. At the moment it will still hold a reference to a bean from the old view scope (view1) and since that bean was destroyed (@PreDestroy was fired) that’s clearly wrong.

      1. View scoped beans should be passivation capable, but the container isn’t enforcing that.

      1. @ViewScoped annotation target problem as I already noted here

      It appears that all of these problems are related to the reuse of @javax.faces.bean.VeiwScoped annotation. Namely, when I rebuilt seam-faces with the custom @ViewScoped annotation, view scope worked flawlessly.

      I've used the following @ViewScoped annotation implementation:

      import java.lang.annotation.Documented;
      import java.lang.annotation.ElementType;
      import java.lang.annotation.Inherited;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;
      @Target(value = {ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
      @Retention(value = RetentionPolicy.RUNTIME)
      public @interface ViewScoped {

      This is basicaly the same as the one on the following blog entry (also referenced from the seam-faces desing notes). As can be seen it is using correct @Target and what is more important it is annotated with @NormalScope. Now, the view scope extension is adding view scope with normal and passivating set to true, but it seems that without using @NormalScope it isn't working.

      So, I guess that we'll need to introduce new annotations (@FlashScoped is probably suffering from similar problems, but I haven't used it) or find another workaround. :)