1

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

2

Just use a tag or component which can iterate over an array. In standard JSF, that are <c:forEach>, <ui:repeat> and <h:dataTable>.

  1. The <c:forEach> runs during view build time and produces JSF components.

    <c:forEach items="#{bean.array}" var="item">
        #{item}
    </c:forEach>
    
  2. The <ui:repeat> runs during view render time and produces no markup.

    <ui:repeat value="#{bean.array}" var="item">
        #{item}
    </ui:repeat>
    
  3. 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>
    
Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • and I read on " the link you provided" , I assume that what you mean by `produces JSF components.` is that `` producing `` by default (even if we don't embed directly to the `#{item}`) right?? – Plain_Dude_Sleeping_Alone Jul 01 '15 at 18:06
  • You're welcome. No, it will in the given example produce an `UIInstructions` component. – BalusC Jul 01 '15 at 20:55