Re: AjaxEditableLabel causes exceptions after session timeout

2012-09-22 Thread Ondřej Žižka
Martin Grigorov píše v Út 18. 09. 2012 v 10:02 +0300:

 Hi,
 
 See https://issues.apache.org/jira/browse/WICKET-4594
 The problem is that Wicket cannot differentiate between page
 parameters and ajax request parameters 

Maybe Wicket could off-load some of the AJAX params to headers?
xmlhttp.setRequestHeader(Wicket-AJAX-param,foo=bar);
Disclaimer: Just an idea, might be nonsense.



 and in case of page re-creation
 all of them were used as page parameters for the new page instance.
 When a page is automatically re-created due to expiration the callback
 method (like onClick, onChange, etc) is not executed because the
 component/behavior may not be visible/enabled in the page's initial
 state. So the page is recreated and rendered in its initial state, no
 callbacks are executed at all.
 
 The whole thing started as simple feature request in WICKET-4014 but
 since then it causes only problems ... :-/
 
 On Tue, Sep 18, 2012 at 4:49 AM, Ondrej Zizka ozi...@redhat.com wrote:
 
 
   Is there a mechanism to let the page be re-created with the original
   PageParameters?
   Maybe they could be kept within JS of the page and sent with the AJAX
   request?  That would probably need a change in Wicket's AJAX code.
   (Wicket 1.5)
 
  That was the case until recently but there was no way to differentiate
  between original page parameters and custom request parameters for the
  Ajax request itself. So we took the safest way by dropping all
  parameters when a page is being auto-recreated.
 
 
  Could this be made optional?  Because, in case the developer knows that
  the URL has all the data the page needs to be recreated, he could
  setSendPageParametersOnAjaxRequests(true) or such... That would make
  life with Ajax components easier... would it? :-)
  Or maybe I don't get this fully, as I don't know the Wicket internals...
  in which case, I believe you there was no way.  If you have a minute,
  could you briefly explain that or point me to some wiki?
 
  Thanks.
  Ondra
 
 
 




Re: AjaxEditableLabel causes exceptions after session timeout

2012-09-18 Thread Martin Grigorov
Hi,

See https://issues.apache.org/jira/browse/WICKET-4594
The problem is that Wicket cannot differentiate between page
parameters and ajax request parameters and in case of page re-creation
all of them were used as page parameters for the new page instance.
When a page is automatically re-created due to expiration the callback
method (like onClick, onChange, etc) is not executed because the
component/behavior may not be visible/enabled in the page's initial
state. So the page is recreated and rendered in its initial state, no
callbacks are executed at all.

The whole thing started as simple feature request in WICKET-4014 but
since then it causes only problems ... :-/

On Tue, Sep 18, 2012 at 4:49 AM, Ondrej Zizka ozi...@redhat.com wrote:


  Is there a mechanism to let the page be re-created with the original
  PageParameters?
  Maybe they could be kept within JS of the page and sent with the AJAX
  request?  That would probably need a change in Wicket's AJAX code.
  (Wicket 1.5)

 That was the case until recently but there was no way to differentiate
 between original page parameters and custom request parameters for the
 Ajax request itself. So we took the safest way by dropping all
 parameters when a page is being auto-recreated.


 Could this be made optional?  Because, in case the developer knows that
 the URL has all the data the page needs to be recreated, he could
 setSendPageParametersOnAjaxRequests(true) or such... That would make
 life with Ajax components easier... would it? :-)
 Or maybe I don't get this fully, as I don't know the Wicket internals...
 in which case, I believe you there was no way.  If you have a minute,
 could you briefly explain that or point me to some wiki?

 Thanks.
 Ondra



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AjaxEditableLabel causes exceptions after session timeout

2012-09-17 Thread Martin Grigorov
Hi,

Usage of Wicket's Ajax behaviors make the page stateful, so there is
no easy way to make it stateless.
The easiest solution is to use
org.apache.wicket.settings.IPageSettings#setRecreateMountedPagesAfterExpiry(false).
This way you'll see the configured
org.apache.wicket.settings.IApplicationSettings#getPageExpiredErrorPage()
instead of a new instance of your page.

On Mon, Sep 17, 2012 at 5:23 AM, Ondrej Zizka ozi...@redhat.com wrote:
 Hi,

 I use a AjaxEditableLabel with a PropertyModel which points to an object
 of the Page.
 But after the session expires, clicking on the label to edit it causes
 exception because the object of the page is empty (in my case, it
 results into HBN's NoResultException).

 What's the way to handle this?

 The page is mounted as /product/${name}/${version}, so the URL contains
 the information necessary to reload the entire page. So perhaps I could
 use some LoadableDetachableModel somehow?
 I've read about making the page stateless. Would that help?

 Thanks,
 Ondra



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AjaxEditableLabel causes exceptions after session timeout

2012-09-17 Thread Ondrej Zizka
Ok, thanks. I set
this.getPageSettings().setRecreateMountedPagesAfterExpiry(false); in the
app class.
But, to my previous point:

The page is mounted and reached with all the necessary data (to get the
entity).
But on AjaxEditableLabel interaction, the page is created with empty
PageParameters.

   Last cause: No entity found for query 

   WicketMessage: Can't instantiate page using constructor 'public 
org.jboss.essc.web.pages.ReleasePage(org.apache.wicket.request.mapper.parameter.PageParameters)'
 
   and argument ''. Might be it doesn't exist, may be it is not visible 
(public).


Is there a mechanism to let the page be re-created with the original
PageParameters?
Maybe they could be kept within JS of the page and sent with the AJAX
request?  That would probably need a change in Wicket's AJAX code.
(Wicket 1.5)

And also, this brings me to other question - how can I control session
programatically? I have seen some pages, old ones, and mostly they do a
timer-based ajax request on a page to keep the session alive.
Is that a best practice?  (Assuming I want to keep the session short for
other pages).

Thanks,
Ondra






On Mon, 2012-09-17 at 10:50 +0300, Martin Grigorov wrote:

 Hi,
 
 Usage of Wicket's Ajax behaviors make the page stateful, so there is
 no easy way to make it stateless.
 The easiest solution is to use
 org.apache.wicket.settings.IPageSettings#setRecreateMountedPagesAfterExpiry(false).
 This way you'll see the configured
 org.apache.wicket.settings.IApplicationSettings#getPageExpiredErrorPage()
 instead of a new instance of your page.
 
 On Mon, Sep 17, 2012 at 5:23 AM, Ondrej Zizka ozi...@redhat.com wrote:
  Hi,
 
  I use a AjaxEditableLabel with a PropertyModel which points to an object
  of the Page.
  But after the session expires, clicking on the label to edit it causes
  exception because the object of the page is empty (in my case, it
  results into HBN's NoResultException).
 
  What's the way to handle this?
 
  The page is mounted as /product/${name}/${version}, so the URL contains
  the information necessary to reload the entire page. So perhaps I could
  use some LoadableDetachableModel somehow?
  I've read about making the page stateless. Would that help?
 
  Thanks,
  Ondra
 
 
 




Re: AjaxEditableLabel causes exceptions after session timeout

2012-09-17 Thread Martin Grigorov
On Mon, Sep 17, 2012 at 5:59 PM, Ondrej Zizka ozi...@redhat.com wrote:
 Ok, thanks. I set
 this.getPageSettings().setRecreateMountedPagesAfterExpiry(false); in the
 app class.
 But, to my previous point:

 The page is mounted and reached with all the necessary data (to get the
 entity).
 But on AjaxEditableLabel interaction, the page is created with empty
 PageParameters.

Last cause: No entity found for query

WicketMessage: Can't instantiate page using constructor 'public 
 org.jboss.essc.web.pages.ReleasePage(org.apache.wicket.request.mapper.parameter.PageParameters)'
and argument ''. Might be it doesn't exist, may be it is not visible 
 (public).


 Is there a mechanism to let the page be re-created with the original
 PageParameters?
 Maybe they could be kept within JS of the page and sent with the AJAX
 request?  That would probably need a change in Wicket's AJAX code.
 (Wicket 1.5)

That was the case until recently but there was no way to differentiate
between original page parameters and custom request parameters for the
Ajax request itself. So we took the safest way by dropping all
parameters when a page is being auto-recreated.


 And also, this brings me to other question - how can I control session
 programatically? I have seen some pages, old ones, and mostly they do a
 timer-based ajax request on a page to keep the session alive.
 Is that a best practice?  (Assuming I want to keep the session short for
 other pages).

I am not aware of another way to do this.


 Thanks,
 Ondra






 On Mon, 2012-09-17 at 10:50 +0300, Martin Grigorov wrote:

 Hi,

 Usage of Wicket's Ajax behaviors make the page stateful, so there is
 no easy way to make it stateless.
 The easiest solution is to use
 org.apache.wicket.settings.IPageSettings#setRecreateMountedPagesAfterExpiry(false).
 This way you'll see the configured
 org.apache.wicket.settings.IApplicationSettings#getPageExpiredErrorPage()
 instead of a new instance of your page.

 On Mon, Sep 17, 2012 at 5:23 AM, Ondrej Zizka ozi...@redhat.com wrote:
  Hi,
 
  I use a AjaxEditableLabel with a PropertyModel which points to an object
  of the Page.
  But after the session expires, clicking on the label to edit it causes
  exception because the object of the page is empty (in my case, it
  results into HBN's NoResultException).
 
  What's the way to handle this?
 
  The page is mounted as /product/${name}/${version}, so the URL contains
  the information necessary to reload the entire page. So perhaps I could
  use some LoadableDetachableModel somehow?
  I've read about making the page stateless. Would that help?
 
  Thanks,
  Ondra








-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AjaxEditableLabel causes exceptions after session timeout

2012-09-17 Thread Ondrej Zizka


  Is there a mechanism to let the page be re-created with the original
  PageParameters?
  Maybe they could be kept within JS of the page and sent with the AJAX
  request?  That would probably need a change in Wicket's AJAX code.
  (Wicket 1.5)
 
 That was the case until recently but there was no way to differentiate
 between original page parameters and custom request parameters for the
 Ajax request itself. So we took the safest way by dropping all
 parameters when a page is being auto-recreated.


Could this be made optional?  Because, in case the developer knows that
the URL has all the data the page needs to be recreated, he could
setSendPageParametersOnAjaxRequests(true) or such... That would make
life with Ajax components easier... would it? :-)
Or maybe I don't get this fully, as I don't know the Wicket internals...
in which case, I believe you there was no way.  If you have a minute,
could you briefly explain that or point me to some wiki?

Thanks.
Ondra


AjaxEditableLabel causes exceptions after session timeout

2012-09-16 Thread Ondrej Zizka
Hi,

I use a AjaxEditableLabel with a PropertyModel which points to an object
of the Page.
But after the session expires, clicking on the label to edit it causes
exception because the object of the page is empty (in my case, it
results into HBN's NoResultException).

What's the way to handle this?

The page is mounted as /product/${name}/${version}, so the URL contains
the information necessary to reload the entire page. So perhaps I could
use some LoadableDetachableModel somehow?
I've read about making the page stateless. Would that help?

Thanks,
Ondra