I want to develop a small JSC Composite Component with an ajax handler, but it won't work. Need a hint what's wrong here:
Code:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:m="http://java.sun.com/jsf/composite/components/mmnet">
<cc:interface>
<cc:attribute name="value" required="true" />
<cc:attribute name="id" type="String"/>
<cc:attribute name="required" type="boolean"/>
<cc:attribute name="multiple" type="boolean"/>
<cc:attribute name="size" type="int" />
<cc:attribute name="scrollHeight" type="int" default="500"/>
<cc:attribute name="style" type="String"/>
<cc:attribute name="styleClass" type="String"/>
<cc:attribute name="label" type="String"/>
<cc:attribute name="minQueryLength" type="String" default="3"/>
<cc:attribute name="queryDelay" type="String" default="400"/>
<cc:attribute name="disabled" type="boolean" default="false"/>
<cc:attribute name="fullNameFormat" type="int" default="4"/>
<cc:attribute name="ajaxEvent" type="String" />
<cc:attribute name="ajaxUpdate" type="String"/>
<cc:attribute name="ajaxListener" />
</cc:interface>
<cc:implementation>
<p:autoComplete id="#{cc.attrs.id}"
value="#{cc.attrs.value}"
size="#{cc.attrs.size}"
scrollHeight="#{cc.attrs.scrollHeight}"
completeMethod="#{personListHandler.autocomplete}"
converter="#{entityConverter}"
forceSelection="true"
minQueryLength="#{cc.attrs.minQueryLength}"
var="_person"
queryDelay="#{cc.attrs.queryDelay}"
panelStyle="width:300px"
styleClass="#{cc.attrs.styleClass}"
style="#{cc.attrs.style}"
label="#{cc.attrs.label}"
disabled="#{cc.attrs.disabled}"
required="#{cc.attrs.required}"
itemLabel="#{_person.getFullName(cc.attrs.fullNameFormat)}"
itemValue="#{_person}"
multiple="#{cc.attrs.multiple}">
<p:ajax event="itemSelect" listener="#{cc.attrs.ajaxListener}" update="#{cc.attrs.ajaxUpdate}" />
</p:autoComplete>
</cc:implementation>
</ui:composition>
Error:
Allgemeiner Anwendungsfehler! : javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}'
Regards LStrike
Solved it.
The attribute for the ajax listener must be declared as follows:
<cc:attribute name="ajaxListener" method-signature="java.lang.String action()" />
Thanks to "sence" from java-forum.org: Thread @ java-forum.org