我试图在datatable中显示对象列表的下面列表。但没有任何东西出现。非常感谢帮助!
public class TimrsDisplayBean {
private static final long serialVersionUID = 1L;
private String teamName = "";
private String teamType = "";
private boolean reported;
private boolean noProd;
private boolean missing;
public String getTeamName() {
return teamName;
}
public void setTeamName(String teamName) {
this.teamName = teamName;
}
public String getTeamType() {
return teamType;
}
public void setTeamType(String teamType) {
this.teamType = teamType;
}
public boolean getReported() {
return reported;
}
public void setReported(boolean reported) {
this.reported = reported;
}
public boolean getNoProd() {
return noProd;
}
public void setNoProd(boolean noProd) {
this.noProd = noProd;
}
public boolean getMissing() {
return missing;
}
public void setMissing(boolean missing) {
this.missing = missing;
}
}
XHTML文件
<p:dataTable value="#{dashboardMBean.timrsDisplayDataList}" var="var" rowIndexVar="row"
styleClass="large-card-datatable alternatingRowTable no-border nowrap">
<f:facet name="header">
<span class="updateDate"> </span>
</f:facet>
<p:column headerText="Type" value=" #{dashboardMBean.timrsDisplayDataList[0]}" columnIndexVar="i">
#{var[i].teamType}
</p:column>
<p:column headerText="Type" value=" #{dashboardMBean.timrsDisplayDataList[0]}" columnIndexVar="i">
#{var[i].teamName}
</p:column>
答案 0 :(得分:0)
如果可能,请支持完整的代码部分。您的datatable
代码甚至没有完成。
var
命名每个元素/行,如Primefaces展示中所示:
http://www.primefaces.org/showcase/ui/data/datatable/basic.xhtml
在你的情况下,它会像
<p:column headerText="Type">
<h:outputText value="#{var.teamType}"/>
</p:column>
另外,正如Jasper De Vries所说,没有名为columnIndexVar
的属性。删除它以防止出现异常行为。
如果这还不够,您需要共享一些ManagedBean的代码。不确定您发布的java类是否代表您的Bean,但如果是,则需要将其声明为ManagedBean,如
@ManagedBean(name = "timrsDisplayBean)
@SessionScoped
public class TimrsDisplayBean {
我希望这有帮助!