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 <[EMAIL PROTECTED]
> 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 <[EMAIL PROTECTED]>
> 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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>