在JSF数据表中显示嵌套数组列表的值 [英] Displaying the values of a nested array list in JSF data table
问题描述
自从我开始使用JSF开发网页以来已经有一段时间了,但是我仍然在学习大多数内容.现在我有一个有趣的问题
Its been quite some time since i have started developing web pages using JSF but i am still learning most of the stuff. Now I have an interesting question
当我拥有要在ArrayList的数据表中显示的值并且将那些ArrayList对象添加到另一个数组列表中时,那么现在我将如何在数据表中显示它们.
When I have the values those to be displayed in a data table in the ArrayList and I am adding those ArrayList objects in another array list , so now how will i be able to display them in a data table.
我正在执行此操作,因为,我需要使表如此动态,以至于我不知道要在页面中显示的结果集中要获得多少列,因此我无法使用Bean obj来存储我的可变值.所以我决定要有类似的东西
I am doing this since , i need my table to be so dynamic so that i dont know how many columns will i be getting in the result set to be displayed in the page, hece i cannot have a Bean obj for storing my variable values. So i have decided to have something like
ArrayList<ArrayList<String>>
ArrayList<String> - Values for Each row
这是否有可以在jsf页面中提供的解决方案
Does this have a solution that can be provided int he jsf page
推荐答案
使用带有嵌套<ui:repeat>
<table>
<ui:repeat value="#{bean.rows}" var="row">
<tr>
<ui:repeat value="#{row}" var="column">
<td>#{column}</td>
</ui:repeat>
</tr>
</ui:repeat>
</table>
或使用 PrimeFaces 和战斧和 <t:columns>
.
or grab a 3rd party component library which has sort of a <x:columns>
tag like PrimeFaces with <p:columns>
and Tomahawk with <t:columns>
.
<p:dataTable value="#{bean.rows}" var="row">
<p:columns value="#{row}" var="column">
#{column}
</p:columns>
</p:dataTable>
无论哪种方式,您都可以将这些列保存在单独的列表中.
Either way, you can even keep the columns in a separate list.
这篇关于在JSF数据表中显示嵌套数组列表的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!