Ajax Jsf primefaces下拉列表更新仅在验证失败期间失败

Ajax Jsf primefaces下拉列表更新仅在验证失败期间失败,ajax,jsf,primefaces,dropdown,Ajax,Jsf,Primefaces,Dropdown,我有一个下拉列表(id=“localOffInputId”),其值需要根据文本框输入(id=“rZip”)进行修改。当表单中没有验证错误时,它可以正常工作。当发生验证错误时,表单会按预期重新显示错误消息。现在,当我更改文本框中的值时,将调用侦听器方法(updateLocalOffice()),并将localOfficeCode设置为新值,但浏览器中的下拉选择不会更改。我注意到,虽然调用了localOfficeMap的getter,但在ajax调用之后没有调用localOfficeCode属性的g

我有一个下拉列表(id=“localOffInputId”),其值需要根据文本框输入(id=“rZip”)进行修改。当表单中没有验证错误时,它可以正常工作。当发生验证错误时,表单会按预期重新显示错误消息。现在,当我更改文本框中的值时,将调用侦听器方法(updateLocalOffice()),并将localOfficeCode设置为新值,但浏览器中的下拉选择不会更改。我注意到,虽然调用了localOfficeMap的getter,但在ajax调用之后没有调用localOfficeCode属性的getter。知道为什么只有在验证失败时才会发生这种情况吗

<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);
        }
    }
}

public void updateLocalOffice(){
最后一个字符串resZip=this.rZip;
if(StringUtils.isNotBlank(resZip)){
最后一个字符串localOfficeCodeForZip=this.service
.getLocalOfficeCodeForZip(this.rZip);
if(StringUtils.isNotBlank(localOfficeCodeForZip)){
setLocalOfficeCode(localOfficeCodeForZip);
}否则{
这个.setLocalOfficeCode(Constants.OOS_代码);
}
}
}

找到了问题的答案。在ajax调用中添加“resetValues=“true”修复了该问题

链接-