You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by a_godin <al...@omhm.qc.ca> on 2008/11/13 22:58:50 UTC

Label with AjaxSelfUpdatingTimerBehavior not refreshing

I'm trying something very simple ... I have a form with many panels and in
one of those panels, I want the current date and time to be refreshed
periodically.

	final Label msgStatutTransfert = new Label("msgStatutTransfert", new
Date().toString());
	msgStatutTransfert.setOutputMarkupId(true);
	msgStatutTransfert.add(new
AjaxSelfUpdatingTimerBehavior(Duration.seconds(5)));
	frmInfosTransfert.add(msgStatutTransfert); // one of my panels

When the page loads, it puts the current date in the label but then it
doesn't reshesh ... I looked at the debug info ... here's what I get

<?xml version="1.0" encoding="UTF-8"?><ajax-response><component
id="InfosTransferts_frmInfosTransfert_msgStatutTransfert" ><![CDATA[Thu Nov
13 16:09:53 EST 2008]]></component><evaluate><![CDATA[setTimeout("var
wcall=wicketAjaxGet('/ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true',
function() { }, function() { });", 1000);]]></evaluate></ajax-response>
INFO: Response parsed. Now invoking steps...
INFO: Response processed successfully.
INFO: Invoking post-call handler(s)...
INFO: 
INFO: Initiating Ajax GET request on
/ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true&random=0.9564825826726502
INFO: Invoking pre-call handler(s)...
INFO: Received ajax response (572 characters)
INFO: 

Any clue what I'm forgetting ?  I'm using wicket-1.2.6 ...
-- 
View this message in context: http://www.nabble.com/Label-with-AjaxSelfUpdatingTimerBehavior-not-refreshing-tp20490454p20490454.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Label with AjaxSelfUpdatingTimerBehavior not refreshing

Posted by Jeremy Thomerson <je...@wickettraining.com>.
So far we're even on beers purchased - so I guess not enough!  I'm thinking
about adding "Buy Wicket in Action" to my signature to help reduce my
chances of carpal tunnel.



-- 
Jeremy Thomerson
http://www.wickettraining.com

On Thu, Nov 13, 2008 at 5:30 PM, Bruno Borges <br...@gmail.com>wrote:

> Jeremy, I forgot to ask you: how many beers is Martijn giving to you to
> promote the book? I want that deal too!
>
> cheers,
> Bruno Borges
> blog.brunoborges.com.br
> +55 21 76727099
>
> "The glory of great men should always be
> measured by the means they have used to
> acquire it."
> - Francois de La Rochefoucauld
>
>
> On Thu, Nov 13, 2008 at 9:28 PM, Bruno Borges <bruno.borges@gmail.com
> >wrote:
>
> > The problem is not just about understanding models. It's deeper than
> that.
> >
> > You have to understand that Wicket architecture is -hardly-speaking- like
> > Java Swing. Objects that you create, will live just like a JButton,
> JPanel,
> > whatever.
> >
> > Label msgStatutTransfert = new Label("msgStatutTransfert", new
> > Date().toString());
> >
> > Here, you create a Label object, and you want an Ajax Update Event to
> > change the date. Well, that will never happen, because in nowhere you are
> > actually updating the 'msgStatusTransfert' object's value. It was created
> > containing an instance of a String (imutable object) from the toString()
> > method of a Date instance.
> >
> > Being more specific (like Swing):
> >   Imagine that you create an instance of JButton(new Date().toString());
> > and add that to a JFrame. Will that value update by itself after calling
> > myJFrame.repaint();? No. Only if you override the repaint() method and
> > before calling super.repaint(), you code something like
> > myButton.setValue(new Date().toString());
> >
> > Understand that, and you will easily - and hopefully quickly - understand
> > why we use Models.
> >
> > Have fun with Wicket!
> >
> > Cheers,
> > Bruno Borges
> > blog.brunoborges.com.br
> > +55 21 76727099
> >
> > "The glory of great men should always be
> > measured by the means they have used to
> > acquire it."
> > - Francois de La Rochefoucauld
> >
> >
> >
> > On Thu, Nov 13, 2008 at 9:13 PM, Jeremy Thomerson <
> > jeremy@wickettraining.com> wrote:
> >
> >> Yes - you're not understanding models.  You created a Label with a
> static
> >> String - the current time at the time of creation.  You need to use a
> >> model,
> >> which is a "data finder"....  something like:
> >>
> >> new Label("msgStatutTransfert", new AbstractReadOnlyModel<Date>() {
> >>     public Date getObject() {
> >>          return new Date();
> >>     }
> >> });
> >>
> >> Also, read:
> >> http://cwiki.apache.org/WICKET/working-with-wicket-models.html
> >> and buy Wicket in Action.
> >>
> >> --
> >> Jeremy Thomerson
> >> http://www.wickettraining.com
> >>
> >> On Thu, Nov 13, 2008 at 3:58 PM, a_godin <al...@omhm.qc.ca>
> >> wrote:
> >>
> >> >
> >> > I'm trying something very simple ... I have a form with many panels
> and
> >> in
> >> > one of those panels, I want the current date and time to be refreshed
> >> > periodically.
> >> >
> >> >        final Label msgStatutTransfert = new
> Label("msgStatutTransfert",
> >> new
> >> > Date().toString());
> >> >        msgStatutTransfert.setOutputMarkupId(true);
> >> >        msgStatutTransfert.add(new
> >> > AjaxSelfUpdatingTimerBehavior(Duration.seconds(5)));
> >> >        frmInfosTransfert.add(msgStatutTransfert); // one of my panels
> >> >
> >> > When the page loads, it puts the current date in the label but then it
> >> > doesn't reshesh ... I looked at the debug info ... here's what I get
> >> >
> >> > <?xml version="1.0" encoding="UTF-8"?><ajax-response><component
> >> > id="InfosTransferts_frmInfosTransfert_msgStatutTransfert"
> ><![CDATA[Thu
> >> Nov
> >> > 13 16:09:53 EST 2008]]></component><evaluate><![CDATA[setTimeout("var
> >> >
> >> >
> >>
> wcall=wicketAjaxGet('/ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true',
> >> > function() { }, function() { });",
> 1000);]]></evaluate></ajax-response>
> >> > INFO: Response parsed. Now invoking steps...
> >> > INFO: Response processed successfully.
> >> > INFO: Invoking post-call handler(s)...
> >> > INFO:
> >> > INFO: Initiating Ajax GET request on
> >> >
> >> >
> >>
> /ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true&random=0.9564825826726502
> >> > INFO: Invoking pre-call handler(s)...
> >> > INFO: Received ajax response (572 characters)
> >> > INFO:
> >> >
> >> > Any clue what I'm forgetting ?  I'm using wicket-1.2.6 ...
> >> > --
> >> > View this message in context:
> >> >
> >>
> http://www.nabble.com/Label-with-AjaxSelfUpdatingTimerBehavior-not-refreshing-tp20490454p20490454.html
> >> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >>
> >
> >
>

Re: Label with AjaxSelfUpdatingTimerBehavior not refreshing

Posted by Bruno Borges <br...@gmail.com>.
Jeremy, I forgot to ask you: how many beers is Martijn giving to you to
promote the book? I want that deal too!

cheers,
Bruno Borges
blog.brunoborges.com.br
+55 21 76727099

"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld


On Thu, Nov 13, 2008 at 9:28 PM, Bruno Borges <br...@gmail.com>wrote:

> The problem is not just about understanding models. It's deeper than that.
>
> You have to understand that Wicket architecture is -hardly-speaking- like
> Java Swing. Objects that you create, will live just like a JButton, JPanel,
> whatever.
>
> Label msgStatutTransfert = new Label("msgStatutTransfert", new
> Date().toString());
>
> Here, you create a Label object, and you want an Ajax Update Event to
> change the date. Well, that will never happen, because in nowhere you are
> actually updating the 'msgStatusTransfert' object's value. It was created
> containing an instance of a String (imutable object) from the toString()
> method of a Date instance.
>
> Being more specific (like Swing):
>   Imagine that you create an instance of JButton(new Date().toString());
> and add that to a JFrame. Will that value update by itself after calling
> myJFrame.repaint();? No. Only if you override the repaint() method and
> before calling super.repaint(), you code something like
> myButton.setValue(new Date().toString());
>
> Understand that, and you will easily - and hopefully quickly - understand
> why we use Models.
>
> Have fun with Wicket!
>
> Cheers,
> Bruno Borges
> blog.brunoborges.com.br
> +55 21 76727099
>
> "The glory of great men should always be
> measured by the means they have used to
> acquire it."
> - Francois de La Rochefoucauld
>
>
>
> On Thu, Nov 13, 2008 at 9:13 PM, Jeremy Thomerson <
> jeremy@wickettraining.com> wrote:
>
>> Yes - you're not understanding models.  You created a Label with a static
>> String - the current time at the time of creation.  You need to use a
>> model,
>> which is a "data finder"....  something like:
>>
>> new Label("msgStatutTransfert", new AbstractReadOnlyModel<Date>() {
>>     public Date getObject() {
>>          return new Date();
>>     }
>> });
>>
>> Also, read:
>> http://cwiki.apache.org/WICKET/working-with-wicket-models.html
>> and buy Wicket in Action.
>>
>> --
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>
>> On Thu, Nov 13, 2008 at 3:58 PM, a_godin <al...@omhm.qc.ca>
>> wrote:
>>
>> >
>> > I'm trying something very simple ... I have a form with many panels and
>> in
>> > one of those panels, I want the current date and time to be refreshed
>> > periodically.
>> >
>> >        final Label msgStatutTransfert = new Label("msgStatutTransfert",
>> new
>> > Date().toString());
>> >        msgStatutTransfert.setOutputMarkupId(true);
>> >        msgStatutTransfert.add(new
>> > AjaxSelfUpdatingTimerBehavior(Duration.seconds(5)));
>> >        frmInfosTransfert.add(msgStatutTransfert); // one of my panels
>> >
>> > When the page loads, it puts the current date in the label but then it
>> > doesn't reshesh ... I looked at the debug info ... here's what I get
>> >
>> > <?xml version="1.0" encoding="UTF-8"?><ajax-response><component
>> > id="InfosTransferts_frmInfosTransfert_msgStatutTransfert" ><![CDATA[Thu
>> Nov
>> > 13 16:09:53 EST 2008]]></component><evaluate><![CDATA[setTimeout("var
>> >
>> >
>> wcall=wicketAjaxGet('/ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true',
>> > function() { }, function() { });", 1000);]]></evaluate></ajax-response>
>> > INFO: Response parsed. Now invoking steps...
>> > INFO: Response processed successfully.
>> > INFO: Invoking post-call handler(s)...
>> > INFO:
>> > INFO: Initiating Ajax GET request on
>> >
>> >
>> /ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true&random=0.9564825826726502
>> > INFO: Invoking pre-call handler(s)...
>> > INFO: Received ajax response (572 characters)
>> > INFO:
>> >
>> > Any clue what I'm forgetting ?  I'm using wicket-1.2.6 ...
>> > --
>> > View this message in context:
>> >
>> http://www.nabble.com/Label-with-AjaxSelfUpdatingTimerBehavior-not-refreshing-tp20490454p20490454.html
>> > Sent from the Wicket - User mailing list archive at Nabble.com.
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>
>

Re: Label with AjaxSelfUpdatingTimerBehavior not refreshing

Posted by Bruno Borges <br...@gmail.com>.
The problem is not just about understanding models. It's deeper than that.

You have to understand that Wicket architecture is -hardly-speaking- like
Java Swing. Objects that you create, will live just like a JButton, JPanel,
whatever.

Label msgStatutTransfert = new Label("msgStatutTransfert", new
Date().toString());

Here, you create a Label object, and you want an Ajax Update Event to change
the date. Well, that will never happen, because in nowhere you are actually
updating the 'msgStatusTransfert' object's value. It was created containing
an instance of a String (imutable object) from the toString() method of a
Date instance.

Being more specific (like Swing):
  Imagine that you create an instance of JButton(new Date().toString()); and
add that to a JFrame. Will that value update by itself after calling
myJFrame.repaint();? No. Only if you override the repaint() method and
before calling super.repaint(), you code something like
myButton.setValue(new Date().toString());

Understand that, and you will easily - and hopefully quickly - understand
why we use Models.

Have fun with Wicket!

Cheers,
Bruno Borges
blog.brunoborges.com.br
+55 21 76727099

"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld


On Thu, Nov 13, 2008 at 9:13 PM, Jeremy Thomerson <jeremy@wickettraining.com
> wrote:

> Yes - you're not understanding models.  You created a Label with a static
> String - the current time at the time of creation.  You need to use a
> model,
> which is a "data finder"....  something like:
>
> new Label("msgStatutTransfert", new AbstractReadOnlyModel<Date>() {
>     public Date getObject() {
>          return new Date();
>     }
> });
>
> Also, read: http://cwiki.apache.org/WICKET/working-with-wicket-models.html
> and buy Wicket in Action.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
> On Thu, Nov 13, 2008 at 3:58 PM, a_godin <al...@omhm.qc.ca>
> wrote:
>
> >
> > I'm trying something very simple ... I have a form with many panels and
> in
> > one of those panels, I want the current date and time to be refreshed
> > periodically.
> >
> >        final Label msgStatutTransfert = new Label("msgStatutTransfert",
> new
> > Date().toString());
> >        msgStatutTransfert.setOutputMarkupId(true);
> >        msgStatutTransfert.add(new
> > AjaxSelfUpdatingTimerBehavior(Duration.seconds(5)));
> >        frmInfosTransfert.add(msgStatutTransfert); // one of my panels
> >
> > When the page loads, it puts the current date in the label but then it
> > doesn't reshesh ... I looked at the debug info ... here's what I get
> >
> > <?xml version="1.0" encoding="UTF-8"?><ajax-response><component
> > id="InfosTransferts_frmInfosTransfert_msgStatutTransfert" ><![CDATA[Thu
> Nov
> > 13 16:09:53 EST 2008]]></component><evaluate><![CDATA[setTimeout("var
> >
> >
> wcall=wicketAjaxGet('/ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true',
> > function() { }, function() { });", 1000);]]></evaluate></ajax-response>
> > INFO: Response parsed. Now invoking steps...
> > INFO: Response processed successfully.
> > INFO: Invoking post-call handler(s)...
> > INFO:
> > INFO: Initiating Ajax GET request on
> >
> >
> /ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true&random=0.9564825826726502
> > INFO: Invoking pre-call handler(s)...
> > INFO: Received ajax response (572 characters)
> > INFO:
> >
> > Any clue what I'm forgetting ?  I'm using wicket-1.2.6 ...
> > --
> > View this message in context:
> >
> http://www.nabble.com/Label-with-AjaxSelfUpdatingTimerBehavior-not-refreshing-tp20490454p20490454.html
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: Label with AjaxSelfUpdatingTimerBehavior not refreshing

Posted by a_godin <al...@omhm.qc.ca>.
Ok thank you, that worked fine ...

Now, in another panel, I'm trying to show the user the progress that's being
made while a process is running, something like "Job 1 out of 7 running"
then ""Job 2 out of 7 running", etc.

Here's what I did (based on what I read in the link you gave me) :

- Create a simple POJO class JobStatus 
- declare a label with an AjaxSelfUpdatingTimerBehavior in my panel
   final Label msgStatus = new Label("msgStatus", new
PropertyModel(jobStatus, "status"));
   msgStatus.setOutputMarkupId(true);
   frmStatus.add(msgStatus);
   msgStatus.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1)));
- in the onSubmit code of the button that submits the job in the panel
  jobStatus.setStatus("Job 1 out of 7 running"); then a little further
jobStatus.setStatus("Job 2 out of 7 running"); etc.

The status is not updated on screen ... any idea what I'a forgetting this
time ?


Jeremy Thomerson-5 wrote:
> 
> Yes - you're not understanding models.  You created a Label with a static
> String - the current time at the time of creation.  You need to use a
> model,
> which is a "data finder"....  something like:
> 
> new Label("msgStatutTransfert", new AbstractReadOnlyModel<Date>() {
>      public Date getObject() {
>           return new Date();
>      }
> });
> 
> Also, read: http://cwiki.apache.org/WICKET/working-with-wicket-models.html
> and buy Wicket in Action.
> 

-- 
View this message in context: http://www.nabble.com/Label-with-AjaxSelfUpdatingTimerBehavior-not-refreshing-tp20490454p20506788.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Label with AjaxSelfUpdatingTimerBehavior not refreshing

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Yes - you're not understanding models.  You created a Label with a static
String - the current time at the time of creation.  You need to use a model,
which is a "data finder"....  something like:

new Label("msgStatutTransfert", new AbstractReadOnlyModel<Date>() {
     public Date getObject() {
          return new Date();
     }
});

Also, read: http://cwiki.apache.org/WICKET/working-with-wicket-models.html
and buy Wicket in Action.

-- 
Jeremy Thomerson
http://www.wickettraining.com

On Thu, Nov 13, 2008 at 3:58 PM, a_godin <al...@omhm.qc.ca> wrote:

>
> I'm trying something very simple ... I have a form with many panels and in
> one of those panels, I want the current date and time to be refreshed
> periodically.
>
>        final Label msgStatutTransfert = new Label("msgStatutTransfert", new
> Date().toString());
>        msgStatutTransfert.setOutputMarkupId(true);
>        msgStatutTransfert.add(new
> AjaxSelfUpdatingTimerBehavior(Duration.seconds(5)));
>        frmInfosTransfert.add(msgStatutTransfert); // one of my panels
>
> When the page loads, it puts the current date in the label but then it
> doesn't reshesh ... I looked at the debug info ... here's what I get
>
> <?xml version="1.0" encoding="UTF-8"?><ajax-response><component
> id="InfosTransferts_frmInfosTransfert_msgStatutTransfert" ><![CDATA[Thu Nov
> 13 16:09:53 EST 2008]]></component><evaluate><![CDATA[setTimeout("var
>
> wcall=wicketAjaxGet('/ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true',
> function() { }, function() { });", 1000);]]></evaluate></ajax-response>
> INFO: Response parsed. Now invoking steps...
> INFO: Response processed successfully.
> INFO: Invoking post-call handler(s)...
> INFO:
> INFO: Initiating Ajax GET request on
>
> /ADHO/app/?wicket:interface=:3:InfosTransferts:frmInfosTransfert:msgStatutTransfert:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&wicket:ignoreIfNotActive=true&random=0.9564825826726502
> INFO: Invoking pre-call handler(s)...
> INFO: Received ajax response (572 characters)
> INFO:
>
> Any clue what I'm forgetting ?  I'm using wicket-1.2.6 ...
> --
> View this message in context:
> http://www.nabble.com/Label-with-AjaxSelfUpdatingTimerBehavior-not-refreshing-tp20490454p20490454.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>