0

I wanted to ask if it's possible to use a var attribute inside an a4j:repeat tag, as a binding of an inner componente. For example

<a4j:repeat value="#{myController.bindingComponents}" var="component">
  <h:panelGroup binding="#{component}"/>
</a4j:repeat>

I tried this already, however component is null when the binding expression is evaluated.

Pablo
  • 3,433
  • 7
  • 44
  • 62

1 Answers1

1

No, that's not possible. The binding attribute is evaluated during view build time (like the id attribute and all tag handlers), while the value of <a4j:repeat> as being an UI component is evaluated during view render time. So at the moment the binding attribute evaluates, the #{component} is null, because the <a4j:repeat> hasn't run at that point.

If you think once more about it, it should make completely sense: there's only one <h:panelGroup> in the JSF component tree which renders its output multiple times. It's not true that multiple <h:panelGroup> components will be generated this way, as you seemed to expect.

To achieve the particular functional requirement you've had in mind, you probably want to use a view build time iterating tag instead, like JSTL <c:forEach>.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Ok, I understand... however using c:forEach isn't giving me the desired approach. What could be an alternative?,I need to achieve dynamically generated forms inside each panel that's looped inside the a4j:repeat tag... The form is obviously created in code, Could I achieve this behaviour bindng to a single panelGroup in a managedBean?. – Pablo Jul 10 '12 at 19:58