You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by John Patterson <jd...@gmail.com> on 2007/10/29 23:22:19 UTC
AutoCompleteTextField excessive serialisation
Hi,
I am using the AutoCompleteTextField and can see that every keystroke
causes the entire page to be serialised and stored which seems a bit
excessive. Is there anyway to say that the page has not changed and
so don't store it?
John
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AutoCompleteTextField excessive serialisation
Posted by Johan Compagner <jc...@gmail.com>.
Maybe for very specific ajax cases that could work
But most of the cases ajax updates state on the server side
that is then translated again to the client.
If there is anything for example that is replaced or created new a none
stateless page wouldnt work
because you can't recreate the exact same page
the auto complete could be the exception if the only thing that is its input
is the field itself.
johan
On 10/30/07, John Patterson <jd...@gmail.com> wrote:
>
> Nope. It looks like the logic to store the page is in
> SEcondLevelCacheSessionStore and it always stores pages that were
> 'touched' that are not stateless.
>
>
> if (!page.isPageStateless())
> {
> String sessionId = getSession().getId();
> if (sessionId != null)
> {
> getStore().storePage(sessionId,
> page);
> setLastPage(page);
> dirty();
> }
> }
>
> I think I need a BookmarkableBehaviorRequestTarget which doesn't seem
> to exist.
>
> It seems to me that AJAX behaviours could work with stateless pages
> and the back button if there was a behaviour equivalent of
> BookmarkableListenerInterfaceRequestTarget which would create the
> page if it did not exist and then call the behaviour.
>
> I was thinking about having a shot at it myself but can see all the
> places in the code that refer to
> BookmarkableListenerInterfaceRequestTarget and thought it would be
> better to leave it to someone who knows the code better.
>
> John
>
> On 29 Oct 2007, at 16:56, Igor Vaynberg wrote:
>
> > autocomplete.setversioned(false) do it?
> >
> > -igor
> >
> >
> > On 10/29/07, John Patterson <jd...@gmail.com> wrote:
> >> Hi,
> >>
> >> I am using the AutoCompleteTextField and can see that every keystroke
> >> causes the entire page to be serialised and stored which seems a bit
> >> excessive. Is there anyway to say that the page has not changed and
> >> so don't store it?
> >>
> >> John
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
>
Re: AutoCompleteTextField excessive serialisation
Posted by John Patterson <jd...@gmail.com>.
Nope. It looks like the logic to store the page is in
SEcondLevelCacheSessionStore and it always stores pages that were
'touched' that are not stateless.
if (!page.isPageStateless())
{
String sessionId = getSession().getId();
if (sessionId != null)
{
getStore().storePage(sessionId, page);
setLastPage(page);
dirty();
}
}
I think I need a BookmarkableBehaviorRequestTarget which doesn't seem
to exist.
It seems to me that AJAX behaviours could work with stateless pages
and the back button if there was a behaviour equivalent of
BookmarkableListenerInterfaceRequestTarget which would create the
page if it did not exist and then call the behaviour.
I was thinking about having a shot at it myself but can see all the
places in the code that refer to
BookmarkableListenerInterfaceRequestTarget and thought it would be
better to leave it to someone who knows the code better.
John
On 29 Oct 2007, at 16:56, Igor Vaynberg wrote:
> autocomplete.setversioned(false) do it?
>
> -igor
>
>
> On 10/29/07, John Patterson <jd...@gmail.com> wrote:
>> Hi,
>>
>> I am using the AutoCompleteTextField and can see that every keystroke
>> causes the entire page to be serialised and stored which seems a bit
>> excessive. Is there anyway to say that the page has not changed and
>> so don't store it?
>>
>> John
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
Re: AutoCompleteTextField excessive serialisation
Posted by Johan Compagner <jc...@gmail.com>.
no we didn't do that at first, the last page wasn't serialized only when it
didn't because the last page anymore
but that had some problems for example. We have to serialize the page before
another request makes a new version..
so every request we just have to snapshot it.
johan
On 10/30/07, Eelco Hillenius <ee...@gmail.com> wrote:
>
> On 10/29/07, Matej Knopp <ma...@gmail.com> wrote:
> > I doubt it would prevent the page from being serialized. Versioning
> > doesn't spot all changes to page (e.g. setting a property) so we can't
> > rely on it, therefore we serialize it on every request.
> >
> > However, if you really want to get around the serialization for certain
> > cases, you need to call Session.untouch(page) before
> > Session.requestDetached() is called.
> >
> > I think calling it from Page.onDetach() should work. So you can set a
> > request cycle metadata if you don't want the page to be serialized and
> > then check for the meta data in page.onDetach().
>
> Is this really just that component that causes the page to serialize?
> Sounds like a design flaw to me if that is the case...
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: AutoCompleteTextField excessive serialisation
Posted by Johan Compagner <jc...@gmail.com>.
On 10/30/07, John Patterson <jd...@gmail.com> wrote:
>
>
> On 29 Oct 2007, at 17:37, Eelco Hillenius wrote:
> /
> Also, I was surprised to find that instances of image were stateful
> if I used the constructor Image(String, String) and I had to override
> the getStatelessHint.
yes that looks like a bug
because i you just give a path then this is called:
loadStaticImage(component.getModelObjectAsString());
that makes a ResourceReference
but in bind() we also create again the resource:
// Then dereference the resource
resource = resourceReference.getResource();
thats a bit weird why we do that there.
because the resource shouldn't be used if there is a resource reference,
because
the url to the shared resource is generated:
*
if* (resourceReference != *null*)
{
// Create URL to shared resource
url = RequestCycle.*get*().urlFor(resourceReference, resourceParameters);
}
i guess the:
*public* *final* *boolean* isStateless()
{
*return* resource == *null*;
}
could be reversed: return resourceReference != null
Re: AutoCompleteTextField excessive serialisation
Posted by John Patterson <jd...@gmail.com>.
On 29 Oct 2007, at 17:37, Eelco Hillenius wrote:
>>
>
> Is this really just that component that causes the page to serialize?
> Sounds like a design flaw to me if that is the case...
>
> Eelco
Definitely just that component causing the page to be marked
stateful. An auto complete field is not _really_ stateful but the
way it has been implemented using DefaultAjaxBehaviour which
typically change the state of the page.
Also, I was surprised to find that instances of image were stateful
if I used the constructor Image(String, String) and I had to override
the getStatelessHint.
Re: AutoCompleteTextField excessive serialisation
Posted by Matej Knopp <ma...@gmail.com>.
We serialize the page every time it's touched. And the page is touched
every request. There is no easy way to determine whether a page jas
changed during the request, so we just serialize it. Otherwise we would
have to traverse the entire object tree and check every property for
being changed. Kinda overkill, don't you think?
In next version of wicket we should have this simplyfied, so that it is
much easier to tell wicket not to serialize the page in cases when the
page doesnt' change and the serialization would cause unnecessary
overhead, such as some ajax polls or autocomplete requests.
-Matej
Eelco Hillenius wrote / napísal(a):
> On 10/29/07, Matej Knopp <ma...@gmail.com> wrote:
>> I doubt it would prevent the page from being serialized. Versioning
>> doesn't spot all changes to page (e.g. setting a property) so we can't
>> rely on it, therefore we serialize it on every request.
>>
>> However, if you really want to get around the serialization for certain
>> cases, you need to call Session.untouch(page) before
>> Session.requestDetached() is called.
>>
>> I think calling it from Page.onDetach() should work. So you can set a
>> request cycle metadata if you don't want the page to be serialized and
>> then check for the meta data in page.onDetach().
>
> Is this really just that component that causes the page to serialize?
> Sounds like a design flaw to me if that is the case...
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AutoCompleteTextField excessive serialisation
Posted by Eelco Hillenius <ee...@gmail.com>.
On 10/29/07, Matej Knopp <ma...@gmail.com> wrote:
> I doubt it would prevent the page from being serialized. Versioning
> doesn't spot all changes to page (e.g. setting a property) so we can't
> rely on it, therefore we serialize it on every request.
>
> However, if you really want to get around the serialization for certain
> cases, you need to call Session.untouch(page) before
> Session.requestDetached() is called.
>
> I think calling it from Page.onDetach() should work. So you can set a
> request cycle metadata if you don't want the page to be serialized and
> then check for the meta data in page.onDetach().
Is this really just that component that causes the page to serialize?
Sounds like a design flaw to me if that is the case...
Eelco
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AutoCompleteTextField excessive serialisation
Posted by John Patterson <jd...@gmail.com>.
For the AutoCompleteTextField I think it would make sense to never
store the page and simply make respond(target) final so that the can
not be changed. Does anyone really want to change the page state
for every key press? If so then that would seem to be the exception
rather than the rule.
On 29 Oct 2007, at 18:11, Matej Knopp wrote:
> Problem is that we can't do this by default. The behavior may
> change the page / component and we can't detect it. Then people
> would start complaining why they changes aren't preserved. This
> could lead to bugs that are very hard to track.
>
> As I said, in the next version, we'll probably have more elegant
> way to prevent page serialization, however it will still be on-
> demand only, not by default.
>
> -Matej
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AutoCompleteTextField excessive serialisation
Posted by Matej Knopp <ma...@gmail.com>.
Problem is that we can't do this by default. The behavior may change the
page / component and we can't detect it. Then people would start
complaining why they changes aren't preserved. This could lead to bugs
that are very hard to track.
As I said, in the next version, we'll probably have more elegant way to
prevent page serialization, however it will still be on-demand only, not
by default.
-Matej
John Patterson wrote / napísal(a):
> I have just made the changes you suggested and it seems to work. I
> added the metadata in response(target)
>
> protected void respond(AjaxRequestTarget target)
> {
> super.respond(target);
> RequestCycle.get().setMetaData(UNTOUCH_PAGE_KEY, Boolean.TRUE);
> }
>
> Perhaps this could be incorporated into the AutoUpdateBehaviour and the
> metadata checked for somewhere in wicket core rather than my Page subclass.
>
> John
>
> On 29 Oct 2007, at 17:27, Matej Knopp wrote:
>
>> I doubt it would prevent the page from being serialized. Versioning
>> doesn't spot all changes to page (e.g. setting a property) so we can't
>> rely on it, therefore we serialize it on every request.
>>
>> However, if you really want to get around the serialization for
>> certain cases, you need to call Session.untouch(page) before
>> Session.requestDetached() is called.
>>
>> I think calling it from Page.onDetach() should work. So you can set a
>> request cycle metadata if you don't want the page to be serialized and
>> then check for the meta data in page.onDetach().
>>
>> -Matej
>>
>> Igor Vaynberg wrote / napísal(a):
>>> autocomplete.setversioned(false) do it?
>>> -igor
>>> On 10/29/07, John Patterson <jd...@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> I am using the AutoCompleteTextField and can see that every keystroke
>>>> causes the entire page to be serialised and stored which seems a bit
>>>> excessive. Is there anyway to say that the page has not changed and
>>>> so don't store it?
>>>>
>>>> John
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AutoCompleteTextField excessive serialisation
Posted by John Patterson <jd...@gmail.com>.
I have just made the changes you suggested and it seems to work. I
added the metadata in response(target)
protected void respond(AjaxRequestTarget target)
{
super.respond(target);
RequestCycle.get().setMetaData(UNTOUCH_PAGE_KEY, Boolean.TRUE);
}
Perhaps this could be incorporated into the AutoUpdateBehaviour and
the metadata checked for somewhere in wicket core rather than my Page
subclass.
John
On 29 Oct 2007, at 17:27, Matej Knopp wrote:
> I doubt it would prevent the page from being serialized. Versioning
> doesn't spot all changes to page (e.g. setting a property) so we
> can't rely on it, therefore we serialize it on every request.
>
> However, if you really want to get around the serialization for
> certain cases, you need to call Session.untouch(page) before
> Session.requestDetached() is called.
>
> I think calling it from Page.onDetach() should work. So you can set
> a request cycle metadata if you don't want the page to be
> serialized and then check for the meta data in page.onDetach().
>
> -Matej
>
> Igor Vaynberg wrote / napísal(a):
>> autocomplete.setversioned(false) do it?
>> -igor
>> On 10/29/07, John Patterson <jd...@gmail.com> wrote:
>>> Hi,
>>>
>>> I am using the AutoCompleteTextField and can see that every
>>> keystroke
>>> causes the entire page to be serialised and stored which seems a bit
>>> excessive. Is there anyway to say that the page has not changed and
>>> so don't store it?
>>>
>>> John
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
Re: AutoCompleteTextField excessive serialisation
Posted by Matej Knopp <ma...@gmail.com>.
I doubt it would prevent the page from being serialized. Versioning
doesn't spot all changes to page (e.g. setting a property) so we can't
rely on it, therefore we serialize it on every request.
However, if you really want to get around the serialization for certain
cases, you need to call Session.untouch(page) before
Session.requestDetached() is called.
I think calling it from Page.onDetach() should work. So you can set a
request cycle metadata if you don't want the page to be serialized and
then check for the meta data in page.onDetach().
-Matej
Igor Vaynberg wrote / napísal(a):
> autocomplete.setversioned(false) do it?
>
> -igor
>
>
> On 10/29/07, John Patterson <jd...@gmail.com> wrote:
>> Hi,
>>
>> I am using the AutoCompleteTextField and can see that every keystroke
>> causes the entire page to be serialised and stored which seems a bit
>> excessive. Is there anyway to say that the page has not changed and
>> so don't store it?
>>
>> John
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AutoCompleteTextField excessive serialisation
Posted by Igor Vaynberg <ig...@gmail.com>.
autocomplete.setversioned(false) do it?
-igor
On 10/29/07, John Patterson <jd...@gmail.com> wrote:
> Hi,
>
> I am using the AutoCompleteTextField and can see that every keystroke
> causes the entire page to be serialised and stored which seems a bit
> excessive. Is there anyway to say that the page has not changed and
> so don't store it?
>
> John
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org