By the time the timer goes off, the page has already been rendered and control
has returned to the browser. The server has no way to tell the browser to
redirect. I’d recommend moving the timer logic to the client side. The
TimerTestPage can render javascript, executed on the client. After 5 seconds,
the client executes a callback to the server that executes the redirect.
On May 22, 2015, at 8:13 AM, MartinoSuperman martinosuper...@live.nl wrote:
Dear,
I want to make a timer on a WicketPage.
When my Wicket website starts at the begin page, it must redirect after 5
seconds to another.
I already have the following code:
=
public final class TimerTestPage extends WebPage {
Timer timer;
public TimerTestPage() {
super();
ActionListener actionListener;
actionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setResponsePage(DemoPage.class);
//getRequestCycle().setRequestTarget(DemoPage.class);
}
};
timer = new Timer(5000, actionListener);
timer.start();
}
}
=
The timer works, but after 5 seconds, the Wicket page is not redirected to
DemoPage.
It gives the following NullPointer exception:
===
Severe: Exception in thread AWT-EventQueue-0
Severe: java.lang.NullPointerException
at org.apache.wicket.Component.setResponsePage(Component.java:3141)
at
com.myapp.wicket.TimerTestPage$1.actionPerformed(TimerTestPage.java:30)
at javax.swing.Timer.fireActionPerformed(Timer.java:312)
at javax.swing.Timer$DoPostEvent.run(Timer.java:244)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:738)
at java.awt.EventQueue.access$300(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:699)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:708)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Does anyone know what I am doing wrong? What exactly generates that
NullPointer exception?
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Redirecting-to-another-Wicket-after-5-seconds-tp4670858.html
Sent from the Users forum mailing list archive at Nabble.com.
-
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