4

I'm developing a JSF web application with PrimeFaces 3.5 on Eclipse 4.3. There are no compiletime or runtime errors and the application deploys successfully. However, I cannot get the desired output in browser. The PrimeFaces components do not show up, while the standard JSF components do.

I'm not sure if I configured everything right. The PrimeFaces JAR is at least inside /WEB-INF/lib:

enter image description here

And the PrimeFaces XML namespace is declared as xmlns:p="http:\\primefaces.org\ui"

enter image description here

And I mapped the FacesServlet on *.xhtml:

enter image description here

Here's the full source code of login.xhtml:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <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:body>  
<h:head ><title>Login Page !!</title></h:head>
 <h:form>  
<p:panel id="panel" header="Login Panel" style="margin-bottom:10px;">  

    <h:panelGrid columns="3">  
        <h:outputLabel  value="User Id:" />  
        <p:inputText id="id" value="loginBean.id" required="true" requiredMessage="ID required"/>  
        <p:message for="id" />

        <p:outputLabel value="User Name:" />  
        <p:inputText id="name" value="loginBean.name"  required="true" requiredMessage="Name required" />  
        <p:message for="name" />
    </h:panelGrid>  
</p:panel>  
<p:commandButton type="Submit" value="Submit" action="#" style="margin-right:20px;" />  

`

The output looks like this:

enter image description here

As you see, <h:outputText> did its job, but none of <p:xxx> show up. How is this caused and how can I solve it?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
kark
  • 4,763
  • 6
  • 30
  • 44
  • No, it is not rendering an empty page. As you see, the page is partly rendered. My guess is that an exception is thrown, what does the server log say? Also, edit your question and replace the code screenshots with actual code. – Magnilex Aug 27 '13 at 10:30
  • don't post images for code..... – Zaheer Ahmed Aug 27 '13 at 10:58

4 Answers4

9

This is not directly answer on this question, but it's related to it. I want to share my experience with the problem "PrimeFaces tags not rendering". I am developing JSF 2.2 app on WildFly, and here is my index.xhtml:

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

<h:body>
    <h:form>
        <p:editor value="#{mDb.newMessage.content}"></p:editor>
    </h:form>
</h:body>
</html>

When an app is running, the editor doesn't appear, and this was very strange to me, because PrimeFaces was configured correctly in project.

I accidentally discovered cause of problem. There was not a h:head tag in index.xhtml. When I put head tag, PrimeFaces components rendered successfully!!

I hope this could help someone.

akelec
  • 3,797
  • 3
  • 41
  • 39
5

As to the cause of your concrete problem of PrimeFaces components not being rendered, as per the screenshot, you have a leading blank space in PrimeFaces taglib URI:

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

This is significant and thus wrong. Get rid of it:

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

This way the PrimeFaces components must be parsed and appear in the HTML output.

For the remainder I strongly recommend you to go through a sane JSF2 tutorial first. You're making several conceptual mistakes which are already covered by a decent Hello World example. Start at our JSF wiki page. Those mistakes do however not have this "blank page" as consequence. They will cause different problems (e.g. CSS/JS not functioning and form submit not working). If you still stucks on that, you should essentially be asking a new question.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Ya the http://stackoverflow.com/tags/jsf/info startup tutorial is very nice to read and which is exactly i was looking for.. – kark Aug 27 '13 at 11:21
0

1.
When ever you are referring to Managed Bean properties from JSF components, use correct syntax for JSF EL statements.

#{bean_name.property}

In your code you are forgetting to provide #{}.
For example at line #15 in login.xhtml use :

<h:inputText id="id" value="#{loginBean.id}" required="true" requiredMessage="ID required"/>

2.
You are keeping <h:head> inside <h:body>. Its not a good practice.
Keep <h:head> out side <h:body>.
Actual structure would be:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

     <h:head>
        <title></title>
     <h:head>   

     <h:body>
       <!-- Your Code -->
     </h:body>
</html>

3.
You may be getting exception in ManagedBean LoginBean.java class.
Please post the code instead of screenshots.

Kishor Prakash
  • 8,011
  • 12
  • 61
  • 92
  • the bean configuration are correct and which is working very well..see the Accepted answer..silly mistake i did... – kark Aug 27 '13 at 11:18
-3

if you build your proeject mit maven remember to include a dependency of primefaces lib into pom.xml

best regards

marco
  • 1