0 Replies Latest reply on Aug 21, 2006 12:57 PM by Joe DeStefano

    Mysteriously vanishing value

    Joe DeStefano Newbie

      Hi all,

      I'm so confused I'm not sure how to describe this problem. I'll do my best, and I appreciate any pointers you can give me on where to look for the solution.

      I am outjecting a list from a Stateful Session-scoped component. The list is created in a factory method:

       @Out(required = false)
       List<Group> allGroups;
       public void loadGroups()
       log.debug("Loading groups");
       allGroups =
       em.createQuery("select g from Group g where g.user = :user order by g.name")
       .setParameter("user", user)
       log.debug("After loading, allGroups is " + allGroups);

      There are two ways of beginning a conversation in this component, one that creates a new entity, and one that uses the entity from the previous view's DataModelSelection:

       @Begin(nested = true)
       public String select() {
       return "editSubscriber";
       @Begin(nested = true)
       public String create() {
       setSubscriber(new Subscriber());
       return "editSubscriber";

      Both display the same view, which accesses allGroups, causing the factory method to be called. In both cases, the displayed list of groups is the same.

      I do nothing but cancel out of that view in either case, calling this method:
       public String cancel() {
       log.debug("allGroups is " + allGroups);
       if (!isNew)
       return "done";

      If I started via select(), the output from both debug statements (in loadGroups and cancel) is the same, i.e., the correct list of groups. If I started via create(), the loadGroups output is correct (same as in select() case), but the output from cancel says "allGroups is null".

      This difference causes problems in my app when something other than cancel is selected, and I need to access the allGroups list. I'm showing you the example using cancel, since it displays the problem and is cleaner to describe.

      I've hacked around in org.jboss.seam.Component to see if allGroups is getting reset somehow, but found nothing. I checked to see if multiple instances of the component are being created, but they are not. I verified that the component is not being serialized and then multiply deserialized. I created a field access aspect to see if it's being overwritten from some code I didn't think of checking, but it isn't.

      I am at a complete loss. Does anyone have any idea where I can look next to figure this out?