Overriding wicket-ajax-jquery.js

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Overriding wicket-ajax-jquery.js

avchavan
Hi,
I am using AjaxSelfUpdatingTimerBehavior in my application which is for session timeout kinda functionality. Also i have a Download functionality using DownloadLink.
The AjaxSelfUpdatingTimerBehavior  doesnt work after i download a file.
I saw a JIRA created for similar issue: https://issues.apache.org/jira/browse/WICKET-5822 
I am using wicket 6.19.0
I saw the changelog and there was some change from changing the event from beforeunload to unload.
Now, can i just make this change in the wicket-ajax-jquery.js and use it somehow for my project?
I am in the middle of a release and cannot upgrade to wicket7 at the moment.
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

Martin Grigorov-4
https://issues.apache.org/jira/browse/WICKET-5822 is fixed in 6.20.0 too

But yes, you could use "monkey patching" to override it locally too. Please
search for "monkey patch javascript" in the web.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Sep 28, 2015 at 9:32 AM, avchavan <[hidden email]>
wrote:

> Hi,
> I am using AjaxSelfUpdatingTimerBehavior in my application which is for
> session timeout kinda functionality. Also i have a Download functionality
> using DownloadLink.
> The AjaxSelfUpdatingTimerBehavior  doesnt work after i download a file.
> I saw a JIRA created for similar issue:
> https://issues.apache.org/jira/browse/WICKET-5822
> I am using wicket 6.19.0
> I saw the changelog and there was some change from changing the event from
> beforeunload to unload.
> Now, can i just make this change in the wicket-ajax-jquery.js and use it
> somehow for my project?
> I am in the middle of a release and cannot upgrade to wicket7 at the
> moment.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Overriding-wicket-ajax-jquery-js-tp4672051.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
I am not too good with Javascript.
What i did is made a duplicate file locally for wicket-ajax-jquery.js and modified "beforeunload" to "unload".
Imported this duplicate file at the end (just before the Head tag closes).
But it doesn't work.
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

Martin Grigorov-4
Time to become better with JavaScript! ;-)
Fire the debugger and see what happens.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Sep 28, 2015 at 12:56 PM, avchavan <[hidden email]>
wrote:

> I am not too good with Javascript.
> What i did is made a duplicate file locally for wicket-ajax-jquery.js and
> modified "beforeunload" to "unload".
> Imported this duplicate file at the end (just before the Head tag closes).
> But it doesn't work.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Overriding-wicket-ajax-jquery-js-tp4672051p4672056.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
not working.
I added alerts inside the method to see if it gets called, but in vein.
I hope my changes are correct, here's what i changed:
Wicket.Event.add(window, "unload", function() {
                var WTH = Wicket.TimerHandles;
                if (WTH) {
                        for (var th in WTH) {
                                if (WTH.hasOwnProperty(th)) {
                                        window.clearTimeout(WTH[th]);
                                        delete WTH[th];
                                }
                        }
                }
        });

Only changes is the event from beforeunload to unload.
I hope i am doing it correctly.
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

Martin Grigorov-4
Why don't you upgrade to 6.20.0 ?

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Sep 30, 2015 at 12:08 PM, avchavan <[hidden email]>
wrote:

> not working.
> I added alerts inside the method to see if it gets called, but in vein.
> I hope my changes are correct, here's what i changed:
> Wicket.Event.add(window, "unload", function() {
>                 var WTH = Wicket.TimerHandles;
>                 if (WTH) {
>                         for (var th in WTH) {
>                                 if (WTH.hasOwnProperty(th)) {
>                                         window.clearTimeout(WTH[th]);
>                                         delete WTH[th];
>                                 }
>                         }
>                 }
>         });
>
> Only changes is the event from beforeunload to unload.
> I hope i am doing it correctly.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Overriding-wicket-ajax-jquery-js-tp4672051p4672060.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
We don't have time to upgrade and do a full cycle of testing of the entire application again :(
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

Tobias Soloschenko
Hi,

because there are no API breaks an upgrade to Wicket 6.20.0 should only consist of changing the maven pom.xml.

All changes of Wicket 6.20.0 are listed in the release notes - so testing the affected components should be all you need to do.

I think this is better then implementing some workarounds.

kind regards

Tobias

> Am 30.09.2015 um 12:14 schrieb avchavan <[hidden email]>:
>
> We don't have time to upgrade and do a full cycle of testing of the entire
> application again :(
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Overriding-wicket-ajax-jquery-js-tp4672051p4672062.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
The problem is we have to deliver tomorrow and the application is BIG, so testing it wont be possible and we wont get a go ahead.
is there any alternative apart from upgrade (even a dirty one would do for time being).
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

Martin Grigorov-4
Please explain in more details what you have done and what is the order of
.js files in your page.
It is hard for us to tell what is wrong from just "it doesn't work".

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Sep 30, 2015 at 2:45 PM, avchavan <[hidden email]>
wrote:

> The problem is we have to deliver tomorrow and the application is BIG, so
> testing it wont be possible and we wont get a go ahead.
> is there any alternative apart from upgrade (even a dirty one would do for
> time being).
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Overriding-wicket-ajax-jquery-js-tp4672051p4672064.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
In reply to this post by avchavan
or may be if there is a way to discard wicket-ajax-jquery.js used by wicket and use a duplicate (with the unload event)?
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
In reply to this post by Martin Grigorov-4
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:wicket="http://wicket.apache.org"
	xsi:schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd http://wicket.apache.org">
<head><script type="text/javascript" src="./wicket/resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery-1.11.2-ver-1443587966000.js"></script>
<script type="text/javascript" src="./wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-event-jquery-ver-1443587966000.js"></script>
<script type="text/javascript" src="./wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-ajax-jquery-ver-1443587966000.js"></script>
<script type="text/javascript" src="./wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-ajax-jquery-debug-ver-1443587966000.js"></script>
<script type="text/javascript" id="wicket-ajax-debug-enable">
/*<![CDATA[*/
Wicket.Ajax.DebugWindow.enabled=true;
/*]]>*/
</script>
<script type="text/javascript" id="wicket-ajax-base-url">
/*<![CDATA[*/
Wicket.Ajax.baseUrl="?0";
/*]]>*/
</script>

<script type="text/javascript" src="wicket-ajax-jquery-monkeypatch.js"></script>
<script type="text/javascript" >
/*<![CDATA[*/
Wicket.Event.add(window, "domready", function(event) { 
Wicket.Ajax.ajax({"c":"downloadSomething2","u":"./?0-1.IBehaviorListener.1-downloadSomething","e":"click"});;
Wicket.Event.publish(Wicket.Event.Topic.AJAX_HANDLERS_BOUND);
;});
/*]]>*/
</script>
<script type="text/javascript" >
/*<![CDATA[*/
Wicket.Event.add(window, "load", function(event) { 
Wicket.Timer.set('timerHits1', function(){Wicket.Ajax.ajax({"c":"timerHits1","u":"./?0-1.IBehaviorListener.0-timerHits"});}, 2000);;
;});
/*]]>*/
</script>
</head>
<body>
	<span>Timer hits:</span><span wicket:id="timerHits" id="timerHits1">0</span>
	<a wicket:id="downloadSomething" id="downloadSomething2" href="javascript:;">Download</a>
</body>
</html>

This is what i get from view page source.
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

Martin Grigorov-4
In reply to this post by avchavan
oh, right.
See application.getJavaScriptLibrarySettings().setWicketJQueryReference()

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Sep 30, 2015 at 2:50 PM, avchavan <[hidden email]>
wrote:

> or may be if there is a way to discard wicket-ajax-jquery.js used by wicket
> and use a duplicate (with the unload event)?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Overriding-wicket-ajax-jquery-js-tp4672051p4672066.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

Martin Grigorov-4
In reply to this post by avchavan
On Wed, Sep 30, 2015 at 2:51 PM, avchavan <[hidden email]>
wrote:

>
>
> This is what i get from view page source.
>

It looks OK.
I guess you need to unregister the old listener before registering the new
one.


>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Overriding-wicket-ajax-jquery-js-tp4672051p4672067.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
In reply to this post by Martin Grigorov-4
I dont see setWicketJQueryReference, but there is setJQueryReference.
I hope you meant setJQueryReference only :)
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
In reply to this post by Martin Grigorov-4
so, call timer.stop() before download finishes?
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

Martin Grigorov-4
In reply to this post by avchavan
I actually mean #setWicketAjaxReference()


https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/settings/JavaScriptLibrarySettings.java#L91

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Sep 30, 2015 at 2:56 PM, avchavan <[hidden email]>
wrote:

> I dont see setWicketJQueryReference, but there is setJQueryReference.
> I hope you meant setJQueryReference only :)
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Overriding-wicket-ajax-jquery-js-tp4672051p4672070.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
The counter doesn't stop now, but i can see javascript errors in firebug:
ReferenceError: Wicket is not defined
Wicket.Class = {
,
TypeError: Wicket.Throttler is not a constructor
throttler: new Wicket.Throttler(true),
&
TypeError: Wicket.Ajax.DebugWindow is undefined
Wicket.Ajax.DebugWindow.enabled=true;

Here's my HTML from view page source:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:wicket="http://wicket.apache.org"
	xsi:schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd http://wicket.apache.org">
<head><script type="text/javascript" src="./wicket/resource/com.mycompany.WicketApplication/wicket-ajax-jquery-monkeypatch-ver-1443619624000.js"></script>
<script type="text/javascript" src="./wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-ajax-jquery-debug-ver-1443587966000.js"></script>
<script type="text/javascript" id="wicket-ajax-debug-enable">
/*<![CDATA[*/
Wicket.Ajax.DebugWindow.enabled=true;
/*]]>*/
</script>
<script type="text/javascript" id="wicket-ajax-base-url">
/*<![CDATA[*/
Wicket.Ajax.baseUrl="?0";
/*]]>*/
</script>
<script type="text/javascript" src="./wicket/resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery-1.11.2-ver-1443587966000.js"></script>
<script type="text/javascript" src="./wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-event-jquery-ver-1443587966000.js"></script>

<script type="text/javascript" src="scripts/wicket-ajax-jquery-monkeypatch.js"></script>
<script type="text/javascript" >
/*<![CDATA[*/
Wicket.Event.add(window, "domready", function(event) { 
Wicket.Ajax.ajax({"c":"downloadSomething2","u":"./?0-1.IBehaviorListener.1-downloadSomething","e":"click"});;
Wicket.Event.publish(Wicket.Event.Topic.AJAX_HANDLERS_BOUND);
;});
/*]]>*/
</script>
<script type="text/javascript" >
/*<![CDATA[*/
Wicket.Event.add(window, "load", function(event) { 
Wicket.Timer.set('timerHits1', function(){Wicket.Ajax.ajax({"c":"timerHits1","u":"./?0-1.IBehaviorListener.0-timerHits"});}, 2000);;
;});
/*]]>*/
</script>
</head>
<body>
	<span>Timer hits:</span><span wicket:id="timerHits" id="timerHits1">0</span>
	<a wicket:id="downloadSomething" id="downloadSomething2" href="javascript:;">Download</a>
</body>
</html>

I have included <script type="text/javascript" src="scripts/wicket-ajax-jquery-monkeypatch.js"></script>as well because it didn't work without it (counter doesn't increment & i get same javascript errors in firebug).
Reply | Threaded
Open this post in threaded view
|

Re: Overriding wicket-ajax-jquery.js

avchavan
In reply to this post by Martin Grigorov-4
What's happening now is the custom js is being loaded first hence i am getting reference error.
Is there a way that the ajax js gets loaded after wicket's jquery and event js?