PrimeFaces TypeError: PF(...) is undefined

In my case, I found that my TypeError: PF(...) is undefined error (without the additional property error) was caused by Primefaces not being able to find the widget widgetVar="usersTable" for example because of a spelling error

In this case, the console output right above the error in Firebug gives you the explanation Widget for var 'editExecContactDialogg' not available!


That can happen when the runtime classpath is dirty of duplicate different versioned libraries. Conflicts would then occur during class loading and resource resolving.

Make sure that you're using only one version of a library. This not only applies to PrimeFaces, but also to Mojarra. Having both 2.2.8 and 2.2.10 is definitely not right.


Like @hendinas' answer, this is not the solution to the particular problem, but might be helpful for future Googlers that have the exact same error but with a different cause.

This is an additional case of @hendinas' answer, but where the thing you're referring to is not found because it does not have the same rendered conditions. Here is an example.

<ui:repeat id="extSyses" var="extSys" value="${cc.attrs.externalSystems}"
        varStatus="extSysLoop">
    <h:commandButton
        id="YesButton" value="Yes" type="button"
        rendered='#{(rptBean.canEditReport or rptBean.canAnnotateReport) and not extSys.closed)}'
        onclick="PF('#{cc.attrs.prefix}yesDlg#{extSysLoop.index}').show()" />

    <p:dialog id="extDocDlg" header='Enter document reference number'
        rendered='#{rptBean.canEditReport and not extSys.closed)}'
        widgetVar="#{cc.attrs.prefix}yesDlg#{extSysLoop.index}"
        width="650" minWidth="650" modal="true">
       ... Dialog Content ...
    </p:dialog>
</ui:repeat>

In this case, the widgetVar matched the value of onclick, so that was good. However, the rendered clause differed. If canEditReport was true, then everything worked fine. However, if canAnnotateReport was true, then the button would show up but it would have no dialog to display! When the button is clicked, the TypeError: PF(…) is undefined message is displayed.

In this example, the solution is to make the rendered clauses the same for both the button and the dialog it refers to.

Tags:

Jsf

Primefaces