Wicket
  1. Wicket
  2. WICKET-4862

AjaxPagingNavigationLink and AjaxPagingNavigationIncrementLink output inline onclick attributes in addition to Wicket.Ajax.ajax event registration

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.2.0
    • Fix Version/s: 6.12.0, 7.0.0-M1
    • Component/s: wicket
    • Environment:
      Not env specific

      Description

      The AjaxPagingNavigation links are outputting inline onclick attributes in addition to being registered via Wicket.Ajax.ajax calls when used with certain tags like span. These are Ajax components so therefore should no longer have inline onclick handlers.

      1. awqs.zip
        29 kB
        Barrett Snyder
      2. WICKET-4862.patch
        3 kB
        Martin Grigorov

        Activity

        Hide
        Martin Grigorov added a comment -

        Dries Schulten Your approach looks good to me. Applied!

        Show
        Martin Grigorov added a comment - Dries Schulten Your approach looks good to me. Applied!
        Hide
        Dries Schulten added a comment -

        Seeing the same issue using Wicket 6.10.0, we use 'em' tags for our paging. Wicket renders an onclick attribute on the 'em' tag because the AjaxPagingNavigationLink extends from Link which in onComponentTag renders a onclick if the tag is not a 'a' tag. Because the Ajax paging links use a AjaxPagingNavigationBehavior that renders a JavaScript click event the original click is not needed (only for non ajax fallback?). Our current workaround is to remove the generated onclick handler in the onComponentTag of AjaxPagingNavigtionLink but I think it stops ajax fallback from working (our whole application is ajax based so no issue for us).

        protected void onComponentTag(ComponentTag tag) {
        	super.onComponentTag(tag);
        	tag.remove("onclick");
        }
        
        Show
        Dries Schulten added a comment - Seeing the same issue using Wicket 6.10.0, we use 'em' tags for our paging. Wicket renders an onclick attribute on the 'em' tag because the AjaxPagingNavigationLink extends from Link which in onComponentTag renders a onclick if the tag is not a 'a' tag. Because the Ajax paging links use a AjaxPagingNavigationBehavior that renders a JavaScript click event the original click is not needed (only for non ajax fallback?). Our current workaround is to remove the generated onclick handler in the onComponentTag of AjaxPagingNavigtionLink but I think it stops ajax fallback from working (our whole application is ajax based so no issue for us). protected void onComponentTag(ComponentTag tag) { super .onComponentTag(tag); tag.remove( "onclick" ); }
        Hide
        Martin Grigorov added a comment -

        @Wicket devs: is this solution too ugly for this problem ?

        The Ajax navigation links extend from Link (instead from AjaxLink due to limitations in Java language) and this causes the logic in org.apache.wicket.markup.html.link.Link#onComponentTag() around line 403 to trigger.
        With the suggested hack this is avoided.

        Show
        Martin Grigorov added a comment - @Wicket devs: is this solution too ugly for this problem ? The Ajax navigation links extend from Link (instead from AjaxLink due to limitations in Java language) and this causes the logic in org.apache.wicket.markup.html.link.Link#onComponentTag() around line 403 to trigger. With the suggested hack this is avoided.
        Hide
        Martin Grigorov added a comment -

        Thanks for the quickstart!

        Show
        Martin Grigorov added a comment - Thanks for the quickstart!
        Hide
        Barrett Snyder added a comment -

        Here is the quickstart. The key to reproducing is using tags other than anchor tags for the navigation links, in this case spans. Just view the source of the page and you'll see the nav links get AJAX behavior click registration in addition to inline onclick handlers. Clicking the paging nav fires 2 requests, one for the AJAX behavior and 1 for the inline onclick.

        Show
        Barrett Snyder added a comment - Here is the quickstart. The key to reproducing is using tags other than anchor tags for the navigation links, in this case spans. Just view the source of the page and you'll see the nav links get AJAX behavior click registration in addition to inline onclick handlers. Clicking the paging nav fires 2 requests, one for the AJAX behavior and 1 for the inline onclick.
        Hide
        Martin Grigorov added a comment -

        Please provide a quickstart demonstrating the problem.

        Show
        Martin Grigorov added a comment - Please provide a quickstart demonstrating the problem.

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Barrett Snyder
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development