Uncaught ReferenceError: PrimeFaces is not defined

1

I am using primefaces and bootstrap in a login and I get the following error:

Uncaught ReferenceError: $ is not defined
    at login.xhtml:252
(anonymous) @ login.xhtml:252 login.xhtml:260 
Uncaught ReferenceError: PrimeFaces is not defined
    at login.xhtml:260
(anonymous) @ login.xhtml:260

I have tried to include the style sheet in the header, to include a different version of jquery ... nothing works for me!

Attached login code.xhtml:

<html xmlns="http://www.w3c.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
<h:head>

</h:head>

<h:body style="text-align:center">
    <p:growl id="mensajes" showDetail="true" life="2000" />
    <h:form>
        <p:panel header="Login" style="width:300px">
            <h:panelGrid columns="2" cellpadding="5">
                <h:outputLabel for="username" value="Usuario:" />
                <p:inputText value="#{loginBean.nombreUsu}" id="username"
                    required="true" label="username" />
                <h:outputLabel for="password" value="Clave:" />
                <p:password value="#{loginBean.password}" id="password" required="true"
                    label="password" />
                <f:facet name="footer">
                    <p:commandButton id="loginButton" value="Login"
                        actionListener="#{loginBean.submit}" update=":mensajes"
                        oncomplete="manejarLogin(xhr, status, args)" />
                </f:facet>
            </h:panelGrid>
        </p:panel>
    </h:form>
</h:body>

<script type="text/javascript">
    //<![CDATA[ 
    function manejarLogin(xhr, status, args) {
        if (!args.validationFailed && args.estaLogeado) {
            setTimeout(function() {
                window.location = args.view;
            }, 500);
        }
    }
    //]]>
</script>
</html>

EDIT:

I just realized that some documents from primefaces load in state 302 ... this why it happens ???

    
asked by alex 21.08.2017 в 12:13
source

1 answer

-1

Ok, I answer myself ...

I have a filter for the login and you have to include path.startsWith("/javax.faces.resource/") because if not, you can not find jQuery and other folders and it does not start correctly.

Deputy code:

if(usuario != null || path.equals("/login") || path.equals("/login.xhtml") 
  || path.startsWith("/public/") || path.equals("/favicon.ico")
  || path.startsWith("/javax.faces.resource/")){

    if(usuario != null && path.equals("/login.xhtml")){
        res.sendRedirect("/inicio.xhtml");
    }else{
        filterChain.doFilter(request, response);
    }
}else{
    res.sendRedirect("login.xhtml");
}

If we do not do this in this way, it does not load correctly.

    
answered by 21.08.2017 / 13:17
source