質問

I have a composite component that is a specialization of PrimeFaces autoComplete.

In some pages I need to use the itemSelect event, so I added

<cc:clientBehavior name="itemSelect" event="itemSelect"
                   targets="#{cc.attrs.id}" />

in the component interface, but the action is not fired.

What am I missing?

Component code:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:p="http://primefaces.org/ui" >    

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="value" required="true" />
        <cc:attribute name="disabled" default="false" />
        <cc:attribute name="required" default="false" />
        <cc:attribute name="size" default="25" />
        <cc:clientBehavior name="itemSelect" event="itemSelect"
            targets="#{cc.attrs.id}" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:autoComplete disabled="#{cc.attrs.disabled}"
            value="#{cc.attrs.value}"
            completeMethod="#{tecnicoBean.completarViajante}" var="t"
            itemLabel="#{t.nome}" itemValue="#{t}" minQueryLength="2"
            forceSelection="true" converter="entityConverter"
            size="#{cc.attrs.size}" queryDelay="700" label="Técnico:"
            onclick="this.select()" cache="true">
        </p:autoComplete>
    </cc:implementation>
</html>

Component usage:

<ezcomp:tecnicos value="#{sessionScope.tecnicoRdv}">
    <p:ajax event="itemSelect" process="@this" update=":mainPanel"
            listener="#{rdvBean.changeTecnico}" />
</ezcomp:tecnicos>
役に立ちましたか?

解決

Finally got it working.

I had to add id="#{cc.attrs.id}" to the p:autoComplete component.

他のヒント

cc:clientBehavior targets - list of local id's. Correct way to use unique id for p:autoComplete

<p:autoComplete id="someUniqueId" ... />

and link it to cc:clientBehavior

<cc:clientBehavior name="itemSelect" event="itemSelect"
            targets="someUniqueId" />
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top