Reputation: 1889
Assuming in my backing bean:
String x []= ....
public String [] getOutput { return this.x;}
public String getOutputAsString(){ return Arrays.asString(x);}
then in the output page we get the output :
#{ myBackingbean.outputAsString }
My question is how to eliminate that getOutputAsString()
and outputting directly in the ouput page :
I could do just
#{ myBackingbean.output[0])
but for a looping example ?? Imagine something like
for ( i to #{myBackingbean.ouput.length; ){
#{myBackingbean.ouput [i]; }
}
How to do that?
Thanks
Upvotes: 1
Views: 155
Reputation: 1108732
Just use a tag or component which can iterate over an array. In standard JSF, that are <c:forEach>
, <ui:repeat>
and <h:dataTable>
.
The <c:forEach>
runs during view build time and produces JSF components.
<c:forEach items="#{bean.array}" var="item">
#{item}
</c:forEach>
The <ui:repeat>
runs during view render time and produces no markup.
<ui:repeat value="#{bean.array}" var="item">
#{item}
</ui:repeat>
The <h:dataTable>
runs during view render time and produces a HTML <table>
.
<h:dataTable value="#{bean.array}" var="item">
<h:column>#{item}</h:column>
</h:dataTable>
Upvotes: 2