1

I would like to use PrimeFaces. I followed all the instructions on the webpage

My POM:

<dependency>  
    <groupId>org.primefaces</groupId>  
    <artifactId>primefaces</artifactId>  
    <version>2.0.0</version>  
</dependency> 

[...]

<repository>  
    <id>prime-repo</id>  
    <name>Prime Technology Maven Repository</name>  
    <url>http://repository.prime.com.tr</url>  
    <layout>default</layout>  
</repository> 

Just works I guess! At least the primefaces-2.0.0.jar has been downloaded!

Next my web.xml:

  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>
      javax.faces.webapp.FacesServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>

   <servlet>  
       <servlet-name>Resource Servlet</servlet-name>  
       <servlet-class>  
           org.primefaces.resource.ResourceServlet  
       </servlet-class>  
   </servlet>  

   <servlet-mapping>  
       <servlet-name>Resource Servlet</servlet-name>  
       <url-pattern>/primefaces_resource/*</url-pattern>  
   </servlet-mapping>   

I use tomcat 6 and so far I know it doesn't support servlet 3.0 that's why I have to add a servlet.

Next my xhtml codes:

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.prime.com.tr/ui" >
    [...]
    <p:editor value="#{projectData.description}" width="640px" height="320px"></p:editor> 

So far, it's not being rendered. Where is my mistake?

Sven
  • 6,288
  • 24
  • 74
  • 116
  • Before doing anything else, upgrade to the latest release (2.1)! 2.0.0 is _really_ old... – egbokul Aug 30 '10 at 10:22
  • Oh thank you for that information, couldn't find a version log on the website – Sven Aug 30 '10 at 11:15
  • @Sven, its been long time since you have posted this question, but currently I am at your stage. My simple primefaces application is not getting displayed properly in browser. How did you solved your problem? If possible have a look at my question http://stackoverflow.com/questions/7219372/simple-primefaces-application-not-working – Shekhar Aug 28 '11 at 07:43

4 Answers4

2

This can happen if you don't request the page through the url-pattern of the FacesServlet. If it is mapped on for example*.jsf, then you need to ensure that your request URL matches it. I.e. open the page by http://example.com/context/page.jsf and thus not by http://examlpe.com/context/page.xhtml.

If that doesn't help, then the firstnext step is to read the server logs for any errors or warnings. Also, checking the generated HTML output (rightclick browser, View Source) if the <h:head> and <h:body> are been parsed into <head> and <body> may give hints about if the FacesServlet is doing its job well or not.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I am not sure I have got what you meant. I posted my FacesServlet declaration, so you can take a look. I request the page through the url-pattern (I think) – Sven Aug 30 '10 at 11:32
1

Tomcat is a simple servlet container, and doesn't contain JSF2 jars. Primefaces is just a component suite on top of the base JSF2 installation (could be Sun's RI: Mojarra, or Myfaces). First you have to download and configure either of those, and then Primefaces will work.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
egbokul
  • 3,944
  • 7
  • 36
  • 54
0

I read the installation page and it seems that you need this to occur somewhere inside the <html> tag:

     <head>  
         <p:resources />  
     <head>
amphetamachine
  • 27,620
  • 12
  • 60
  • 72
  • 1
    Thank you. But I am using JSF2 and the installation page says: 'If you're using PrimeFaces 2.x with JSF you can skip this section as native JSF2 apis are used in this case.' But anyways I tried it and it doesn't solve the problem. – Sven Aug 30 '10 at 09:00
0

Make sure that you have an <h:head> element in your page and not just <head> since this is required by primefaces

aseychell
  • 1,794
  • 17
  • 35