Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When <ui:repeat> works for X but <c:forEach> works for Y

Tags:

java

jsf

jstl

I use <c:foreach> in my jsf app to iterate over a list of people. I don't use <ui:repeat> because every person has its own tab (primefaces). JSF hero 'BalusC' already helped my out on this one link. Now I tried to save (postback) the data. This doesn't work with <c:forEach>, the approriate setter of the Person object gets never called. With <ui:repeat> it works. Obviously I haven't grasped the difference between the two tags so I would appriciate some enlightenment.

Thanks

Marcel

like image 200
Marcel Menz Avatar asked Nov 18 '10 10:11

Marcel Menz


2 Answers

<c:forEach> does not build JSF tree nodes on the server. You can see this directly in the html, the inputs do not have the usual long and distinct id="j_12:customerTabPanel:j_34:customerName".

Please, read this:

https://rogerkeays.com/jsf-c-foreach-vs-ui-repeat

like image 186
mcosta Avatar answered Oct 21 '22 13:10

mcosta


<c:***> tags are build-time tags, as <ui:***> are rendered-time tags. To get the difference between these two concepts, I recommand you to read the two links below:

  • <c:forEach> vs <ui:repeat>
  • Why <ui:repeat> does not work?
    (editor's note (2013-01-03: dead link)
like image 33
Romain Linsolas Avatar answered Oct 21 '22 13:10

Romain Linsolas