[英]How to show string array in primefaces datatable?
i'm working on a project with JSF and PrimeFaces. 我正在与JSF和PrimeFaces进行一个项目。 In this project i have to show a string array on datatable. 在这个项目中,我必须在数据表上显示一个字符串数组。
View: 视图:
<p:dataTable id="table" var="String" value="#{readData.tuples}" scrollRows="50" scrollable="true" liveScroll="true" scrollHeight="150">
<h:outputText value="String"/>
</p:dataTable>
Bean: 豆角,扁豆:
List<String[]> allRows = new ArrayList<>();
List<String> tuples = new ArrayList<>();
public String fill() {
String s = "";
for (String[] tuple : allRows) {
for (String string : tuple) {
s += string + " ";
tuples.add(s);
}
s = "";
}
return "tables.xhtml";
}
I want to show allRows String[] list as columns and rows. 我想将allRows String []列表显示为列和行。 Every string array on list will be a row, every element of string[] will be in columns. 列表中的每个字符串数组都将是一行,string []的每个元素都将在列中。 Or showing tuples list on datatable as every string as a row, it'll work too. 或者在数据表上将元组列表显示为每个字符串作为一行,它也将起作用。
How can i do that? 我怎样才能做到这一点?
try 尝试
<p:dataTable id="table" var="string" value="#{readData.tuples}" scrollRows="50" scrollable="true" liveScroll="true" scrollHeight="150">
<p:column>
<h:outputText value="#{string}"/>
</p:column>
</p:dataTable>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.