Reputation: 1979
I have a requirement in which my view object is returning a comma separated list in one of the columns for the query.
On the UI I need to implement a for each system such that when the screen renders, the content displayed in the for each is based on the length and value of the elements in the comma separated list.
An example can be seen as below:
the element inside the for each is (+) for 1 and (-) for 0
if value returned: 1,0,0,1 so the out put should be (+)(-)(-)(+)
if value returned: 1,1,0,1 so the out put should be (+)(+)(-)(+)
if value returned: 1,1,0,0 so the out put should be (+)(+)(-)(-)
and so on.
please suggest what can be done for the same.
Thanks in advance
Upvotes: 1
Views: 1570
Reputation: 6252
Firstly you need to convert the comma separated string into a List so that it can be used in an <af:iterator>
.
Then within the <af:iterator>
you can use a <af:switcher>
something like below:
<af:iterator value=#{myBean.myList}" var="elem">
<af:switcher facetName="#{elem}">
<f:facet name="1">
<af:outputText value="(+)"/>
</f:facet>
<f:facet name="0">
<af:outputText value="(-)"/>
</f:facet>
</af:switcher>
</af:iterator>
Upvotes: 1