2014-03-25 192 views
0

我有一个使用Primefaces正确渲染数据表的probem:渲染只是一个纯文本,没有正常的Primefaces图形(没有替代颜色行等)。 我想明白为什么,因为所有其他几页都很好地呈现在我的网站上。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://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:p="http://primefaces.org/ui"> 

    <h:body> 
    <h:form> 
    <p:dataTable var="c" value="#{viewContattoBean.contatto}"> 
     <p:column headerText="Nome"> 
      <h:outputText value="#{c.contattoid}" /> 
     </p:column> 

     <p:column headerText="Telefono"> 
      <h:outputText value="#{c.numero}" /> 
     </p:column> 
    </p:dataTable> 
    </h:form> 
    </h:body> 
</html> 

这里的XHTML是在web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> 
    <display-name>RubricaWeb</display-name> 
    <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>*.xhtml</url-pattern> 
    </servlet-mapping> 
    <login-config> 
     <auth-method>FORM</auth-method> 
     <form-login-config> 
      <form-login-page>/login.xhtml</form-login-page> 
      <form-error-page>/loginerror.xhtml</form-error-page> 
     </form-login-config> 
    </login-config> 
    <security-constraint> 
     <web-resource-collection> 
      <web-resource-name>Admins Pages</web-resource-name> 
      <description /> 
      <url-pattern>/admin/*</url-pattern> 
     </web-resource-collection> 
     <auth-constraint> 
      <role-name>admin</role-name> 
     </auth-constraint> 
    </security-constraint> 
    <security-constraint> 
     <web-resource-collection> 
      <web-resource-name>Users Pages</web-resource-name> 
      <description /> 
      <url-pattern>/user/*</url-pattern> 
     </web-resource-collection> 
     <auth-constraint> 
      <role-name>user</role-name> 
     </auth-constraint> 
    </security-constraint> 
    <welcome-file-list> 
     <welcome-file>index.xhtml</welcome-file> 
    </welcome-file-list> 
</web-app> 

的问题,就像我已经sayd是我想象像纯文本的表,但内容是正确的(这就是为什么我认为不是有用的向你展示托管bean)。

感谢大家。

+0

您是否应用了主题?如果你没有主题,那么就没有什么样的设计元素,我会害怕知道它是什么样的。看看primefaces中的主题。 – VeenarM

+0

是的,我安装了它。实际上有些页面我通常可视化(带有主题),但其他一些我只看到纯文本。 – Samuele

回答

0

在您的ManagedBean中,您有注释@Named@ManagedBean?有必要在任何视图中使用。

您的变量contatto ViewContattoBean是List类型吗? #{viewContattoBean.contatto}

primefaces数据表的标记值需要数据模型的列表值或实现。

+0

Contatto是一个数组。现在我把它转换成列表,但看起来是错误的,因为它不能部署...这个bean是@ManagedBean ...是不是正确?谢谢 – Samuele

+0

现在确定它与列表部署但它仍然无法正常工作,呈现仍然是纯文本,而其他页面呈现与主题 – Samuele