2015-10-30 71 views
0

我有一個下拉(id =「localOffInputId」),它的值需要根據文本框輸入(id =「rZip」)修改。它在表單中沒有驗證錯誤時工作正常。當發生驗證錯誤時,表單將按照預期重新顯示錯誤消息。現在,當我更改文本框中的值時,會調用偵聽器方法(updateLocalOffice()),並將localOfficeCode設置爲新值,但下拉選擇在瀏覽器中不會更改。我注意到localOfficeCode屬性的getter在ajax調用後沒有被調用,雖然localOfficeMap的getter被調用。任何想法爲什麼只有當驗證失敗發生時纔會發生?Jsf primefaces下拉更新失敗僅在驗證失敗

<p:row> 
    <p:column> 
     <h:panelGroup id="resZipInputId"> 
      <p:inputMask id="rZip" value="#{createProfile.profileForm.rZip}" mask="99999" size="5" required="true" requiredMessage="#{msg['msg.physical.zip.required']}" valueChangeListener="#{createProfile.addDirtyFields}"> 
       <f:attribute name="fieldName" value="Physical Address - ZIP" /> 
       <f:attribute name="fieldOrder" value="24"/> 
       <p:ajax event="change" listener="#{createProfile.profileForm.updateLocalOffice}" update="localOfficeTableId,localOffInputId, localOfficeDropdownId" /> 
      </p:inputMask> 
      <h:outputText value=" - "/> 
      <p:inputMask value="#{createProfile.profileForm.rZipPlus4}" mask="9999" size="4" valueChangeListener="#{createProfile.addDirtyFields}"></p:inputMask> 
     </h:panelGroup> 
    </p:column> 
</p:row> 

<p:row> 
    <p:column colspan="2"> 
     <h:panelGroup id="localOfficeTableId"> 
      <p:panelGrid styleClass="noBorderPanelGrid"> 
       <p:row> 
        <p:column> 
         <h:panelGroup id="localOffInputId"> 
          <h:selectOneMenu value="#{createProfile.profileForm.localOfficeCode}" id="localOfficeDropdownId" valueChangeListener="#{createProfile.addDirtyFields}" required="true" requiredMessage="#{msg['msg.localoffice.required']}"> 
           <f:selectItems value="#{createProfile.profileForm.localOfficeMap}" /> 
          </h:selectOneMenu> 
         </h:panelGroup> 
        </p:column> 
       </p:row> 
      </p:panelGrid> 
     </h:panelGroup> 
    </p:column> 
</p:row> 

public void updateLocalOffice(){ 
    final String resZip = this.rZip; 
    if (StringUtils.isNotBlank(resZip)) { 
     final String localOfficeCodeForZip = this.service 
       .getLocalOfficeCodeForZip(this.rZip); 

     if (StringUtils.isNotBlank(localOfficeCodeForZip)) { 
      this.setLocalOfficeCode(localOfficeCodeForZip); 
     } else { 
      this.setLocalOfficeCode(Constants.OOS_CODE); 
     } 
    } 
} 

回答