Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser error: PrimeFacesExt is not defined

Im using PrimeFaces 3.5 with PrimeFaces Extensions 0.7.0 and OmniFaces version 1.4

I have a accordionPanel with a ui:fragment witch looks like that:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"
    xmlns:pe="http://primefaces.org/ui/extensions"> 
<ui:fragment>

    <f:metadata>
        <f:event type="javax.faces.event.PreRenderViewEvent" listener="#{fleet.preRenderView()}" />
    </f:metadata>

    <!-- Other things.... -->

    <!-- Dialogs -->
    <p:dialog id="createSubFleetDialog" widgetVar="createSubFleet"
        header="#{msg.administration_fleet_createFleetDialog_title}">
        <h:panelGrid id="createSubFleetPanel" columns="2">

            <!-- Here im using primefaces extensions -->

            <h:outputLabel for="newFleetName" value="#{msg.administration_fleet_fleetName}" />
            <p:inputText id="newFleetName" value="#{fleet.fleetName}">
                <pe:keyFilter mask="alphanum"></pe:keyFilter>
            </p:inputText>

        </h:panelGrid>
    </p:dialog>


</ui:fragment>
</html>

There is no warning or error in eclipse but when running my application there is a browser error: Uncaught ReferenceError: PrimeFacesExt is not defined

Does anybody know how how to fix this problem?

like image 252
Gatschet Avatar asked Mar 21 '23 12:03

Gatschet


2 Answers

I was have same issue, but i found working workaround for it in this link : http://forum.primefaces.org/viewtopic.php?f=14&t=36652

Seems the issue is :

It seems primefaces ext js files are not loaded unless we use at least one ext tag.

Since i was not using one on the main page..but it was in a dynamic ui:include, it was loading only after a hard refresh of main page.

So you can add dummy pe tag in your main template just after <h:body> like this :

<pe:blockUI></pe:blockUI>

Or like :

<pe:inputNumber style="display:none" />

Its worked for me actually.

like image 139
Al-Mothafar Avatar answered Mar 23 '23 02:03

Al-Mothafar


Facing this issue, we found that a cleaner fix was to simply add this line in the <h:head> tag in the main template:

<h:outputScript library="primefaces-extensions" name="primefaces-extensions.js"/>

No need to add the xmlns:pe namespace, no need to add a dummy tag!

like image 24
papyreno Avatar answered Mar 23 '23 01:03

papyreno