ICEfaces
  1. ICEfaces
  2. ICE-7619

The jsf.js file is loaded twice when h:commandLink is present

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.RC2
    • Fix Version/s: 3.0
    • Component/s: Framework, Sample Apps
    • Labels:
      None
    • Environment:
      ICEfaces 3 Mojarra
    • Assignee Priority:
      P2

      Description

      I haven't noticed the same behaviour with MyFaces but when running something like ACE Showcase with Mojarra, the jsf.js file is loaded twice. The reason is that the h:commandLink components used on the page will render out an inline reference to the file if Mojarra determines it's necessary. You can see it in the CommandLinkRenderer class:


          @Override
          public void encodeBegin(FacesContext context, UIComponent component)
                throws IOException {

              rendererParamsNotNull(context, component);

              if (!shouldEncode(component)) {
                  return;
              }

              boolean componentDisabled =
                    Boolean.TRUE.equals(component.getAttributes().get("disabled"));

              String formClientId = RenderKitUtils.getFormClientId(component, context);

              if (componentDisabled || formClientId == null) {
                  renderAsDisabled(context, component);
              } else {
                  RenderKitUtils.renderJsfJs(context);
                  renderAsActive(context, component);
              }

          }

      In the method, it attempt to do a check to see if jsf.js is already there (which we do in the BridgeSetup) but it presumably fails that check and renders out an inline script for the benefit of the onclick handler:


      <li style="padding-left: 15px;">
          <script src="/mo/javax.faces.resource/jsf.js.jsf?ln=javax.faces&amp;stage=Development"
                type="text/javascript">
          </script>
          <a class="selected"
             href="#"
             id="j_idt20:j_idt22:24:j_idt30:0:_t32"
             onclick="mojarra.jsfcljs(document.getElementById('j_idt20'),{'j_idt20:j_idt22:24:j_idt30:0:_t32':'j_idt20:j_idt22:24:j_idt30:0:_t32'},'');return false"
             title="Overview">
              <span id="j_idt20:j_idt22:24:j_idt30:0:_t33">&gt; Overview</span>
          </a>
      </li>

        Activity

        Hide
        Deryk Sinotte added a comment -

        Assigning to Mircea

        Show
        Deryk Sinotte added a comment - Assigning to Mircea
        Hide
        Mircea Toma added a comment -

        Changed JavascriptResourceOutput constructor to assign 'name' and 'library' attributes to the component so that JSF/Mojarra will detect when "jsf.js" component resource was already added.

        Show
        Mircea Toma added a comment - Changed JavascriptResourceOutput constructor to assign 'name' and 'library' attributes to the component so that JSF/Mojarra will detect when "jsf.js" component resource was already added.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Deryk Sinotte
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: