FkJ FkJ - 1 year ago 294
Ajax Question

JSF 2 composite component + clientBehavior

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="#{}" />

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" "">
<html xmlns=""
xmlns:p="" >

<!-- 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="#{}" />

<p:autoComplete disabled="#{cc.attrs.disabled}"
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="" cache="true">

Component usage:

<ezcomp:tecnicos value="#{sessionScope.tecnicoRdv}">
<p:ajax event="itemSelect" process="@this" update=":mainPanel"
listener="#{rdvBean.changeTecnico}" />

Answer Source

Finally got it working.

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download