Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
844 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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...