I will try it when I get to work.  Thanks a bunch!

On Apr 17, 2009 6:37 AM, "Peter Gardfjäll" <[email protected]>
wrote:

Sure,
here goes. I have added both the java and the js file to the same Java
package:

WicketAjaxJsPatch.java
==================

/**
 * {...@link IBehavior} that should be added to {...@link Page}s that need to
prevent
 * the page load performance penalty incurred when wicket-ajax.js traverses
all
 * &lt;a&gt; tags in the page markup.
 *
 * <p/>
 * For background information, see <a
href="
http://www.nabble.com/wicket-ajax-and-IE-performance-problems-for-pages-with-many-links-td23078336.html
"
 * >this mailing list thread</a>
 * <p/>
 * This behavior simply makes sure that our patch gets applied to
wicket-ajax.js
 * (by forcing wicket-ajax.js to be added to the page head prior to
 * wicket-ajax-patch.js).
 *
 */
public class WicketAjaxJsPatch extends AbstractDefaultAjaxBehavior {

   @Override
   public void renderHead(IHeaderResponse response) {
       super.renderHead(response);
       response.renderJavascriptReference(new ResourceReference(
           WicketAjaxJsPatch.class, "wicket-ajax-patch.js"));
   }

   @Override
   protected void respond(AjaxRequestTarget target) {
       // Does nothing. The fact that we are extending
       // AbstractDefaultAjaxBehavior means that we will pull in
       // wicket-event.js and wicket-ajax.js. The job of this behavior is to
       // make sure that our wicket-ajax-patch.js script gets added to the
page
       // head after those scripts.
   }
}


wicket-ajax-patch.js
===============

/**
 * Overrides the attachFocusEvent function registered by wicket-ajax.js.
 * The original version traverses all anchor and button tags on the page
 * which incurs a major performance penalty on pages with many links.
 * This version skips these elements in the scanning.
 */

if (typeof(Wicket) != "undefined") { if (typeof(Wicket.Focus) !=
"undefined") { // Deregister ...
Attaching the behavior
=================
What I do then is to add the WicketAjaxJsPatch to the page by doing.

 page.add(new WicketAjaxJsPatch());


It seems to be doing its job for me. Please tell me if it doesn't work.

cheers, Peter


On Fri, Apr 17, 2009 at 12:15 PM, James Carman

<[email protected]> wrote: > Did that code actually work for you?
 I tried adding this js...

Reply via email to