[jboss-user] [JBoss Seam] - Re: Bug? Outjected boolean changes value mid-template

tomstrummer do-not-reply at jboss.com
Thu Feb 7 11:51:19 EST 2008

Hi Pete -- thanks for your reply.  

"pete.muir at jboss.org" wrote : 1) If you have an @Stateless bean it can't have any fields on it. read about what @Stateless *really* means (this probably explains your values changing)

I understand that I can't keep state in my SLSB, but I thought the point was that you could biject stateful values into your SLSBs.  See http://books.google.com/books?id=h1madTvupB8C&pg=PA162&vq=listing+6-2&sig=gedSD8Cnzsm8Oj-tDxPWs7pmvkk

"pete.muir at jboss.org" wrote : 
  | 2) This is because you are outjecting into EVENT scope. So, the process is this whilst rendering the page
  | Try to access boolean value, not in context, so null and so on
  | Render datatable, initialized by @Factory on seam component as boolean value. component does outjection including boolean value,
  | Try to access boolean value, now in context.

I can understand that it is null at the beginning of the request (since there is no @Factory for it) but if the value is not explicitly set in an action, the value should remain null.  That is, I would expect Seam's bijection mechanism to say "oh this value was set on a previous request so it is out of scope now" rather than suddenly finding the value when a totally different context variable is asked for from the context.  

So I think I understand -- the SLSB is actually maintaining state even though bijection would make it seem that it is not so.  It would seem to me that bijection is broken by design unless a factory is not specified for each and every bijected field.  No?  

This does happen just the same if the fields are PAGE scoped -- i.e. the value is set to true, go to a different page, come back, and the same  behavior (null, then old stale value) appears.  I imagine it would also happen as well for a SFSB -- Say you have a session-scoped SFSB, and say an @Out(scope=PAGE) List myList.  If I don't have a factory for myList, and instead initialize the list on some action.  Then leave this page and come back...  I'll see the list again after something else wakes up that SFSB?  If that is the case I would argue that it is broken.

More to the point, how would you get around this issue?  How would you toggle a flag to show a simple form that you want to automatically reset if the user leaves the page or does something else?  
* Put an auto-action in pages.xml to reset everything?  That seems annoying but doable (I have a number of pages that use this pattern)

* Use a conversation?  It seems like overkill for just one stateful flag.  And if they do _anything_ else, I have to make sure that conversation ends, no?   How do I make sure the conversation ends if they decide to do something totally unrelated to the conversation?  

* Create a factory that simply returns null or false in order to reset the value?  I'm guessing the factory will definitely be called when the value is re-referenced after it goes out of scope!?!  But it turns out in my non-simplified, real world code I actually have two flags for different forms, and then two more flags for whether or not they are new or updated domain objects.  So suddenly I have to create four factories just initialize a couple of boolean fields.  This is annoying.  

What if Seam had some sort of implicit "null factory" that would automatically reset bijected values that went out of scope?  That would fix my problem.  

What do you think?  I'm dealing with such a simple state that all of Seam's state management mechanisms are overkill.  It seems to be making things harder, whereas if I was using an MVC framework, I would just put a showForm:true flag in my model, which of course is gone after the response is rendered. 



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127486#4127486

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127486

More information about the jboss-user mailing list