-
1. Re: Proper way to clear or recompute a @Factory generated value?
hasan_muhstaq Aug 14, 2008 12:38 PM (in response to tynor.stynor.gmail.com)The proper way to recompute a Factory is to set the associated object to NULL. For Example
@Out private Object currentUser; public void myMethod(){ currentUser = null; }
Calling the method myMethod would automaticaly provoke the factory.
The problem is that in our application, the currentUser factory method might be invoked before we have authenticated the user and outjected the currentUserId keyI think the Factory currentUser should not be provoked at the first place
-
2. Re: Proper way to clear or recompute a @Factory generated value?
tynor.stynor.gmail.com Aug 15, 2008 6:02 PM (in response to tynor.stynor.gmail.com)FWIW, outjection does not work for this case - it appears to happen too late. In our case, we are trying to reset the user inside Authenticator.authenticate() as soon as we know who the authenticated user is. If we don't explicitly clear the contexts as I described (and in fact, also clear the currentUserId), then the view rendered after the authentication still sees the
pre outjected
value for currentUserId and the factory recomputes the same 'anonymous' User object for the view.public boolean authenticate() { ... // HACK: this needs to be in the session before normal outjection makes it available, so we do it explicitly. Contexts.getSessionContext().set("currentUserId", currentUserId); // Reset the CurrentUserHome to recompute the factory method for the user: currentUserHome.clearInstance(); Contexts.getConversationContext().set("currentUser", null); return true; }
I still think this feels
wrong
, but it's the only thing we've found to work.Thanks,
Steve -
3. Re: Proper way to clear or recompute a @Factory generated value?
kvk.vijay.koppuravuri.aero.bombardier.com Aug 15, 2008 7:00 PM (in response to tynor.stynor.gmail.com)How about using events
'
@In
private Events events;@Factory
@Observer(xxx)
public void getxxx(){}
public void myMethod(){
currentUser = null;
events.raiseXXXEvent(...);
}
'