primefaces: Dynamic Resource loading doesn't work with Mojarra 2.2

1) Environment

  • PrimeFaces version: 6.2.3
  • Does it work on the newest released PrimeFaces version? Version? no
  • Application server + version: Tomcat v8.0
  • Affected browsers: all
  • Mojarra version 2.2.15, 2.2.16, 2.2.17

2) Expected behavior

When using p:inputNumber inside c:if tag, “loaded to page by ajax” the javascripts should work properly.

3) Actual behavior

Browser’s console shows JS error: Widget not available: InputNumber and the inputs are not formatted correctly (formatting function with thousand delimiter, currency etc. is not invoked).

If there was p:inputNumber component in the page on page-load, the JS would work. In this example there is no p:inputNumber in page on load and the component is added using ajax request. The inputnumber/inputnumber.js is “transfered” to the client browser but it is somehow broken.

In Mojarra versin 2.3.2 it works well, but I can’t upgrade.

4) Steps to reproduce

Alter PF showcase using XHTML and Java code below. Go to inputNumber.xhtml and click “crash button”. Observe browser’s javascript console.

5) Sample XHTML

Altered showcase inputNumber.xhtml: Added button which updates panel containing c:if tag. At page load, the inputNumberView.flag is false. After ajax update it is true.

<h:form>
        <p:commandButton process="@this" update="@form:updatedPanelGrid" value="crash" 
            action="#{inputNumberView.setFlag(true)}"/>
        <p:panel id="updatedPanelGrid">
            <c:if test="#{inputNumberView.flag}">
              <p:panelGrid class="ui-noborder">  
                  <f:facet name="header">  
                      <p:row>  
                          <p:column style="font-weight: bold;">inputNumber</p:column>  
                          <p:column style="font-weight: bold;">Numeric Value</p:column>  
                          <p:column style="font-weight: bold;">Description</p:column>  
                      </p:row>  
                  </f:facet>
                  <p:row>  
                      <p:column>  
                          <p:inputNumber id="input1" value="#{inputNumberView.input1}">  
                          </p:inputNumber>  
                      </p:column>  
                      ......

                  </p:row>
                </p:panelGrid>
              </c:if>
            </p:panel>
        </h:form>

6) Sample bean

Add this code to InputNumberView.java:

private boolean flag = false;

public boolean isFlag() {
    return flag;
}

public void setFlag(boolean flag) {
    this.flag = flag;
}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I will report under my PRO account to get it merged.

The problem is the following: https://github.com/primefaces/primefaces/issues/2303

we removed async=false, so the script is executed after our widgets initialization.

Did you clean up your browser caches as well? Just to ensure you don’t have a broken JS in your cache…