0

Suppose I'd like to do something like this

<ui:repeat value="#{myMB.fields}" var="field">
<p:outputLabel for="#{field}" value="#{field}:" style="width:100px;"/>
<p:outputLabel id="#{field}" value="#{my.someobject.#{field}}"/>
</ui:repeat>

"fields" are the attributes of some bean (can be retrieved using reflection or not)

is it possible to be done using c:forEach or ui:repeat?

1 Answers1

0

You should be able to do with ui:repeat no problem:

<ui:repeat value="#{myMB.fields}" var="field">
  <p:outputLabel for="#{field.some_id}" value="#{field.some_value}:" style="width:100px;"/>
  <p:outputLabel id="#{field.some_id}" value="#{my.someobject.#{field.value}}"/>
</ui:repeat>

public class myMB {

  List<Field> fields = new ArrayList<Field>();

  // Constructor
  public MyMB() {
    // Set some values in fields 
  }

  // Getters and Setters
}

public class Field {
    int some_id = 10;
    String some_value = "Something"

    // Getters and setters
  }

Is that what you're asking?

Catfish
  • 18,876
  • 54
  • 209
  • 353
  • I confess I didn't ever tried because I did not thought it would be possible :-) thanks –  Jan 07 '14 at 20:30