Is there any way to trigger an event in my composite component with clientBehavior and jQuery?
If not possible, what is the proper way to create custom events in composites?
Example:
ajaxTest.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:p="http://primefaces.org/ui">
<cc:interface>
<cc:clientBehavior name="myEvent" targets="myLabel" event="myEvent"/>
</cc:interface>
<cc:implementation>
<div id="#{cc.clientId}">
<p:outputLabel id="myLabel" value="Test label" />
<p:commandLink value="trigger event"
onstart="$(PrimeFaces.escapeClientId('#{cc.clientId}:myLabel')).trigger('myEvent');"/>
</div>
</cc:implementation>
</html>
testPage.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:demo="http://xmlns.jcp.org/jsf/composite/component">
<h:body>
<h:form id="form-1">
<demo:ajaxTest>
<p:ajax event="myEvent" oncomplete="alert('Ajax called');" />
</demo:ajaxTest>
</h:form>
</h:body>
</html>