Re: Redirecting to another Wicket after 5 seconds

2015-05-22 Thread Don Ferguson
The following works for me:
public TimerTestPage() {
   add(new AbstractAjaxTimerBehavior(Duration.seconds(5)) {
   @Override
   protected void onTimer(AjaxRequestTarget target) {
setResponsePage(TimerTestPage2.class, new PageParameters());
   }
   });
}


> On May 22, 2015, at 8:13 AM, MartinoSuperman  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
> 



Re: Redirecting to another Wicket after 5 seconds

2015-05-22 Thread Don Ferguson
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  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



Redirecting to another Wicket after 5 seconds

2015-05-22 Thread MartinoSuperman
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



Re: ClientProperties.getBrowserWidth() always returns -1

2015-05-22 Thread Martin Grigorov
Hi,

On Thu, May 21, 2015 at 4:40 AM, smallufo  wrote:

> 2015-05-20 23:27 GMT+08:00 Martin Grigorov :
>
> > You can use AjaxBrowserInfoBehavior.
> >
>
>
> I think you mean AjaxClientInfoBehavior
> http://www.wicket-library.com/wicket-examples-6.0.x/ajaxhellobrowser/?0
>
> Thanks . it's working well !
>
> But I have another question.
>

Please use a new thread for new questions.


>
> Is there any way to get the containing element's width ?
>
> for example :
>
>
> *  *
>
> It will have different proportion in different width
> for XS (extreme small) screen , it will be 100% width
> and for SM (small) or larger  screen , it will cover 1/3 width
> Is it possible to dynamically get the width of the containing element ?
> (so that I can generate correct width image )
>

This is rather a JS/CSS question, not Wicket/Java.
It is possible. You should use the computed style of the container element.
Once you read the width/height you can use Wicket Ajax to send the data to
the server.



>
> Thanks.
>