Hi Lasitha, Here is how I handle this. Again, I'm not sure if it's best practice, I'd be interested in comments:
1) In @PageAttached, I NULL out entity. 2) In OnActivate() (which is executed a few times), I set entity to a new, empty Entity (useful if this page was called with no primary key, to create a new entity) 3) In OnActivate( Integer PrimaryKey ), I use DataStore to populate entity--I think this is only executed once Andy On Fri, 2007-11-23 at 13:34 +0530, lasitha wrote: > On Nov 23, 2007 4:29 AM, Angelo Chen <[EMAIL PROTECTED]> wrote: > > > > lasitha wrote: > > > > > > Since the above events fire on both the original request and the one > > > from the redirect, you'll probably need a null check to differentiate: > > > > can you explain more about about this null > > check, any example why we have to check? thanks. > > I should say first that i'm not sure this is best practice. It's sort > of obvious, rudimentary and not particularly elegant - if there's a > better way i hope someone will point it out. > > @Persist("flash") Entity entity; > @Inject private Datastore datastore; > void onPrepare() { > if(entity == null) > entity = datastore.loadEntity(); > else > datastore.reattach(entity); > } > > * Datastore is my data-access service and reattach() just facades > Session.lock(). > * As i mentioned earlier, onPrepare() is one of a few places you might > do this. I'd say as a general rule, the earlier in the request, the > better. > > Cheers, lasitha > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]