I want to inlude <ui:include>
one page dynamically several times.
Code:
<h:dataTable ..>
<h:column>
<ui:include src="#{create_page}">
<h:column>
<h:dataTable>
Now when I submit it persists only the last inlude. It remembers only the values for the last included page. I want unique entity object in each create_page. How can I do that?
The <ui:include>
is as being a tag handler executed during view build time, while the <h:dataTable>
is as being an UI component executed during view render time. This means that the <ui:include>
is executed only once before the <h:dataTable>
and thus not during the iteration. You effectively end up with exactly the same include source in every row. When the form is submitted the rows are processed one by one until the last row, that's why you effectively end up with the values of the last row.
There are basically 2 ways to solve this:
Use <c:forEach>
instead of <h:dataTable>
, this runs also during view build time.
Use a tag file or a composite component instead of <ui:include>
, this runs also during view render time.
Either way, you also need to ensure that the input values are bound to the object behind the var
attribute of the datatable, not to one and same backing bean property.
<ui:include>
falls in the same category as JSTL)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With