[英]JSF Composite Component with ajax won't work
I want to develop a small JSC Composite Component with an ajax handler, but it won't work. 我想用ajax处理程序开发一个小的JSC Composite Component,但是它不起作用。 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! Allgemeiner Anwendungsfehler! : javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}' :javax.faces.FacesException:无法通过使用EL表达式'#{cc.attrs.ajaxListener}'使用页面来解析复合组件
Regards LStrike 关于LStrike
Solved it. 解决了。
The attribute for the ajax listener must be declared as follows: Ajax侦听器的属性必须声明如下:
<cc:attribute name="ajaxListener" method-signature="java.lang.String action()" />
Thanks to "sence" from java-forum.org: Thread @ java-forum.org 感谢java-forum.org的“ sence”: Thread @ java-forum.org
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.