If I understood your use correctly, this approach won't work if there are two users using the application concurrently - you would overwrite one's application-scoped object with another.... Right? There is only one application per application - not per session.
-- Jeremy Thomerson http://www.wickettraining.com On Mon, Aug 25, 2008 at 6:04 AM, Marvan Spagnolo <[EMAIL PROTECTED]> wrote: > Hi all, I'm new to Wicket and developing my first Wicket website. > I have some temporary objects created inside a users' session but needed by > a parallel process which uses them > outside the user session and I would like to avoid temporarily persisting > them into a database. > > I'm looking at using application scope objects but I'm not sure how to do > it > best > in Wicket. > > I guess I should override the get() method of WebApplication > mimicking the pattern used for custom Session objects. > > public class WicketApplication extends MyWebApplication > { > private Object applicationScopeObject; > > public WicketApplication() { > setApplicationScopeObject( <init value> ); > } > @Override > public static WicketApplication get() { > return (WicketApplication) WebApplication.get(); > } > public Object getApplicationScopeObject(){ > return this.applicationScopeObject; > } > public void setApplicationScopeObject( Object applicationScopeObject ){ > this.applicationScopeObject = applicationScopeObject; > } > [...] > } > > public class PageInsideUserSession > { > public PageInsideUserSession(){ > [...] > // object has already been initialized > WicketApplication.get().setApplicationScopeObject( object ); > } > } > > public class PageOutsideUserSession > { > public PageOutsideUserSession(){ > Object object = WicketApplication.get().getApplicationScopeObject(); > [...] > } > } > > In my case synchronizing the access to the application scope object should > not be needed. > > Is this approach correct (and efficient) or is there a better solution ? > Should I maybe use a separate parent class (parent of WicketApplication and > child of WebApplication) for > overriding the get() method (in case the override interferes with something > else in the framework) ? > > Cheers, > > Marvan > > -- > Reza Marvan Spagnolo > SW Engineer - Freelancer >