1

I've posted here earlier about how to make a tic tac toe for two users using jsf and I got the link for this great taglib, Primefaces. It's absolutely perfect for what I need to do, but I'm being stuck on trying to make it do anything, even render the examples from their website.

So I've been following this tutorial I found (sadly, there aren't many of them on the subject of Primefaces): http://java.dzone.com/articles/primefaces-quickstart-tutorial Step by step, I made everything according to this tutorial, yet when I run it, it renders an empty page every time.

So I tried a simpler example from the official website: http://www.primefaces.org/gettingStarted.html

This (test.xhtml):

 <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>    
<p:spinner />   
</h:body>
</html>

renders an empty page, while this:

 <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>
test test test test
<p:spinner />   
</h:body>
</html>

renders only the "test test test test" text.

So I guess the problem must be in the tags, tomcat doesn't see them/doesn't know how to interprete them. But, according to the tutorial and the primefaces website all I need to do is to put the jars in WEB-INF/lib as I have done (by the way, I'm using Eclipse and the empty project I created was "Dynamic Web Project"). In my WEB-INF/lib I have the following jars:

jsf-api-2.0.3.jar

jsf-impl-2.0.3.jar

jstl-1.0.2.jar

primefaces-3.3.RC1.jar

If it's of any help, here's the content of the tomcat console:

    2012-05-27 13:18:11 org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in                         production environments was not found on the java.library.path:         .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
    2012-05-27 13:18:12 org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Primefaces1' did not find a matching property.
    2012-05-27 13:18:12 org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    2012-05-27 13:18:12 org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 1127 ms
    2012-05-27 13:18:12 org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    2012-05-27 13:18:12 org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
    2012-05-27 13:18:13 com.sun.faces.config.ConfigureListener contextInitialized
    INFO: Initializing Mojarra 2.0.3 (SNAPSHOT 20100726) for context '/Primefaces1'
    2012-05-27 13:18:17 org.primefaces.webapp.PostConstructApplicationEventListener processEvent
    INFO: Running on PrimeFaces 3.3.RC1
    2012-05-27 13:18:17 org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    2012-05-27 13:18:17 org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    2012-05-27 13:18:17 org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/63  config=null
    2012-05-27 13:18:17 org.apache.catalina.startup.Catalina start
    INFO: Server startup in 5096 ms

What can be the case? Am I putting the jars in wrong place, is it a tomcat failure or maybe something else entirely?

Natalia Zoń
  • 980
  • 2
  • 12
  • 22

1 Answers1

1

Ok, I solved it, maybe someone will someday find this useful.

So, when using Primefaces with JSF, not only the webpage files have to have the .xhtml extension (a solution I've found here: http://www.coderanch.com/t/473437/JSF/java/not-allowed-template-text), but also the web.xml file must be modified (a solution I've found here: Simple primefaces application not working), like this:

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

Now it works perfectly well.

Community
  • 1
  • 1
Natalia Zoń
  • 980
  • 2
  • 12
  • 22
  • This problem is not strictly related to PrimeFaces, but to basic JSF in general. You would have exactly the same problem when not using PrimeFaces. Rightclick page in browser, *View Source*, you'll see that standard JSF tags like `` and so on are **also** unparsed when the request did not invoke the `FacesServlet`! – BalusC May 27 '12 at 17:30
  • Can you explain step by step, how to implement Tic Tac Toe using JSF and primefaces @Natalia Zon – spt Oct 09 '12 at 12:11