You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alfonso Quiroga <al...@gmail.com> on 2012/03/22 15:20:48 UTC

keep component state?

Hi, in my job we are using wicket and I've made some components like
Accordion, etc. The problem is, when the page refreshes, the accordion
state is reseted. I think I can develop this solution:

* every time the users clicks in a accordion tab, an AJAX request is
made, to mantain the component state in the server.

But it will be very heavy for the server, I mean, too many ajax
requests (one per click). I'm looking a NON-ajax solution.

In the page we have links (grids with paginator, buttons, etc) Is
there a global solution that, no matter which link is clicked, it will
*always* send the component state? or maybe using cookies? thanks in
advance

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


Re: keep component state?

Posted by Alfonso Quiroga <al...@gmail.com>.
Igor: I agree 100%. My question was thinking something (maybe
impossible) that, no matter which link you click, it will always send
the accordion (or any other componenent) state. Maybe it is not
possible because i.e. a normal link only requests a new url generated
by Wicket, and I don't see the way to "push" a component state in the
url. Thanks !

pd: if the links and form would mantain the hash of the page, the
problem will be solved

On Thu, Mar 22, 2012 at 6:35 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> ah. well, if you want it to be preserved across link clicks then you
> have to keep the state on the server. you wouldnt have to if the links
> were ajax and were not repainting the accordion.
>
> -igor
>
>
> On Thu, Mar 22, 2012 at 2:33 PM, Alfonso Quiroga <al...@gmail.com> wrote:
>> Are you sure when the page changes the hash is keeped? Maybe I did not
>> express correctly, when I typed "refresh the page" I wanted to say
>> "when you click a link and wicket renders the page again". I think
>> when you click any link, a new url is generated without the hash.
>> Thanks anyway
>>
>> On Thu, Mar 22, 2012 at 1:28 PM, Igor Vaynberg <ig...@gmail.com> wrote:
>>> add the state to the hash of the page. and when initializing accordion
>>> check the hash and restore it. this should survive page refreshes.
>>>
>>> -igor
>>>
>>>
>>> On Thu, Mar 22, 2012 at 7:20 AM, Alfonso Quiroga <al...@gmail.com> wrote:
>>>> Hi, in my job we are using wicket and I've made some components like
>>>> Accordion, etc. The problem is, when the page refreshes, the accordion
>>>> state is reseted. I think I can develop this solution:
>>>>
>>>> * every time the users clicks in a accordion tab, an AJAX request is
>>>> made, to mantain the component state in the server.
>>>>
>>>> But it will be very heavy for the server, I mean, too many ajax
>>>> requests (one per click). I'm looking a NON-ajax solution.
>>>>
>>>> In the page we have links (grids with paginator, buttons, etc) Is
>>>> there a global solution that, no matter which link is clicked, it will
>>>> *always* send the component state? or maybe using cookies? thanks in
>>>> advance
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>

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


Re: keep component state?

Posted by Alfonso Quiroga <al...@gmail.com>.
Thanks to both Igor and Dan. I already thougth on jquery solution (I'm
using jQuery) changing ALL the links, but I think it is not a happy
solution. Tomorrow at work I will fight with cookies and js, which is
a good idea. Thanks again!!

On Thu, Mar 22, 2012 at 7:00 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> if a cookie is used then no server side interaction is required.
> javascript can read the cookie itself and restore state all on client
> side.
>
> as far as naming the cookie, its not terribly hard. name the coookie
> "accordion". assign each accordian a guid on serverside and push it to
> clientside where js can use it as the key to store the state in map
> that lives in the cookie.
>
> -igor
>
> On Thu, Mar 22, 2012 at 2:45 PM, Dan Retzlaff <dr...@gmail.com> wrote:
>> I thought Alfonso's cookie suggestion sounded workable. Have JS keep the
>> current accordian state there, and you can grab it server-side in
>> your accordion's onBeforeRender. A cookie naming strategy that works
>> generally might be tricky (does it include the page mount? version?
>> component ID?). But you could probably make an "engineering compromise"
>> that works.
>>
>> There's probably an uglier jQuery solution that updates all link targets in
>> the page when your accordian gets clicked. :)
>>
>> On Thu, Mar 22, 2012 at 2:35 PM, Igor Vaynberg <ig...@gmail.com>wrote:
>>
>>> ah. well, if you want it to be preserved across link clicks then you
>>> have to keep the state on the server. you wouldnt have to if the links
>>> were ajax and were not repainting the accordion.
>>>
>>> -igor
>>>
>>>
>>> On Thu, Mar 22, 2012 at 2:33 PM, Alfonso Quiroga <al...@gmail.com>
>>> wrote:
>>> > Are you sure when the page changes the hash is keeped? Maybe I did not
>>> > express correctly, when I typed "refresh the page" I wanted to say
>>> > "when you click a link and wicket renders the page again". I think
>>> > when you click any link, a new url is generated without the hash.
>>> > Thanks anyway
>>> >
>>> > On Thu, Mar 22, 2012 at 1:28 PM, Igor Vaynberg <ig...@gmail.com>
>>> wrote:
>>> >> add the state to the hash of the page. and when initializing accordion
>>> >> check the hash and restore it. this should survive page refreshes.
>>> >>
>>> >> -igor
>>> >>
>>> >>
>>> >> On Thu, Mar 22, 2012 at 7:20 AM, Alfonso Quiroga <
>>> alfonsosebaq@gmail.com> wrote:
>>> >>> Hi, in my job we are using wicket and I've made some components like
>>> >>> Accordion, etc. The problem is, when the page refreshes, the accordion
>>> >>> state is reseted. I think I can develop this solution:
>>> >>>
>>> >>> * every time the users clicks in a accordion tab, an AJAX request is
>>> >>> made, to mantain the component state in the server.
>>> >>>
>>> >>> But it will be very heavy for the server, I mean, too many ajax
>>> >>> requests (one per click). I'm looking a NON-ajax solution.
>>> >>>
>>> >>> In the page we have links (grids with paginator, buttons, etc) Is
>>> >>> there a global solution that, no matter which link is clicked, it will
>>> >>> *always* send the component state? or maybe using cookies? thanks in
>>> >>> advance
>>> >>>
>>> >>> ---------------------------------------------------------------------
>>> >>> 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
>>>
>>>
>
> ---------------------------------------------------------------------
> 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: keep component state?

Posted by Igor Vaynberg <ig...@gmail.com>.
if a cookie is used then no server side interaction is required.
javascript can read the cookie itself and restore state all on client
side.

as far as naming the cookie, its not terribly hard. name the coookie
"accordion". assign each accordian a guid on serverside and push it to
clientside where js can use it as the key to store the state in map
that lives in the cookie.

-igor

On Thu, Mar 22, 2012 at 2:45 PM, Dan Retzlaff <dr...@gmail.com> wrote:
> I thought Alfonso's cookie suggestion sounded workable. Have JS keep the
> current accordian state there, and you can grab it server-side in
> your accordion's onBeforeRender. A cookie naming strategy that works
> generally might be tricky (does it include the page mount? version?
> component ID?). But you could probably make an "engineering compromise"
> that works.
>
> There's probably an uglier jQuery solution that updates all link targets in
> the page when your accordian gets clicked. :)
>
> On Thu, Mar 22, 2012 at 2:35 PM, Igor Vaynberg <ig...@gmail.com>wrote:
>
>> ah. well, if you want it to be preserved across link clicks then you
>> have to keep the state on the server. you wouldnt have to if the links
>> were ajax and were not repainting the accordion.
>>
>> -igor
>>
>>
>> On Thu, Mar 22, 2012 at 2:33 PM, Alfonso Quiroga <al...@gmail.com>
>> wrote:
>> > Are you sure when the page changes the hash is keeped? Maybe I did not
>> > express correctly, when I typed "refresh the page" I wanted to say
>> > "when you click a link and wicket renders the page again". I think
>> > when you click any link, a new url is generated without the hash.
>> > Thanks anyway
>> >
>> > On Thu, Mar 22, 2012 at 1:28 PM, Igor Vaynberg <ig...@gmail.com>
>> wrote:
>> >> add the state to the hash of the page. and when initializing accordion
>> >> check the hash and restore it. this should survive page refreshes.
>> >>
>> >> -igor
>> >>
>> >>
>> >> On Thu, Mar 22, 2012 at 7:20 AM, Alfonso Quiroga <
>> alfonsosebaq@gmail.com> wrote:
>> >>> Hi, in my job we are using wicket and I've made some components like
>> >>> Accordion, etc. The problem is, when the page refreshes, the accordion
>> >>> state is reseted. I think I can develop this solution:
>> >>>
>> >>> * every time the users clicks in a accordion tab, an AJAX request is
>> >>> made, to mantain the component state in the server.
>> >>>
>> >>> But it will be very heavy for the server, I mean, too many ajax
>> >>> requests (one per click). I'm looking a NON-ajax solution.
>> >>>
>> >>> In the page we have links (grids with paginator, buttons, etc) Is
>> >>> there a global solution that, no matter which link is clicked, it will
>> >>> *always* send the component state? or maybe using cookies? thanks in
>> >>> advance
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> 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
>>
>>

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


Re: keep component state?

Posted by Dan Retzlaff <dr...@gmail.com>.
I thought Alfonso's cookie suggestion sounded workable. Have JS keep the
current accordian state there, and you can grab it server-side in
your accordion's onBeforeRender. A cookie naming strategy that works
generally might be tricky (does it include the page mount? version?
component ID?). But you could probably make an "engineering compromise"
that works.

There's probably an uglier jQuery solution that updates all link targets in
the page when your accordian gets clicked. :)

On Thu, Mar 22, 2012 at 2:35 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> ah. well, if you want it to be preserved across link clicks then you
> have to keep the state on the server. you wouldnt have to if the links
> were ajax and were not repainting the accordion.
>
> -igor
>
>
> On Thu, Mar 22, 2012 at 2:33 PM, Alfonso Quiroga <al...@gmail.com>
> wrote:
> > Are you sure when the page changes the hash is keeped? Maybe I did not
> > express correctly, when I typed "refresh the page" I wanted to say
> > "when you click a link and wicket renders the page again". I think
> > when you click any link, a new url is generated without the hash.
> > Thanks anyway
> >
> > On Thu, Mar 22, 2012 at 1:28 PM, Igor Vaynberg <ig...@gmail.com>
> wrote:
> >> add the state to the hash of the page. and when initializing accordion
> >> check the hash and restore it. this should survive page refreshes.
> >>
> >> -igor
> >>
> >>
> >> On Thu, Mar 22, 2012 at 7:20 AM, Alfonso Quiroga <
> alfonsosebaq@gmail.com> wrote:
> >>> Hi, in my job we are using wicket and I've made some components like
> >>> Accordion, etc. The problem is, when the page refreshes, the accordion
> >>> state is reseted. I think I can develop this solution:
> >>>
> >>> * every time the users clicks in a accordion tab, an AJAX request is
> >>> made, to mantain the component state in the server.
> >>>
> >>> But it will be very heavy for the server, I mean, too many ajax
> >>> requests (one per click). I'm looking a NON-ajax solution.
> >>>
> >>> In the page we have links (grids with paginator, buttons, etc) Is
> >>> there a global solution that, no matter which link is clicked, it will
> >>> *always* send the component state? or maybe using cookies? thanks in
> >>> advance
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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: keep component state?

Posted by Igor Vaynberg <ig...@gmail.com>.
ah. well, if you want it to be preserved across link clicks then you
have to keep the state on the server. you wouldnt have to if the links
were ajax and were not repainting the accordion.

-igor


On Thu, Mar 22, 2012 at 2:33 PM, Alfonso Quiroga <al...@gmail.com> wrote:
> Are you sure when the page changes the hash is keeped? Maybe I did not
> express correctly, when I typed "refresh the page" I wanted to say
> "when you click a link and wicket renders the page again". I think
> when you click any link, a new url is generated without the hash.
> Thanks anyway
>
> On Thu, Mar 22, 2012 at 1:28 PM, Igor Vaynberg <ig...@gmail.com> wrote:
>> add the state to the hash of the page. and when initializing accordion
>> check the hash and restore it. this should survive page refreshes.
>>
>> -igor
>>
>>
>> On Thu, Mar 22, 2012 at 7:20 AM, Alfonso Quiroga <al...@gmail.com> wrote:
>>> Hi, in my job we are using wicket and I've made some components like
>>> Accordion, etc. The problem is, when the page refreshes, the accordion
>>> state is reseted. I think I can develop this solution:
>>>
>>> * every time the users clicks in a accordion tab, an AJAX request is
>>> made, to mantain the component state in the server.
>>>
>>> But it will be very heavy for the server, I mean, too many ajax
>>> requests (one per click). I'm looking a NON-ajax solution.
>>>
>>> In the page we have links (grids with paginator, buttons, etc) Is
>>> there a global solution that, no matter which link is clicked, it will
>>> *always* send the component state? or maybe using cookies? thanks in
>>> advance
>>>
>>> ---------------------------------------------------------------------
>>> 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: keep component state?

Posted by Alfonso Quiroga <al...@gmail.com>.
Are you sure when the page changes the hash is keeped? Maybe I did not
express correctly, when I typed "refresh the page" I wanted to say
"when you click a link and wicket renders the page again". I think
when you click any link, a new url is generated without the hash.
Thanks anyway

On Thu, Mar 22, 2012 at 1:28 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> add the state to the hash of the page. and when initializing accordion
> check the hash and restore it. this should survive page refreshes.
>
> -igor
>
>
> On Thu, Mar 22, 2012 at 7:20 AM, Alfonso Quiroga <al...@gmail.com> wrote:
>> Hi, in my job we are using wicket and I've made some components like
>> Accordion, etc. The problem is, when the page refreshes, the accordion
>> state is reseted. I think I can develop this solution:
>>
>> * every time the users clicks in a accordion tab, an AJAX request is
>> made, to mantain the component state in the server.
>>
>> But it will be very heavy for the server, I mean, too many ajax
>> requests (one per click). I'm looking a NON-ajax solution.
>>
>> In the page we have links (grids with paginator, buttons, etc) Is
>> there a global solution that, no matter which link is clicked, it will
>> *always* send the component state? or maybe using cookies? thanks in
>> advance
>>
>> ---------------------------------------------------------------------
>> 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: keep component state?

Posted by Igor Vaynberg <ig...@gmail.com>.
add the state to the hash of the page. and when initializing accordion
check the hash and restore it. this should survive page refreshes.

-igor


On Thu, Mar 22, 2012 at 7:20 AM, Alfonso Quiroga <al...@gmail.com> wrote:
> Hi, in my job we are using wicket and I've made some components like
> Accordion, etc. The problem is, when the page refreshes, the accordion
> state is reseted. I think I can develop this solution:
>
> * every time the users clicks in a accordion tab, an AJAX request is
> made, to mantain the component state in the server.
>
> But it will be very heavy for the server, I mean, too many ajax
> requests (one per click). I'm looking a NON-ajax solution.
>
> In the page we have links (grids with paginator, buttons, etc) Is
> there a global solution that, no matter which link is clicked, it will
> *always* send the component state? or maybe using cookies? thanks in
> advance
>
> ---------------------------------------------------------------------
> 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