无法将<p:ajax>附加到非ClientBehaviorHolder父级</p:ajax>

时间:2015-01-19 06:32:06

标签: java html ajax primefaces drop-down-menu

我试图通过下拉列表选择一个值来调用函数。继承我的代码:

<h:form id="frmUpload" enctype="multipart/form-data">  

       <p:column><h:outputText value="Select Team: " /></p:column>
        <p:column>
                #{' '}
                <h:selectOneMenu required="true" id="ddlTeam" value="#{telesalesUpload.selectTeam}">
                <f:selectItem itemValue="0" itemLabel="Dunning Team" />
                <f:selectItem itemValue="1" itemLabel="SAVD Team"  />
                </h:selectOneMenu>
                #{' '}
         <p:ajax process="@this" event="change" listener="#{telesalesUpload.UpdateTeam}" /> 

        </p:column>

<h:outputText value="Note: first row will be skipped as header row!" />  
<p:fileUpload  fileUploadListener="#{telesalesUpload.handleFileUpload}"  
        process = "ddlTeam" 
        auto="true"
        mode="advanced"
        update="messages,:frmData"  
        allowTypes="/(\.|\/)(csv|jpe?g|png)$/"/>  
<p:growl id="messages" showDetail="true"/> 

但我收到此错误:无法附加到非ClientBehaviorHolder父级

1 个答案:

答案 0 :(得分:4)

您必须将<p:ajax>放在<p:selectOneMenu>内。

<p:column>
     #{' '}
     <p:selectOneMenu required="true" id="ddlTeam" value="#{telesalesUpload.selectTeam}">
         <f:selectItem itemValue="0" itemLabel="Dunning Team" />
         <f:selectItem itemValue="1" itemLabel="SAVD Team"  />
         <p:ajax process="@this" event="change" listener="#{telesalesUpload.UpdateTeam}" /> 
     </p:selectOneMenu>
     #{' '}
</p:column>