0

我想开发一个带有 ajax 处理程序的小型 JSC 复合组件,但它不起作用。需要提示这里出了什么问题:

代码:

 <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>

错误:

Allgemeier Anwendungsfehler!:javax.faces.FacesException:无法使用EL表达式'#{cc.attrs.ajaxListener}'使用页面解析复合组件

问候 LStrike

4

1 回答 1

0

解决了。

ajax 监听器的属性必须声明如下:

<cc:attribute name="ajaxListener" method-signature="java.lang.String action()" /> 

感谢来自 java-forum.org 的“sence”: Thread @ java-forum.org

于 2013-10-29T12:07:59.033 回答