You're right Ernesto, your example works, but what if I want to replace a whole 
panel and not just the model of a label?


-----Urspr√ľngliche Nachricht-----
Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] 
Gesendet: Mittwoch, 11. November 2009 10:15
An: users@wicket.apache.org
Betreff: Re: AbstractAjaxTimerBehavior causes exception

Well I think it all boils down to the explanation a gave on my first e-mail:
if you replace the component with a new one that does not have the behavior
then you will get an exception (the same will happend if you remove the
behavior during a round trip).  I guess Martin was just trying to say that
you should use the same label...? Did you try the code I posted? It does
work ;-)

Cheers,

Ernesto

On Wed, Nov 11, 2009 at 10:06 AM, Giambalvo, Christian <
christian.giamba...@excelsisnet.com> wrote:

> Hi Martin,
>
> this doesn't work.
>
>        @Override
>            protected void onTimer(AjaxRequestTarget target)
>            {
>                Label t2 = new Label("message", "Test " + testCounter);
>                 t2.setOutputMarkupId(true);
>                 test = t2;
>                testCounter++;
>                target.addComponent(test);
>            }
> It doesn't throw an exception, but the t2 didn't show up.
> I think this is because t2 isn't added to the page.
> That's why there is Component#replaceWith(Component).
>
> Greets
>
> -----Urspr√ľngliche Nachricht-----
> Von: Martin Grigorov [mailto:mcgreg...@e-card.bg]
> Gesendet: Mittwoch, 11. November 2009 09:59
> An: users@wicket.apache.org
> Betreff: Re: AbstractAjaxTimerBehavior causes exception
>
> On Wed, 2009-11-11 at 09:21 +0100, Giambalvo, Christian wrote:
> > Hi all,
> >
> >
> >
> > maybe i found a bug.
> >
> > Don't know if I'm doing something wrong.
> >
> > But it's a simple usecase.
> >
> >
> >
> > Following code produces an exception:
> >
> >
> >
> > public class HomePage extends WebPage {
> >
> >
> >
> >     private static final long serialVersionUID = 1L;
> >
> >
> >
> >     private static int testCounter = 0;
> >
> >
> >
> >     public HomePage(final PageParameters parameters) {
> >
> >
> >
> >         // Add the simplest type of label
> >
> >         final Label test = new Label("message", "If you see this message
> > wicket is properly configured and running");
> >
> >         test.add(new AbstractAjaxTimerBehavior(Duration.seconds(1))
> >
> >         {
> >
> >             @Override
> >
> >             protected void onTimer(AjaxRequestTarget target)
> >
> >             {
> >
> >                 Label t2 = new Label("message", "Test " + testCounter);
> >
> >                 test.replaceWith(t2);
> here you need to make : test = t2;
> >
> >                 testCounter++;
> >
> >                 target.addComponent(test);
> >
> >             }
> >
> >         });
> >
> >
> >
> >         add(test);
> >
> >     }
> >
> > }
> >
> >
> >
> > Exception:
> >
> > Root cause:
> >
> > java.lang.IllegalStateException: No Page found for component [Component
> > id = message]
> >      at org.apache.wicket.Component.getPage(Component.java:1754)
> >      at org.apache.wicket.RequestCycle.urlFor(RequestCycle.java:872)
> >      at org.apache.wicket.Component.urlFor(Component.java:3286)
> >      at
> > org.apache.wicket.behavior.AbstractAjaxBehavior.getCallbackUrl(AbstractA
> > jaxBehavior.java:124)
> >      at
> > org.apache.wicket.ajax.AbstractAjaxTimerBehavior.getCallbackScript(Abstr
> > actAjaxTimerBehavior.java:127)
> >      at
> > org.apache.wicket.ajax.AbstractAjaxTimerBehavior.getJsTimeoutCall(Abstra
> > ctAjaxTimerBehavior.java:120)
> >      at
> > org.apache.wicket.ajax.AbstractAjaxTimerBehavior.respond(AbstractAjaxTim
> > erBehavior.java:163)
> >      at
> > org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDef
> > aultAjaxBehavior.java:299)
> >      at
> > org.apache.wicket.request.target.component.listener.BehaviorRequestTarge
> > t.processEvents(BehaviorRequestTarget.java:119)
> >      at
> > org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(Ab
> > stractRequestCycleProcessor.java:92)
> >      at
> > org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java
> > :1250)
> >      at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
> >      at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
> >      at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
> >      at
> > org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:468
> > )
> >      at
> > org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:
> > 301)
> >      at
> > org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHan
> > dler.java:1157)
> >      at
> > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
> >      at
> > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:2
> > 16)
> >      at
> > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
> >      at
> > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
> >      at
> > org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
> >      at
> > org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandler
> > Collection.java:230)
> >      at
> > org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.jav
> > a:114)
> >      at
> > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> >      at org.mortbay.jetty.Server.handle(Server.java:326)
> >      at
> > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)
> >      at
> > org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConne
> > ction.java:915)
> >      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
> >      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
> >      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)
> >      at
> > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
> > 409)
> >      at
> > org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java
> > :582)
> >
> >
> >
> > Greets
> >
> > Chris
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

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

Reply via email to