繁体   English   中英

Primefaces Ajax无法在字段数据表上更新

[英]Primefaces ajax not working update on field datatable

我的应用程序中的“”组件有问题。 我有一个数据表,其中2个字段可编辑,第一个是inputtext,第二个字段是dateInput。

在字段内部,我将更新列表中的值,但是将其提交给bean时不会更新值。

下面是我的page.xhtml和bean。

<p:dialog id="modalNovosParametrosRecesso" header="Salvar Novos Parâmetros de Estagiário"
                  widgetVar="widgetvarNovoParametro" 
                  draggable="true" resizable="false" 
                  closable="false" modal="true" width="630">

               <h:outputText styleClass="modalRecessoAuto" value="#{msg.MN064}" escape="false" />

              <br />   
             <h:panelGroup>
                <br />
                <p:dataTable id="tableRegRecessoAuto" var="recessoAuto"
                    value="#{parametroEstagiarioMB.visao.listaOcorrenciaRegistroRecesso}"
                    styleClass="hide-column-names" rowIndexVar="rowIndex" >

                    <p:column style="width:98px;">
                        <h:outputLabel value="#{rowIndex+1}º Recesso de " style="color: #0039BA" />
                        <p:inputText value="#{recessoAuto.diasRecesso}" size="2">
                            <p:ajax event="blur" update=":frmFiltro:tableRegRecessoAuto" ignoreAutoUpdate="true"    global="false" />
                        </p:inputText>

                        <h:outputLabel value="dia(s) começando em " style="color: #0039BA" />
                        <p:inputMask value="#{recessoAuto.dtInicioOcorrencia}"  mask="99/99/9999" size="10">
                            <f:convertDateTime pattern="dd/MM/yyyy" locale="pt_BR" />
                            <p:ajax event="blur" update=":frmFiltro:tableRegRecessoAuto" ignoreAutoUpdate="true"    global="false"/>                                
                        </p:inputMask>

                        <h:outputLabel value=" e finalizando em " style="color: #0039BA; margin-left: 5px;"/>
                        <h:outputLabel id="dtLbl1" value="#{recessoAuto.dtFimOcorrencia}"   style="color: #0039BA; margin-left: 5px;" >
                           <f:convertDateTime for="dtLbl1" pattern="dd/MM/yyyy" locale="pt_BR"/>
                        </h:outputLabel>
                    </p:column>

->

            <div style="padding-left: 170px;">



                <p:commandLink styleClass="btnLaranja marginTop"
                               ignoreAutoUpdate="true" global="false" ajax="false" action="#{parametroEstagiarioMB.salvarRecessoPrimeiraParametrizacao()}"
                               update=":frmFiltro:tableRegRecessoAuto">
                    <span>Confirmar</span>
                </p:commandLink>                    

                <p:commandLink styleClass="btnLaranja marginTop"
                                id="btnCancelarRecessoAuto"
                                oncomplete="PF('widgetvarNovoParametro').hide();"
                                ignoreAutoUpdate="true" global="false" actionListener="#{parametroEstagiarioMB.cancelar}">
                                <f:setPropertyActionListener
                                    target="#{parametroEstagiarioMB.visao.exibirModal}"
                                    value="#{false}" />                                 
                                <span>Cancelar</span>
                </p:commandLink>

                <p:commandLink styleClass="btnLaranja marginTop"
                               id="btnVerRegrasAuto"
                               oncomplete="PF('widgetvarModalRegras').show();"
                               ignoreAutoUpdate="true" global="false">
                               <span>Regras</span>
                </p:commandLink>
            </div>  

        </p:dialog>

我的豆子:

public void salvarRecessoPrimeiraParametrizacao(){

    int count = 0;      

    final DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
            .findComponent(":frmFiltro:tableRegRecessoAuto");

    List<OcorrenciaPonto> teste = new ArrayList<OcorrenciaPonto>();

    for(OcorrenciaPonto c : (List<OcorrenciaPonto>) dataTable.getValue()){
        teste.add(c);
        count+=1;
    }}

datatable.getValues()不获取新值,而是获取屏幕上显示的旧值。

您是否正确使用了getter和setter?

您是否尝试过在输入字段上使用immediate="true"

我看到您正在使用<p:ajax>
我对此有些麻烦。
也许,如果您更改为**<f:ajax>**它必须运行良好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM