2015-10-30 72 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); 
     } 
    } 
} 

回答