You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Robin Shine <ro...@pmease.com> on 2011/12/08 05:24:29 UTC

Back button not work in Wicket 1.5.3 when component structure is not changed

Hi All, 


In Wicket 1.5.3, I create a very simple page containing a label and a link, when the link is clicked, it increases a counter, and change model value of the label. Thus the counter on the page will increase each time the link is clicked. For instance, the initial value displayed is 0, and after three clicks, the page displays value 3. However, the url remains unchanged while clicking the link, and hitting a back button at this time will display the page before displaying value 0, instead of displaying value 2. 


Is this a designed behavior or a bug? The page java code and its template is like below:


TestPage.java:

public class MyPage extends WebPage {

    private int count;    
    protected void onInitialize() {
        super.onInitialize();
        add(new Link<Void>("link") {
            public void onClick() {
                count++;
            }            
        });
        add(new Label("label", new AbstractReadOnlyModel<String>() {
            public String getObject() {
                return String.valueOf(count);
            }            
        }));
    }
}

TestPage.html:

<a wicket:id="link">link</a>
<span wicket:id="label">label</span>


Thanks for your help. 

Robin

Re: Back button not work in Wicket 1.5.3 when component structure is not changed

Posted by Robin Shine <ro...@pmease.com>.
I will use modelChanged() as you suggested. Thanks for the community, my question always get answered very quickly, :D

In case you are interested, here is another wicket powered product: QuickBuild, a continuous integration and release management server. Initially I 
chose Tapestry for the UI layer. Starting from QuickBuild 2.0, I 
switched to Wicket since it is very easy to contribute web UI via 
plugins due to the fact that Wicket page can be dynamically composed. 

Regards
Robin


________________________________
 From: Martin Grigorov <mg...@apache.org>
To: users@wicket.apache.org 
Sent: Thursday, December 8, 2011 7:31 PM
Subject: Re: Back button not work in Wicket 1.5.3 when component structure is not changed
 
Actually the important method is modelChanging(). It calls #dirty() for you.
In the code below there is no change in the state managed by Wicket (a
change in a model with setDefaultModel[Object]()) and that's the
reason the request doesn't trigger new page version.

On Thu, Dec 8, 2011 at 12:27 PM, James Carman
<jc...@carmanconsulting.com> wrote:
> modelChanged()?
>
> Sent from tablet device.  Please excuse typos and brevity.
> On Dec 8, 2011 12:58 AM, "Dan Retzlaff" <dr...@gmail.com> wrote:
>
>> Hi, Robin. I am not a core developer, but I believe this is as designed. If
>> you want the page version to be incremented, you can call Page#dirty() in
>> your onClick(). Otherwise the page version only advances when the component
>> hierarchy changes or when a component's model changes.
>>
>> On Wed, Dec 7, 2011 at 8:24 PM, Robin Shine <ro...@pmease.com> wrote:
>>
>> > Hi All,
>> >
>> >
>> > In Wicket 1.5.3, I create a very simple page containing a label and a
>> > link, when the link is clicked, it increases a counter, and change model
>> > value of the label. Thus the counter on the page will increase each time
>> > the link is clicked. For instance, the initial value displayed is 0, and
>> > after three clicks, the page displays value 3. However, the url remains
>> > unchanged while clicking the link, and hitting a back button at this time
>> > will display the page before displaying value 0, instead of displaying
>> > value 2.
>> >
>> >
>> > Is this a designed behavior or a bug? The page java code and its template
>> > is like below:
>> >
>> >
>> > TestPage.java:
>> >
>> > public class MyPage extends WebPage {
>> >
>> >     private int count;
>> >     protected void onInitialize() {
>> >         super.onInitialize();
>> >         add(new Link<Void>("link") {
>> >             public void onClick() {
>> >                 count++;
>> >             }
>> >         });
>> >         add(new Label("label", new AbstractReadOnlyModel<String>() {
>> >             public String getObject() {
>> >                 return String.valueOf(count);
>> >             }
>> >         }));
>> >     }
>> > }
>> >
>> > TestPage.html:
>> >
>> > <a wicket:id="link">link</a>
>> > <span wicket:id="label">label</span>
>> >
>> >
>> > Thanks for your help.
>> >
>> > Robin
>> >
>>



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

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

Re: Back button not work in Wicket 1.5.3 when component structure is not changed

Posted by Martin Grigorov <mg...@apache.org>.
Actually the important method is modelChanging(). It calls #dirty() for you.
In the code below there is no change in the state managed by Wicket (a
change in a model with setDefaultModel[Object]()) and that's the
reason the request doesn't trigger new page version.

On Thu, Dec 8, 2011 at 12:27 PM, James Carman
<jc...@carmanconsulting.com> wrote:
> modelChanged()?
>
> Sent from tablet device.  Please excuse typos and brevity.
> On Dec 8, 2011 12:58 AM, "Dan Retzlaff" <dr...@gmail.com> wrote:
>
>> Hi, Robin. I am not a core developer, but I believe this is as designed. If
>> you want the page version to be incremented, you can call Page#dirty() in
>> your onClick(). Otherwise the page version only advances when the component
>> hierarchy changes or when a component's model changes.
>>
>> On Wed, Dec 7, 2011 at 8:24 PM, Robin Shine <ro...@pmease.com> wrote:
>>
>> > Hi All,
>> >
>> >
>> > In Wicket 1.5.3, I create a very simple page containing a label and a
>> > link, when the link is clicked, it increases a counter, and change model
>> > value of the label. Thus the counter on the page will increase each time
>> > the link is clicked. For instance, the initial value displayed is 0, and
>> > after three clicks, the page displays value 3. However, the url remains
>> > unchanged while clicking the link, and hitting a back button at this time
>> > will display the page before displaying value 0, instead of displaying
>> > value 2.
>> >
>> >
>> > Is this a designed behavior or a bug? The page java code and its template
>> > is like below:
>> >
>> >
>> > TestPage.java:
>> >
>> > public class MyPage extends WebPage {
>> >
>> >     private int count;
>> >     protected void onInitialize() {
>> >         super.onInitialize();
>> >         add(new Link<Void>("link") {
>> >             public void onClick() {
>> >                 count++;
>> >             }
>> >         });
>> >         add(new Label("label", new AbstractReadOnlyModel<String>() {
>> >             public String getObject() {
>> >                 return String.valueOf(count);
>> >             }
>> >         }));
>> >     }
>> > }
>> >
>> > TestPage.html:
>> >
>> > <a wicket:id="link">link</a>
>> > <span wicket:id="label">label</span>
>> >
>> >
>> > Thanks for your help.
>> >
>> > Robin
>> >
>>



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

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


Re: Back button not work in Wicket 1.5.3 when component structure is not changed

Posted by James Carman <jc...@carmanconsulting.com>.
modelChanged()?

Sent from tablet device.  Please excuse typos and brevity.
On Dec 8, 2011 12:58 AM, "Dan Retzlaff" <dr...@gmail.com> wrote:

> Hi, Robin. I am not a core developer, but I believe this is as designed. If
> you want the page version to be incremented, you can call Page#dirty() in
> your onClick(). Otherwise the page version only advances when the component
> hierarchy changes or when a component's model changes.
>
> On Wed, Dec 7, 2011 at 8:24 PM, Robin Shine <ro...@pmease.com> wrote:
>
> > Hi All,
> >
> >
> > In Wicket 1.5.3, I create a very simple page containing a label and a
> > link, when the link is clicked, it increases a counter, and change model
> > value of the label. Thus the counter on the page will increase each time
> > the link is clicked. For instance, the initial value displayed is 0, and
> > after three clicks, the page displays value 3. However, the url remains
> > unchanged while clicking the link, and hitting a back button at this time
> > will display the page before displaying value 0, instead of displaying
> > value 2.
> >
> >
> > Is this a designed behavior or a bug? The page java code and its template
> > is like below:
> >
> >
> > TestPage.java:
> >
> > public class MyPage extends WebPage {
> >
> >     private int count;
> >     protected void onInitialize() {
> >         super.onInitialize();
> >         add(new Link<Void>("link") {
> >             public void onClick() {
> >                 count++;
> >             }
> >         });
> >         add(new Label("label", new AbstractReadOnlyModel<String>() {
> >             public String getObject() {
> >                 return String.valueOf(count);
> >             }
> >         }));
> >     }
> > }
> >
> > TestPage.html:
> >
> > <a wicket:id="link">link</a>
> > <span wicket:id="label">label</span>
> >
> >
> > Thanks for your help.
> >
> > Robin
> >
>

Re: Back button not work in Wicket 1.5.3 when component structure is not changed

Posted by Robin Shine <ro...@pmease.com>.
Hi Dan, 


Thanks for the quick response. The dirty() method does make the back button work again. 

Regards
Robin



________________________________
 From: Dan Retzlaff <dr...@gmail.com>
To: users@wicket.apache.org; Robin Shine <ro...@pmease.com> 
Sent: Thursday, December 8, 2011 1:57 PM
Subject: Re: Back button not work in Wicket 1.5.3 when component structure is not changed
 
Hi, Robin. I am not a core developer, but I believe this is as designed. If
you want the page version to be incremented, you can call Page#dirty() in
your onClick(). Otherwise the page version only advances when the component
hierarchy changes or when a component's model changes.

On Wed, Dec 7, 2011 at 8:24 PM, Robin Shine <ro...@pmease.com> wrote:

> Hi All,
>
>
> In Wicket 1.5.3, I create a very simple page containing a label and a
> link, when the link is clicked, it increases a counter, and change model
> value of the label. Thus the counter on the page will increase each time
> the link is clicked. For instance, the initial value displayed is 0, and
> after three clicks, the page displays value 3. However, the url remains
> unchanged while clicking the link, and hitting a back button at this time
> will display the page before displaying value 0, instead of displaying
> value 2.
>
>
> Is this a designed behavior or a bug? The page java code and its template
> is like below:
>
>
> TestPage.java:
>
> public class MyPage extends WebPage {
>
>     private int count;
>     protected void onInitialize() {
>         super.onInitialize();
>         add(new Link<Void>("link") {
>             public void onClick() {
>                 count++;
>             }
>         });
>         add(new Label("label", new AbstractReadOnlyModel<String>() {
>             public String getObject() {
>                 return String.valueOf(count);
>             }
>         }));
>     }
> }
>
> TestPage.html:
>
> <a wicket:id="link">link</a>
> <span wicket:id="label">label</span>
>
>
> Thanks for your help.
>
> Robin
>

Re: Back button not work in Wicket 1.5.3 when component structure is not changed

Posted by Dan Retzlaff <dr...@gmail.com>.
Hi, Robin. I am not a core developer, but I believe this is as designed. If
you want the page version to be incremented, you can call Page#dirty() in
your onClick(). Otherwise the page version only advances when the component
hierarchy changes or when a component's model changes.

On Wed, Dec 7, 2011 at 8:24 PM, Robin Shine <ro...@pmease.com> wrote:

> Hi All,
>
>
> In Wicket 1.5.3, I create a very simple page containing a label and a
> link, when the link is clicked, it increases a counter, and change model
> value of the label. Thus the counter on the page will increase each time
> the link is clicked. For instance, the initial value displayed is 0, and
> after three clicks, the page displays value 3. However, the url remains
> unchanged while clicking the link, and hitting a back button at this time
> will display the page before displaying value 0, instead of displaying
> value 2.
>
>
> Is this a designed behavior or a bug? The page java code and its template
> is like below:
>
>
> TestPage.java:
>
> public class MyPage extends WebPage {
>
>     private int count;
>     protected void onInitialize() {
>         super.onInitialize();
>         add(new Link<Void>("link") {
>             public void onClick() {
>                 count++;
>             }
>         });
>         add(new Label("label", new AbstractReadOnlyModel<String>() {
>             public String getObject() {
>                 return String.valueOf(count);
>             }
>         }));
>     }
> }
>
> TestPage.html:
>
> <a wicket:id="link">link</a>
> <span wicket:id="label">label</span>
>
>
> Thanks for your help.
>
> Robin
>