Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax 通过对话框组件更新SelectOneMenu primefaces组件_Ajax_Jsf_Primefaces_Jsf 2 - Fatal编程技术网

Ajax 通过对话框组件更新SelectOneMenu primefaces组件

Ajax 通过对话框组件更新SelectOneMenu primefaces组件,ajax,jsf,primefaces,jsf-2,Ajax,Jsf,Primefaces,Jsf 2,我正在一个对话框组件中运行一个地址查找,用地址数据刷新表单。address对象的所有信息都是正确的,但城市和社区组件没有使用适当的信息进行处理。仅加载状态组件 选择组件是相关的、州、城市和社区 页面地址 <h:form id="formEnd"> <p:panelGrid id="pnlEnderecoID" columns="2" layout="grid" columnClasses="ui-grid-col-2, ui-grid-col-5" styleClass

我正在一个对话框组件中运行一个地址查找,用地址数据刷新表单。address对象的所有信息都是正确的,但城市和社区组件没有使用适当的信息进行处理。仅加载状态组件

选择组件是相关的、州、城市和社区

页面地址

<h:form id="formEnd">
    <p:panelGrid id="pnlEnderecoID" columns="2" layout="grid" columnClasses="ui-grid-col-2, ui-grid-col-5" styleClass="ui-panelgrid-blank">

        <p:outputLabel value="Cep:"/>
        <p:outputPanel>
            <p:inputText id="iptCepID" value="#{funcionarioBean.endereco.cep}" style="width: 180px;">
                <sgr:onlyNumber/>
            </p:inputText>
            <p:commandLink onclick="PF('cepDLG').show();" process="@this">
                <span class="label label-primary"><i class="fa fa-search"></i></span>
            </p:commandLink>
        </p:outputPanel>

        <p:outputLabel value="Estado:"/>
        <p:selectOneMenu id="selectEstadoID" value="#{funcionarioBean.endereco.bairro.cidade.estado}" converter="omnifaces.SelectItemsConverter">
            <f:selectItem itemLabel="Selecione" itemValue="" noSelectionOption="true"/>
            <f:selectItems value="#{funcionarioBean.listaEstados}" var="obj" itemLabel="#{obj.descricao}" itemValue="#{obj}"/>
            <p:ajax listener="#{funcionarioBean.buscarCidadesPorEstadoSelecionado}" update="selectCidadeID"/>
        </p:selectOneMenu>

        <p:outputLabel value="Cidade:"/>
        <p:selectOneMenu id="selectCidadeID" value="#{funcionarioBean.endereco.bairro.cidade}" converter="omnifaces.SelectItemsConverter">
            <f:selectItem itemLabel="Selecione" itemValue="" noSelectionOption="true"/>
            <f:selectItems value="#{funcionarioBean.listaCidades}" var="obj" itemLabel="#{obj.descricao}" itemValue="#{obj}"/>
            <p:ajax listener="#{funcionarioBean.buscarBairrosPorCidadeSelecionada}" update="selectBairroID"/>
        </p:selectOneMenu>

        <p:outputLabel value="Bairro:"/>
        <p:selectOneMenu id="selectBairroID" value="#{funcionarioBean.endereco.bairro}" converter="omnifaces.SelectItemsConverter">
            <f:selectItem itemLabel="Selecione" itemValue="" noSelectionOption="true"/>
            <f:selectItems value="#{funcionarioBean.listaBairros}" var="obj" itemLabel="#{obj.descricao}" itemValue="#{obj}"/>
        </p:selectOneMenu>

    </p:panelGrid>
</h:form>

<p:dialog header="Pesquisar CEP" widgetVar="cepDLG" modal="true" height="100">
    <h:form id="formDLG">
        <p:inputText id="iptCepWS" placeholder="Digite o CEP" value="#{funcionarioBean.endereco.cep}"/>
        <p:commandButton
                    action="#{funcionarioBean.pesquisaCepComplementaEndereco}"
                    process="@this, iptCepWS"
                    update=":pnlEnderecoID"
                    style="width: 50px;"
                    icon="fa fa-search" oncomplete="PF('cepDLG').hide()"/>
    </h:form>
</p:dialog>

通过对话框渲染formEnd后的图像


在加载表单后,我可以通过加载城市和社区列表来解决这个问题。感谢您的帮助@Jaqen H'ghar

您能否尝试使用update=“:formEnd:pnlEnderecoID”(或just“:formEnd”)查看“重复”感谢Jaqen H'ghar的回复。但我的问题的图像也出现了同样的结果。我不理解这些依赖组件中的这种行为自从使用Omnifaces转换器以来,您已经检查了toString()?谢谢您的回答。贾庆赫尔。我在这个屏幕上使用的所有实体都有ToString()实现,它只返回一个实体字段。我甚至用我实现的另一个转换器对它进行了测试。结果是一样的。