"PrimeFaces is not defined" error

21,759

Solution 1

If you didnt have a head tag you will get that error.

Primefaces requires a head tag to work.

See #2 on their faq

http://primefaces.org/faq.html

Solution 2

This was a minor defect and fixed in 3.2. final;

http://code.google.com/p/primefaces/issues/detail?id=3670

Solution 3

This will also happen if you are not allowing access to

${webapp}/javax.faces.resources/**

Check your security XML configuration.

The JavaScript error that Primefaces is not defined.

Solution 4

try this... (if this does not work its probably a bug - open a ticket on issue tracker...)

<html xmlns="http://www.w3.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>  
     <h:form>
      <h:commandButton id="btn" value="Print">
        <p:printer target="output" />
      </h:commandButton>
      <h:outputText id="output" value="PrimeFaces Rocks!" />

      <h:outputLink id="lnk" value="#">
          <p:printer target="image" />
          <h:outputText value="Print Image" />
      </h:outputLink>
      <p:graphicImage id="image" value="/images/nature1.jpg" />

      </h:form>   
    </h:body>  
</html>  

listen... primefaces are using the jqprint jquery plugin.... You might be better try use it directly while waiting for a official primefaces response...

Solution 5

You need to add the PrimeFaces namespace.

xmlns:p="http://primefaces.org/ui"  

Have a look at the PrimeFaces Getting Started guide.

Share:
21,759
Eric
Author by

Eric

A junior programmer

Updated on September 20, 2020

Comments

  • Eric
    Eric over 3 years

    I am trying to print using the PrimeFaces printer functionality. I have created a new GlassFish 3 Java EE project and added the PrimeFaces 3.1.1 .jar file.

    The code I am using currently is as follows:

    <html xmlns="http://www.w3.org/1999/xhtml" 
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:p="http://primefaces.org/ui">
    
      <h:head>
        <title>Facelet Title</title>
      </h:head>
      <h:body>
        <h:form>
          <h:outputText id="a" value="AA" />
          <h:commandLink id="btn" value="Print">
            <p:printer target="a" />
          </h:commandLink>
        </h:form>
      </h:body>
    </html>
    

    Unfortunately, the print function isn't working. Instead, the FireBug console shows me the following error:

    PrimeFaces is not defined