ICEfaces
  1. ICEfaces
  2. ICE-7554

ACE:linkButton component - Network Connection Interrupted issue

    Details

    • Assignee Priority:
      P2

      Description

      When clicking on a ace:linkButton component in any of the test pages, there is a Network Connection Interrupted message appearing for a very short time.
      There is also a server error visible in Tomcat log:
      8-Dec-2011 12:56:54 PM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
      SEVERE: Error Rendering View[/linkBttnAttribute.xhtml]
      java.lang.NullPointerException
      at org.icefaces.impl.event.WindowAndViewIDSetup$1.encode(WindowAndViewIDSetup.java:72)
      at org.icefaces.impl.event.UIOutputWriter.encodeBegin(UIOutputWriter.java:32)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1755)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
      at org.icefaces.impl.renderkit.RendererWrapper.encodeChildren(RendererWrapper.java:54)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)


      Steps:
      - load the page: http://localhost:8080/linkBttn/linkBttnAttribute.jsf
      - click ckeckbox 'rendered' to render the component on page.
      - click on the ace:linkButton component.

        Activity

        Hide
        Deryk Sinotte added a comment -

        The markup for the button in question is:

        <ice:linkButton id="LBAtt"
        value="Test Attributes"
        href="http://www.icefaces.org/main/home/"
        rendered="#

        {linkBean.rendered}

        "
        disabled="#

        {linkBean.disabled}

        "
        tabindex="#

        {linkBean.tabindex}

        "
        style="#

        {linkBean.style}

        "
        singleSubmit="true"
        styelClass="#

        {linkBean.styleClass}

        "
        hrefLang="#

        {linkBean.hrefLang}

        "
        target="#

        {linkBean.target}

        "
        immediate="#

        {linkBean.immediate}

        "
        />

        Which generates the following rendered output:

        <a href="http://www.icefaces.org/main/home/"
        hreflang="en"
        onclick="return ice.ace.linkButton.clickHandler(event, 'frm5:LBAtt' );"
        style="background-color:lightgreen"
        tabindex="10" target="_self"
        id="frm5:LBAtt_span-button"
        class="">Test Attributes</a>

        This results in both a full submit and an Ajax call and leads to the following error from the server (generated by JSF):

        "The Http Transport returned a 0 status code. This is usually the result of mixing ajax and full requests. This is usually undesired, for both performance and data integrity reasons."

        We handle the error as a generic network issue and the Network Interrupted dialog is shown just before the actual navigation to the href occurs. Googling for "mixing ajax and full requests" returns a number of results generally indicating that we shouldn't do this:

        http://weblogs.java.net/blog/driscoll/archive/2009/10/01/mixing-ajax-and-full-requests-jsf-20
        https://forums.oracle.com/forums/thread.jspa?threadID=2148500

        Perhaps the test as it currently stands is invalid?
        Or we need to check to see if there is an href before also rendering out our click handler?
        Or handle the special errors differently?

        Show
        Deryk Sinotte added a comment - The markup for the button in question is: <ice:linkButton id="LBAtt" value="Test Attributes" href="http://www.icefaces.org/main/home/" rendered="# {linkBean.rendered} " disabled="# {linkBean.disabled} " tabindex="# {linkBean.tabindex} " style="# {linkBean.style} " singleSubmit="true" styelClass="# {linkBean.styleClass} " hrefLang="# {linkBean.hrefLang} " target="# {linkBean.target} " immediate="# {linkBean.immediate} " /> Which generates the following rendered output: <a href="http://www.icefaces.org/main/home/" hreflang="en" onclick="return ice.ace.linkButton.clickHandler(event, 'frm5:LBAtt' );" style="background-color:lightgreen" tabindex="10" target="_self" id="frm5:LBAtt_span-button" class="">Test Attributes</a> This results in both a full submit and an Ajax call and leads to the following error from the server (generated by JSF): "The Http Transport returned a 0 status code. This is usually the result of mixing ajax and full requests. This is usually undesired, for both performance and data integrity reasons." We handle the error as a generic network issue and the Network Interrupted dialog is shown just before the actual navigation to the href occurs. Googling for "mixing ajax and full requests" returns a number of results generally indicating that we shouldn't do this: http://weblogs.java.net/blog/driscoll/archive/2009/10/01/mixing-ajax-and-full-requests-jsf-20 https://forums.oracle.com/forums/thread.jspa?threadID=2148500 Perhaps the test as it currently stands is invalid? Or we need to check to see if there is an href before also rendering out our click handler? Or handle the special errors differently?
        Hide
        Deryk Sinotte added a comment -

        Yip wrote:
        > f (i.e. doAction) is determined by action or actionListener attribute:
        > ActionListener[] al = linkButton.getActionListeners();
        > boolean doAction = (al.length > 0 || (linkButton.getActionExpression() != null));
        >
        > Here is comment in JS about returning false:
        > // If there are actionListeners, don't do default behaviour
        > if (doAction)

        { > return false; > }

        The examples in our tests and in the ACE Showcase use an "href" attribute and they are the ones that cause the problem. In the LinkButtonRenderer, we automatically add the onclick handler:

        writer.writeAttribute(HTML.ONCLICK_ATTR, userOnclick +
        "return ice.ace.linkButton.clickHandler(event, '" + clientId + "' );",
        null);

        But mixing that with an href attribute leads to the double request IF an action or actionListener is not present (as per Yip's comment above). So we need to answer the questions about how the component should be used and how should the href/onclick markup be rendered out in relation to those various use cases.

        Show
        Deryk Sinotte added a comment - Yip wrote: > f (i.e. doAction) is determined by action or actionListener attribute: > ActionListener[] al = linkButton.getActionListeners(); > boolean doAction = (al.length > 0 || (linkButton.getActionExpression() != null)); > > Here is comment in JS about returning false: > // If there are actionListeners, don't do default behaviour > if (doAction) { > return false; > } The examples in our tests and in the ACE Showcase use an "href" attribute and they are the ones that cause the problem. In the LinkButtonRenderer, we automatically add the onclick handler: writer.writeAttribute(HTML.ONCLICK_ATTR, userOnclick + "return ice.ace.linkButton.clickHandler(event, '" + clientId + "' );", null); But mixing that with an href attribute leads to the double request IF an action or actionListener is not present (as per Yip's comment above). So we need to answer the questions about how the component should be used and how should the href/onclick markup be rendered out in relation to those various use cases.
        Hide
        Ken Fyten added a comment -

        I believe that the correct behaviour for linkButton is to only add the onClick trigger if an action or actionListener is define. ALSO, if the onClick listener is added, then we must take steps to ensure that the href default event is not executed as well.

        My recollection as to why we keep rendering the href at all in this case is so you can use the browser's context menu to open the link in another window or tab, while still using ICEfaces ajax submit if the user selects the link by clicking it.

        Looking at the logic in component's clickHandler function below:

        ,clickHandler: function(h, b) {
        var g = ice.ace.getJSContext(b);
        var f = g.getJSFProps().doAction;
        var d = document.getElementById(b);
        var c = g.getJSFProps().postParameters;
        var j = function(l) {
        if (c != null) {
        var k = c.length / 2;
        for (var e = 0; e < k; e++)

        { l(c[e * 2], c[(e * 2) + 1]); }

        }
        };
        if (f)

        { ice.s(h, d, j); }

        else

        { ice.se(h, d, j); }

        var a = g.getJSProps().behaviors;
        if (a) {
        if (a.activate)

        { a.activate(); }

        }
        if (f)

        { return false; }

        It seems like if (not f), then we need to disable the default href event as well as submit using ice.se() (which we do already).

        Show
        Ken Fyten added a comment - I believe that the correct behaviour for linkButton is to only add the onClick trigger if an action or actionListener is define. ALSO, if the onClick listener is added, then we must take steps to ensure that the href default event is not executed as well. My recollection as to why we keep rendering the href at all in this case is so you can use the browser's context menu to open the link in another window or tab, while still using ICEfaces ajax submit if the user selects the link by clicking it. Looking at the logic in component's clickHandler function below: ,clickHandler: function(h, b) { var g = ice.ace.getJSContext(b); var f = g.getJSFProps().doAction; var d = document.getElementById(b); var c = g.getJSFProps().postParameters; var j = function(l) { if (c != null) { var k = c.length / 2; for (var e = 0; e < k; e++) { l(c[e * 2], c[(e * 2) + 1]); } } }; if (f) { ice.s(h, d, j); } else { ice.se(h, d, j); } var a = g.getJSProps().behaviors; if (a) { if (a.activate) { a.activate(); } } if (f) { return false; } It seems like if (not f), then we need to disable the default href event as well as submit using ice.se() (which we do already).
        Hide
        Ken Fyten added a comment -

        From the TLD doc for the href attribute:

        href of link. If specified and actionListener is absent, linkButton works as normal anchor. If specified and actionListener is present, linkButton works as AJAX event source, but href may be opened in a new tab or window

        So the linkbutton has the following modes:

        href specified, no action specified = normal anchor behavior (aka full page GET / navigation).
        href specified, action specified = action button behavior, unless user uses context menu to open link another window or tab, then it uses the href for normal full page GET / navigation behavior.
        href not specified, action specified = normal action button behavior
        href not specified, action not specified = ? Likely does a normal form submit like any button would?

        So, reviewing the JIRA note as to what is actually happening now:

        Re: http://jira.icefaces.org/browse/ICE-7554

        We have a regression test with the following markup for a link button:

        <ice:linkButton id="LBAtt"
        value="Test Attributes"
        href="http://www.icefaces.org/main/home/"
        rendered="#

        {linkBean.rendered}

        "
        disabled="#

        {linkBean.disabled}

        "
        tabindex="#

        {linkBean.tabindex}

        "
        style="#

        {linkBean.style}

        "
        singleSubmit="true"
        styelClass="#

        {linkBean.styleClass}

        "
        hrefLang="#

        {linkBean.hrefLang}

        "
        target="#

        {linkBean.target}

        "
        immediate="#

        {linkBean.immediate}

        "
        />

        Which generates the following rendered output:

        <a href="http://www.icefaces.org/main/home/"
        hreflang="en"
        onclick="return ice.ace.linkButton.clickHandler(event, 'frm5:LBAtt' );"
        style="background-color:lightgreen"
        tabindex="10" target="_self"
        id="frm5:LBAtt_span-button"
        class="">Test Attributes</a>

        This results in both a full submit and an Ajax call and leads to the following error from the server...

        ...it seems that the mode where href is used, but no action specified, is incorrectly doing an ajax submit, when it should only be doing normal anchor / navigation behavior.

        Does anyone agree with me?

        Show
        Ken Fyten added a comment - From the TLD doc for the href attribute: href of link. If specified and actionListener is absent, linkButton works as normal anchor. If specified and actionListener is present, linkButton works as AJAX event source, but href may be opened in a new tab or window So the linkbutton has the following modes: href specified, no action specified = normal anchor behavior (aka full page GET / navigation). href specified, action specified = action button behavior, unless user uses context menu to open link another window or tab, then it uses the href for normal full page GET / navigation behavior. href not specified, action specified = normal action button behavior href not specified, action not specified = ? Likely does a normal form submit like any button would? So, reviewing the JIRA note as to what is actually happening now: Re: http://jira.icefaces.org/browse/ICE-7554 We have a regression test with the following markup for a link button: <ice:linkButton id="LBAtt" value="Test Attributes" href="http://www.icefaces.org/main/home/" rendered="# {linkBean.rendered} " disabled="# {linkBean.disabled} " tabindex="# {linkBean.tabindex} " style="# {linkBean.style} " singleSubmit="true" styelClass="# {linkBean.styleClass} " hrefLang="# {linkBean.hrefLang} " target="# {linkBean.target} " immediate="# {linkBean.immediate} " /> Which generates the following rendered output: <a href="http://www.icefaces.org/main/home/" hreflang="en" onclick="return ice.ace.linkButton.clickHandler(event, 'frm5:LBAtt' );" style="background-color:lightgreen" tabindex="10" target="_self" id="frm5:LBAtt_span-button" class="">Test Attributes</a> This results in both a full submit and an Ajax call and leads to the following error from the server... ...it seems that the mode where href is used, but no action specified, is incorrectly doing an ajax submit, when it should only be doing normal anchor / navigation behavior. Does anyone agree with me?
        Hide
        yip.ng added a comment -

        Modified: C:\svn\ossrepo\icefaces3\trunk\icefaces\ace\component\resources\icefaces.ace\linkbutton\linkbutton.js
        Completed: At revision: 26904

        Show
        yip.ng added a comment - Modified: C:\svn\ossrepo\icefaces3\trunk\icefaces\ace\component\resources\icefaces.ace\linkbutton\linkbutton.js Completed: At revision: 26904
        Hide
        Carmen Cristurean added a comment -

        Verified fix with Icefaces3 code revision # 27107, with Firefox 3.6 and Firefox 6.

        Show
        Carmen Cristurean added a comment - Verified fix with Icefaces3 code revision # 27107, with Firefox 3.6 and Firefox 6.

          People

          • Assignee:
            yip.ng
            Reporter:
            Carmen Cristurean
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: