Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
912 views
in Technique[技术] by (71.8m points)

jsf 2 - PrimeFaces components don't display while standard JSF components render fine

Java EE6/CDI JSF2 Primefaces 3.3.1. I created a search page with a few cascading dropdowns that are used to generate a table of search results If I use jsf:

<h:dataTable  var="_employeeVList" value="#{employeeVProducer.employeeVList}"  rendered="#{not empty employeeVProducer.employeeVList}"> 
    <f:facet name="header">  
        Employee Search Results 
    </f:facet>
    <h:column>
        <f:facet name="header">Area</f:facet>
        <h:outputText value="#{_employeeVList.areaName}" />
    </h:column>
    ...
</h:dataTable>

The table renders with output, html looks normal. But when I change to primefaces:

<p:dataTable  var="_employeeVList" value="#{employeeVProducer.employeeVList}"  rendered="#{not empty employeeVProducer.employeeVList}"> 
    <f:facet name="header">  
        Employee Search Results 
    </f:facet>
    <p:column>
        <f:facet name="header">Area</f:facet>
        <h:outputText value="#{_employeeVList.areaName}" />
    </p:column>
    ...
</p:dataTable>

The table doesn't display. When I look at the source with firebug I see some weirdness with the html:

    <table id="searchForm:results">
    <tbody>
    <tr>
    <td>
    <p:datatable rendered="true" value="[com.raytheon.myPkg.EmployeeV@f486,                                 com.raytheon.myPkg.EmployeeV@88fe,                              com.raytheon.myPkg.EmployeeV@adaf, 
                                          ...
                                com.raytheon.myPkg.EmployeeV@6a5b]" 
var="_employeeVList">
    <p:column></p:column>
    <p:column></p:column>
    ...                          
    </p:datatable></td>
    </tr>
    </tbody>
    </table>

The objects are in the tag label, the columns are empty. Elsewhere in the page I'm using p:panelGrid, that contains the dropdowns and that displays correctly.

I have h:head and h:body in my default template page.

The table is backed by a stateful request scoped bean.

I'm not using any external JavaScript.

What am I doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Thus, the <p:xxx> tags are not been parsed as JSF tags at all and appear plain vanilla in the generated HTML output. That can have one or more of the following reasons:

  1. You forgot to declare the p: XML namespace in the view, or you used the wrong namespace URI. It should be:

    xmlns:p="http://primefaces.org/ui"
    
  2. You forgot to actually install the PrimeFaces library. It should be a matter of either

    a. Dropping primefaces.jar in webapp's /WEB-INF/lib folder.

    b. Making sure your dependency manager (e.g. Maven) has been configured to add PrimeFaces to the project and added it to the runtime /WEB-INF/lib folder


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...