JSF ui:repeat vs h:dataTable
Asked Answered
N

1

5

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).

So, is there any use cases where the only choice is to use h:dataTable? or the opposite (only choice is ui:repeat)?

Noland answered 9/3, 2015 at 13:48 Comment(0)
W
7

is there any use cases where the only choice is to use h:dataTable?

  • If you want to use an UIData-based component (with all of its special attributes absent in UIRepeat).
  • 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.

or the opposite (only choice is ui:repeat)?

  • 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).
Worth answered 9/3, 2015 at 14:10 Comment(3)
Thanks @Worth for your prompt answer. one last question, is there an alternative way in h:datatable regarding the step attribute of ui:repeat ?Noland
There isn't (apart from just preparing the model the view needs) . Updated answer.Worth
Wait, datatable isn"t part of the facelet view technology ? I thought facelet was englobing every ui, f and h.Drain

© 2022 - 2024 — McMap. All rights reserved.