2013-06-12 148 views
0

我已經開發了一個使用JSF和PrimeFaces的應用程序。我在Facelets頁面中遇到了一個問題,其中<p:xxx>標記未顯示在頁面中。這是我的Facelets頁面顯示標籤,文本框和按鈕。只有標籤顯示在頁面:PrimeFaces組件不會呈現

<!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://primefaces.org/ui" 
     xmlns:ui="http://java.sun.com/jsf/facelets" 
     xmlns:i="http://primefaces.prime.com.tr/touch" 
     xmlns:p="http://primefaces.org/ui"> 
<h:head></h:head> 
<body> 
<ui:composition template="/templates/template.xhtml"> 
    <ui:define name="content"> 
    <h:form> 

     <h:outputLabel for="curator" value="Name:" style="font-weight:bold"/> 

     <p:inputText id="curator" value="#{user.curator}" /> 

     <p:commandButton value="Submit" update="display"/> 
</h:form> 
    </ui:define> 
</ui:composition> 
</body> 
</html> 

我的web.xml文件

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 
    <display-name>Cation</display-name> 

    <context-param> 
     <param-name>javax.faces.PROJECT_STAGE</param-name> 
     <param-value>Development</param-value> 
     </context-param> 
    <welcome-file-list> 
     <welcome-file>faces/login.xhtml</welcome-file> 
    </welcome-file-list> 

    <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>/faces/*</url-pattern> 
    </servlet-mapping> 
    <listener> 
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> 
    </listener> 
</web-app> 

這是怎麼造成的,我該怎麼解決呢?

+0

請檢查您的classpath中是否包含Primefaces jar,並嘗試將'body'更改爲'h:body' –

+0

@LaabidiRaissi:對於body,在之外的任何內容是**忽略**,因此與問題無關。重要的是OP沒有顯示的主模板文件'/ templates/template.xhtml'。 – BalusC

+0

是的,你是對的BalusC。 @ user2476979請將模板顯示爲BalusC提到的模板,並且檢查服務器日誌,如果Primefaces jar包含在classpath中,它通常會打印一些關於所使用的PF版本的信息 –

回答

0

看來標籤顯示,因爲它是一個H標籤,而其他標籤是P,所以第一關,請檢查您primefaces罐子是否通過檢查項目中的Libraries(如果使用NetBeans)實施或Java Resources\Libraries如果蝕。 xmlns:p="http://primefaces.org/ui"不足以使primefaces正常工作,它僅指定命名空間。

注意:您標記primefaces-extensions,我覺得primefaces標籤是你的情況更爲重要。