1

I have a problem with the JSF composite cc:clientBehavior's targets attribute.

The main question is:

What should I write to the behavior "targets" to work with all of the list elements?

My sample code:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:cc="http://xmlns.jcp.org/jsf/composite"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:p="http://primefaces.org/ui">
<cc:interface>
    <cc:attribute name="items" />
    <cc:clientBehavior name="itemClick" targets="???" event="click" />
</cc:interface>

<cc:implementation>
    <!-- or ui:repeat or c:forEach... -->
    <p:dataList id="itemList" value="#{cc.attrs.items}" var="item">
            <p:outputLabel value="#{item.id}" />
            <p:commandLink id="itemLink" value="view details" >
                <f:attribute name="clicked" value="#{item.id}" />
            </p:commandLink>
    </p:dataList>
</cc:implementation>

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Plutoz
  • 694
  • 9
  • 13

1 Answers1

1

Just use a composite-component-implementation-relative client ID pointing to the <p:commandLink>.

<cc:clientBehavior name="itemClick" targets="itemList:itemLink" event="click" />

Note that this wouldn't have worked with <c:forEach>. See also JSTL in JSF2 Facelets... makes sense?

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