-
1. Re: why Factory method is calling more than once?
christian.bauer Oct 15, 2007 3:01 AM (in response to mnrz)Use a stateful context, not STATELESS...
-
2. Re: why Factory method is calling more than once?
mnrz Oct 15, 2007 5:20 AM (in response to mnrz)Hi Christian,
but if I alter the STATELESS to SESSION my problem will changed, because I have a combo box at the page and when the user change it the forms will be submitted and the information of the selected user should be displayed.
if I use the SESSION scope for the factory method, at first the user is instansiating as "new User()" and because the session is still alive, this factory method won't be called until the session is destroyed or the user is null so this won't resolve the problem
and if you meant changing my Session bean to a stateful context, I did it but problem still exists, it seems that being SFSB or SLSB has nothing to do with this factory method and the method will be called whenever the Seam needs it.
you know, if I remove the relaod=false; from the code everything is fine but the problem is when user is going to update the information the submitted values won't apply to tempUser because after submitting new values, Seam is calling this factory method and everything is turning to its first step!!!!
thank you in advance for your reply, any comment would be of a great help -
3. Re: why Factory method is calling more than once?
christian.bauer Oct 15, 2007 5:31 AM (in response to mnrz)Factory methods are not the right way to do what you want to do. There are many other ways, one would be an a:support on your select box that calls a loadUser() method on a backing component, which sets the user variable in the PAGE context.
-
4. Re: why Factory method is calling more than once?
mnrz Oct 16, 2007 1:38 AM (in response to mnrz)I did what you suggest, but <a:support> doesn't resolve my problem.
first off, after calling the loadUser() by a:support nothing will be displayed on page
second, apart from that, when the user clicks on the Save button, the form is submitting but the thing is that (it seems) Seam doesn't populate an object inside a SB from the request, does it?
after form submission, an exception is thrown that says the tempUser resolves to null, one way is to define instance variables in a SB instead of defining an object of type User but this makes your bean very untidy.
maybe I am mistaken but I'd like to know your idea.class MySessionBean { private User tempUser; // rest of the codes... }
andclass MySessionBean { private String username; private String password; private String userAddress; private String name; private String family; ... // rest of the codes... }
thanks