Hi,

Maybe it is a problem in your code ;-)

 <p>In case of session expiration this method is called in a non-worker
thread, i.e.
 * there are no thread locals exported for the Application, RequestCycle
and Session.
 * The Session is the current instance. The Application can be found by
using
 * {@link Application#get(String)}. There is no way to get a reference to a
RequestCycle</p>
 */
public void onInvalidate()
{
}

The javadoc clearly says that when this method is called by the web
container due to session expiration there are no thread locals.
The thread locals are available in #onInvalidate() only if the application
code called Session#invalidate[Now]() explicitly.

Martin Grigorov
Wicket Training and Consulting


On Thu, Mar 13, 2014 at 4:34 PM, Daniela L <danigal...@gmail.com> wrote:

> Hi Martin,
> if found the reason why the data is not freed in onInvalidate,
> the Spring/Hibernate update to the database issues a "There is no
> application attached to current thread
> ContainerBackgroundProcessor[StandardEngine[Catalina]]". Is this a wicket
> or a tomcat issue?
> Best Regards
> Daniela
>
>
> 2014-03-12 14:31 GMT+01:00 Martin Grigorov <mgrigo...@apache.org>:
>
> > On Wed, Mar 12, 2014 at 3:20 PM, Daniela L <danigal...@gmail.com> wrote:
> >
> > > Hi Martin,
> > > thank you very much for your quick and brilliant answer :-)
> > > Changing to AjaxCheckBox did the trick.
> > > It seems to be very difficult to provide a secure way to invalidate
> user
> > > data
> > > cross browser compliant. I noticed that using a tablet with android or
> > IOS
> > > the
> > > beforeunload is not triggered at all. Therefor I added a cleanup method
> > to
> > > the onInvalidate
> > > of my custom session which should be triggered by the tomcats
> > > session-timeout, but
> > > it seems using mobile devices onInvalidate is not triggered?
> > >
> >
> > onInvalidate() is called by the server when the client hasn't
> touched/used
> > its http session for session-timeout minutes.
> > It shouldn't matter whether it is a desktop or mobile client.
> >
> >
> > > Best Regards
> > > Daniela
> > >
> > >
> > > 2014-03-12 13:21 GMT+01:00 Martin Grigorov <mgrigo...@apache.org>:
> > >
> > > > Hi,
> > > >
> > > > On Wed, Mar 12, 2014 at 1:15 PM, Daniela L <danigal...@gmail.com>
> > wrote:
> > > >
> > > > > Hi,
> > > > > I am using a close browser behavior to clean up user data if the
> user
> > > > > closes
> > > > > the browser window. I also use a CheckBox to toggle the visibility
> of
> > > > some
> > > > > Textfields. Unfortunately the refresh through the click of the
> > CheckBox
> > > > > triggers the close browser
> > > > > behavior. How can this be avoided?
> > > > > Here is what I did (with wicket 6.12.0):
> > > > >
> > > > >
> > > > > customerFirstName = new
> > > RequiredTextField<String>("customer.firstName");
> > > > > customerFirstName.setOutputMarkupPlaceholderTag(true);
> > > > > closeBrowserBehavior =  new AbstractDefaultAjaxBehavior() {
> > > > >            @Override
> > > > >             protected void respond(AjaxRequestTarget target) {
> > > > >
> > > > > AppointmentSession.get().releaseSavedBlockedFreeCalendarEvent();
> > > > >             }
> > > > >
> > > > >             @Override
> > > > >             public void renderHead(Component component,
> > IHeaderResponse
> > > > >                     response) {
> > > > >                 super.renderHead(component, response);
> > > > >                 response.render(new
> > > > >
> OnDomReadyHeaderItem("window.onbeforeunload =
> > > > > function (e) {"
> > > > >                                 + "if (!window.dontAsk) {"
> > > > >                                 + "Wicket.Ajax.get({u:
> > > > > '"+getCallbackUrl()+"', async: false});"
> > > > >                                 + "var message = 'my message.',"
> > > > >                                 + "e = e || window.event;" + "if
> (e)
> > {"
> > > > >                                 + "e.returnValue = message;" +
> "}}" +
> > > > > "return message;"
> > > > >                                 +
> > > > >                                 "};"));
> > > > >             }
> > > > >         };
> > > > > customerFirstName.add(closeBrowserBehavior);
> > > > > form.add(customerFirstName);
> > > > >
> > > > > createAccountCB = new CheckBox("createAccountCB", new
> > > > > Model<Boolean>(createAccount)){
> > > > >             @Override
> > > > >             protected void onSelectionChanged(Boolean
> newSelection) {
> > > > >                 super.onSelectionChanged(newSelection);
> > > > >                 createAccount = !createAccount;
> > > > >             }
> > > > >
> > > > >             @Override
> > > > >             protected boolean wantOnSelectionChangedNotifications()
> > > > >             {
> > > > >                 return true;
> > > > >
> > > >
> > > > This uses non-Ajax way to submit the new selection.
> > > > As you noted this leads to 'beforeunload' event being fired.
> > > >
> > > > You will have to use AjaxCheckBox or
> AjaxFormComponentUpdatingBehavior
> > to
> > > > avoid the page reload.
> > > >
> > > >
> > > > >             }
> > > > >         };
> > > > > form.add(createAccountCB);
> > > > >
> > > > > emailRepeat = new TextField<String>("emailRepeat", new
> > > > > PropertyModel<String>(appointCalendar, customer.eMailAdress")){
> > > > >           @Override
> > > > >             protected void onConfigure(){
> > > > >                 super.onConfigure();
> > > > >                 setVisibilityAllowed(createAccount);
> > > > >             }
> > > > >             }
> > > > >         };
> > > > > emailRepeat.setOutputMarkupPlaceholderTag(true);
> > > > > form.add(emailRepeat):
> > > > >
> > > > > Thanks a lot in advance!
> > > > > Best Regards
> > > > > Daniela
> > > > >
> > > >
> > >
> >
>

Reply via email to