Question

I am trying to understand what happens when a page is closed in Wicket. I want to be able to check if a user is running a long batch load, that they cannot open another instance of the application to run another batch job. I was going to set a boolean in the session, and then change it when the page is closed by the user. I was doing some hunting and nothing pops out. The only methods I thought to override were:

onDetach() and onRemove() but none of those seemed to work.

protected void onDetach()
{
   System.out.println("called inside onDetach()");  
   super.onDetach();
}

Seems to work, except this method also seems to get called twice on page render

Was it helpful?

Solution

All detach() methods on any Component, RequestCycle, Session are called eachtime Wicket decides to remove/finish it. In most cases it means, that rendering is finished and response is prepared to send back to the browser. The main idea of detaching is to detach anything that needn't persist in memory.

There is no definition on calling detach just once. It can be called so many times as required.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top