【问题标题】:I have to click twice to update other table (Primefaces p:ajax)我必须单击两次才能更新其他表(Primefaces p:ajax)
【发布时间】:2016-05-10 03:30:46
【问题描述】:

当我从表中选择一行并想更新其他表时,我遇到了 primefaces 5.1 的问题,我必须单击两次才能正常工作。

当我单击 tb_hojas 表中的一行时,此方法 cargarTablas() 获取数据并从 tb_familia 表中更新 ArrayList,但我必须单击 tb_hojas 表中的行两次才能查看 tb_familia 中的新数据表。

在 bean 中,当我使用 RequestScope 时它可以工作,但我需要使用 ViewScoped。

这是我的 XHTML 代码:

    <h:form id="panel">

        <p:dataTable  id="tb_hojas" selection="#{hojaB2.filaHojas}" rowKey="#{lis.id}"
                      selectionMode="single" scrollable="true" scrollHeight="300" resizableColumns="true" 
                      liveResize="true" var="lis" value="#{hojaB2.tablaHojas}"
                      paginator="true" rows="50" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                      rowsPerPageTemplate="25,30,50" filteredValue="#{hojaB2.filtroHojas}">
            <p:ajax  listener="#{hojaB2.cargarTablas()}" update=":panel" event="rowSelect" />  
            <p:column headerText="id" sortBy="#{lis.id}" filterBy="#{lis.id}">
                <h:outputText  value="#{lis.id}"/>
            </p:column>
            <p:column headerText="nombre" sortBy="#{lis.nombre}" filterBy="#{lis.nombre}">
                <h:outputText  value="#{lis.nombre}"/>
            </p:column>
        </p:dataTable>
         <p:dataTable id="tb_familia" selection="#{hojaB2.filaFamilia}" selectionMode="single" scrollable="true" scrollHeight="300" resizableColumns="true" 
                     liveResize="true" var="lis2" value="#{hojaB2.tablaFamilia}" rowKey="#{lis2.codigo}"
                     paginator="true" rows="50" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                     rowsPerPageTemplate="25,30,50" filteredValue="#{hojaB2.filtroFamilia}">
            <p:ajax listener="#{hojaB2.cargarDialogoFamilia()}" oncomplete="PF('dlg_familia2').show();" update="@([id$=tb_familia]),@([id$=Form])" event="rowSelect" >  
            </p:ajax>
            <p:column headerText="codigo" sortBy="#{lis2.codigo}" filterBy="#{lis2.codigo}">
                <h:outputText  value="#{lis2.codigo}"/>
            </p:column>
            <p:column headerText="nombre" sortBy="#{lis2.nombre}" filterBy="#{lis2.nombre}">
                <h:outputText  value="#{lis2.nombre}"/>
            </p:column>
            <p:column headerText="cargo" sortBy="#{lis2.cargo}" filterBy="#{lis2.cargo}">
                <h:outputText  value="#{lis2.nombre}"/>
            </p:column>
        </p:dataTable>
    </h:form>

【问题讨论】:

  • 尝试在 &lt;p:ajax&gt; 中添加 process="@form @this",您正在调用方法 `cargarTablas'
  • 尝试设置

标签: ajax jsf primefaces


【解决方案1】:

为什么要更新 p:tables 所在的自己的表单?
我相信只更新另一个表可以解决您的问题并且足以满足您的要求。

例子:

 <p:ajax  listener="#{hojaB2.cargarTablas()}" update="tb_familia" event="rowSelect" />

【讨论】:

    猜你喜欢
    • 2015-07-02
    • 1970-01-01
    • 1970-01-01
    • 2020-06-29
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-31
    相关资源
    最近更新 更多