Hello,
A similar problem as discussed in this thread.
How is the following possible in JSF: (note, read the code below as
pseudo code..., a ui:repeat could be a t:dataTable)
<ui:repeat var="customer" value="#{customerBean.customers}" >
Customer: #{customer.id} - #{customer.name} -
<ui:repeat var="office" value="#{officeBean.offices}">
Office: #{office.id}
</ui:repeat>
</ui:repeat>
where officeBean.offices should take #{customer.id} as a property. So
for each customer displayed, display that customers' offices.
When I define officeBean as managed bean with a property for customerId,
I see that for all customers the same id is sent (i.e. the first one). I
think it is similar to the issue discussed before in this thread, that
when the component is built with the values are bound at that time. The
resolution at that time was to use 'rendered' attribute for components,
but how can we resolve this issue where another managed-bean's method
needs to be invoked in a loop and the current value in the loop needs to
be provided as a porperty for inner invoked method?
I also tried to define the inner manged bean with scope of 'none',
assuming that for each invocation it will be created and it will pickup
the value at that instant.. but I get the following exception:
Property [propertyName] references object in a scope with shorter
lifetime than the target scope none
Thanks
MRather
M Rather wrote:
Thanks Andrew,
I got the desired output using the rendered attribute. Though I will
test out limitRendered tag as well, I am getting some compile errors
on 1.1.7 sandbox snapshot (mvn dependencies).
For those who might see this thread, below is the code that works..
==================== ui:repeat with rendered=================<br/>
<ui:repeat var="customer" value="${customers}" >
${customer.id} - ${customer.name} -
<ui:fragment rendered="#{customer.id eq 1}">
YES
</ui:fragment>
<ui:fragment rendered="#{customer.id ne 1}">
NO
</ui:fragment>
<br/>
</ui:repeat>
==================== ui:repeat with
rendered=================<br/><br/><br/>
and this is the generated result, as desired
==================== ui:repeat with rendered=================
1 - cust1- YES
2 - cust2 - NO
3 - cust3 - NO
4 - cust4 - NO
5 - cust5 - NO
6 - cust6 - NO
7 - cust7 - NO
8 - cust8 - NO
9 - cust9 - NO
==================== ui:repeat with rendered=================
-MRather