【问题标题】:Primefaces update strange behaviourPrimefaces 更新奇怪的行为
【发布时间】:2014-12-02 22:39:01
【问题描述】:

我在 Primefaces 更新上有一个奇怪的行为: 我有一个带有多个输出文本的面板网格和一个带有多行的 dataTable 的页面。如果我修改一行,数据表会正确更新,但如果我插入新行或删除一行,它不会更新。页面代码如下:

<ui:composition>
    <p:dialog id="composizioneDlg" widgetVar="ComposizioneDialog" modal="true" resizable="false" appendTo="@(body)" header="#{bundle.ListDescImmTitle}">
        <h:form id="composizioneListForm">  
            <p:panelGrid  columns="10" rendered="#{immobiliController.selected != null}">                       
                <h:outputText value="#{bundle.ViewImmobiliLabel_categoria}"/>
                <h:outputText value="#{immobiliController.selected.categoria.descrizione}" 
-------SEVERAL OUTPUTS---------------------------------
            </p:panelGrid>

            <p:panel  header="#{bundle.ListDescImmTitle}">
                <p:dataTable id="datalistComp" value="#{descImmController.composizione}" var="item" >
-----SEVERAL OPTIONS OF DATA TABLE-------------------
                    <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                    <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListDescImmTitle_stato}"/>
                        </f:facet>
                        <h:outputText value="#{item.stato}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListDescImmTitle_categoria}"/>
                        </f:facet>
                        <h:outputText value="#{item.categoria}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListDescImmTitle_descrizione}"/>
                        </f:facet>
                        <h:outputText value="#{item.descrizione}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListDescImmTitle_mq}"/>
                        </f:facet>
                        <h:outputText value="#{item.mq}"/>
                    </p:column>                      
                    <f:facet name="footer">
                        <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{descImmController.prepareCreate}" update=":DescImmCreateForm" oncomplete="PF('DescImmCreateDialog').show()"/>
                        <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{bundle.Edit}" update=":DescImmEditForm" oncomplete="PF('DescImmEditDialog').show()" disabled="#{empty descImmController.selected}"/>
                        <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{bundle.Delete}" actionListener="#{descImmController.destroy}" update=":composizioneListForm:datalistComp, :growl" disabled="#{empty descImmController.selected}"/>
                    </f:facet>
                </p:dataTable>
            </p:panel>
        </h:form>
    </p:dialog>
</ui:composition>

editButton 代码是这样的(并且可以正常工作):

<ui:composition>

    <p:dialog id="DescImmEditDlg" widgetVar="DescImmEditDialog" modal="true" resizable="false" appendTo="@(body)" header="#{bundle.EditDescImmTitle}">
        <h:form id="DescImmEditForm">
            <h:panelGroup id="display">
                <p:panelGrid columns="2" rendered="#{descImmController.selected != null}">

                    <p:outputLabel value="#{bundle.EditDescImmLabel_stato}" for="stato" />
                    <p:inputText id="stato" value="#{descImmController.selected.stato}" title="#{bundle.EditDescImmTitle_stato}" />

                    <p:outputLabel value="#{bundle.EditDescImmLabel_descrizione}" for="descrizione" />
                    <p:inputText id="descrizione" value="#{descImmController.selected.descrizione}" title="#{bundle.EditDescImmTitle_descrizione}" />
                    <p:outputLabel value="#{bundle.EditDescImmLabel_mq}" for="mq" />
                    <p:inputText id="mq" value="#{descImmController.selected.mq}" title="#{bundle.EditDescImmTitle_mq}" />                       
                </p:panelGrid>
                <p:commandButton actionListener="#{descImmController.update}" value="#{bundle.Save}" update="display, :composizioneListForm:datalistComp, :growl" oncomplete="handleSubmit(args, 'DescImmEditDialog');"/>
                <p:commandButton value="#{bundle.Cancel}" onclick="DescImmEditDialog.hide()"/>
            </h:panelGroup>
        </h:form>
    </p:dialog>

</ui:composition>

这是 createButton 的代码(不是 update 而不是 editButton ):

<ui:composition>

    <p:dialog id="DescImmCreateDlg" widgetVar="DescImmCreateDialog" modal="true" resizable="false" appendTo="@(body)" header="#{bundle.CreateDescImmTitle}">
        <h:form id="DescImmCreateForm">
            <h:panelGroup id="display">
                <p:panelGrid columns="2" rendered="#{descImmController.selected != null}">                        

                    <p:outputLabel value="#{bundle.CreateDescImmLabel_descrizione}" for="descrizione" />
                    <p:inputText id="descrizione" value="#{descImmController.selected.descrizione}" title="#{bundle.CreateDescImmTitle_descrizione}" />
                    <p:outputLabel value="#{bundle.CreateDescImmLabel_mq}" for="mq" />
                    <p:inputText id="mq" value="#{descImmController.selected.mq}" title="#{bundle.CreateDescImmTitle_mq}" />                        
                </p:panelGrid>
                <p:commandButton actionListener="#{descImmController.create}" value="#{bundle.Save}" update="display, :composizioneListForm:datalistComp, :growl" oncomplete="handleSubmit(args,'DescImmCreateDialog');"/>
                <p:commandButton value="#{bundle.Cancel}" onclick="DescImmCreateDialog.hide()"/>
            </h:panelGroup>
        </h:form>
    </p:dialog>

</ui:composition>

在 deleteButton 和 createButton 中调用 update="" 时我的错误在哪里????

【问题讨论】:

    标签: jsf primefaces


    【解决方案1】:

    从头开始重写代码后(但使用相同的代码)一切顺利。现在可以了

    【讨论】:

      猜你喜欢
      • 2016-02-16
      • 2016-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多