Pablo
Pablo

Reputation: 3467

using a4j:repeat var in binding

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.

Upvotes: 0

Views: 1140

Answers (1)

BalusC
BalusC

Reputation: 1108632

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:

Upvotes: 1

Related Questions