JSF ui:repeat vs h:dataTable [英] JSF ui:repeat vs h:dataTable
问题描述
在问这个问题之前,我拜访了许多其他相关问题,并试图收集最多的信息.但是,到目前为止,我发现我发现ui:repeat
和h:dataTable
之间没有真正/主要的区别,并且每当我们可以使用h:dataTable
时,我们也可以使用ui:repeat
(有时其中一个是彼此之间没有什么复杂,但是最后我们得到了相同的结果.
Before asking this question, I visited many other related ones and tried to gather the maximum of information. But, what I found till now let me understand that there is no real/major difference between ui:repeat
and h:dataTable
, and that whenever we can use h:dataTable
we can also use ui:repeat
(sometimes one of them is a little complex than the other, but at the end we got same results).
那么,在所有用例中,唯一的选择就是使用h:dataTable
吗?或相反(唯一选择是ui:repeat
)?
So, is there any use cases where the only choice is to use h:dataTable
? or the opposite (only choice is ui:repeat
)?
推荐答案
在任何情况下,唯一的选择就是使用h:dataTable?
- 如果要使用
UIData
为基础的组件(UIRepeat
中不存在其所有特殊属性). - 如果要通过JSF组件呈现HTML
<table>
. - 如果您希望能够自定义
<table>
渲染(例如PrimeFaces<p:dataTable>
会进行排序,过滤,分组,折叠,延迟加载等). - 如果您不使用Facelets作为查看技术.
- If you want to use an
UIData
-based component (with all of its special attributes absent inUIRepeat
). - If you want to render a HTML
<table>
by a JSF component. - If you want to be able to customize the
<table>
rendering (like PrimeFaces<p:dataTable>
does with sorting, filtering, grouping, folding, lazyloading, etc, etc). - If you aren't using Facelets as view technology.
- 如果您不希望以上任何内容,因此需要一个纯净的无标记迭代组件.
- 如果您希望能够在迭代过程中跳过每个 n 个项目(使用
step
属性). - If you don't want any of above and thus need a pure markup-less iteration component.
- If you want to be able to skip every n items during iteration (using
step
attribute).
或相反(唯一选择是ui:repeat)?
这篇关于JSF ui:repeat vs h:dataTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!