【问题标题】:primefaces growl redisplays previous messageprimefaces 咆哮重新显示以前的消息
【发布时间】:2011-06-09 14:17:31
【问题描述】:

我有一个包含数据表中的列表的表单。要将新记录添加到列表中,请单击“添加”并出现对话框<p:dialog>,其中任何具有 2 列的空数据表都有两个输入文本框要填充。在对话框中,我有保存和取消按钮。一旦我们点击保存按钮,一条新记录应该保存到数据库中,并且表单中的列表应该显示新记录。数据表具有 primefaces 内联行编辑功能。我正在使用咆哮来显示错误消息。一旦我用空数据更新我的记录,它就会显示所需的消息。但是当我单击“添加”按钮时,它再次显示相同的必需消息。它显示上一个错误。我不想拥有那个。任何人都可以在这种情况下帮助我。 “添加”是一个 ajax 请求。

<h:body>
<ui:composition template="/WEB-INF/facelets/template/adminLayout.xhtml">
    <ui:define name="view"> 
<h:form id="myForm" prependId="false">


<div class="header" >
    <div class="titleColor">
        T_COD_Prefil
    </div>
</div>

<div class="divPosition">
<p:dataTable var="profile" id="profileTable" value="#{profileView.profileModelList}" rowEditListener="#{profileView.rowEditListener}" onRowEditUpdate="buttonPanel" >
                    <p:column style="width:60px;">                  
                        <p:rowEditor/> 
                        <h:commandButton  style="padding-left:5px;" image="/resources/images/delete.jpeg" styleClass="spa"  value="delete" immediate="true" actionListener="#{profileView.delete}" >
                            <f:attribute name="delteProfile" value="#{profile}" />
                        </h:commandButton>                          
                    </p:column>

                    <p:column>                                  
                        <f:facet name="header">
                            <h:outputText value="IDprefil" />
                        </f:facet>                          
                        <h:outputText value="#{profile.profileId}" />

                    </p:column>

                    <p:column>                  
                        <f:facet name="header">
                            <h:outputText value="description" />
                        </f:facet>                      
                        <p:cellEditor>                      
                            <f:facet name="output">
                                <h:outputText value="#{profile.profileDescription}" />
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText required="true" requiredMessage="#{msg.desProfileEmpty}" maxlength="255"  value="#{profile.profileDescription}" />
                            </f:facet>                          
                        </p:cellEditor>
                    </p:column>                 
                </p:dataTable>

        </div>
        <div class="divButPosition">

        <h:panelGroup id="buttonPanel">

            <p:commandButton id="buttons" value="Add" actionListener="#{profileView.addEmptyProfile}"
            async="true" update="myForm" rendered="#{!profileView.addNewRow}" oncomplete="profileDialog.show();" />

        </h:panelGroup>

    </div>

    <p:growl id="growl" showDetail="false" />  
<p:dialog id="profileDialog" header="Profile Detail" prependId="false" widgetVar="profileDialog" resizable="false" width="500" showEffect="explode" hideEffect="explode" modal="false" closable="false">

<h:dataTable var="newProfile" value="#{profileView.newProfile}">
    <h:column>
        <f:facet name="header">
            <h:outputText value="IDprefil" />
        </f:facet>
        <h:inputText value="#{newProfile.profileId}" required="true" requiredMessage="not empty" />
    </h:column>
    <h:column>
        <f:facet name="header">
            <h:outputText value="description" />
        </f:facet>
        <h:inputText value="#{newProfile.profileDescription}" required="true" requiredMessage="Desctiption should not be empty" />
    </h:column>
</h:dataTable> 
<p:commandButton value="Save"  actionListener="#{profileView.saveProfile}" async="true" update="growl,buttonPanel,profileTable" oncomplete="handleRequest(args ,document.getElementById('profileDialog'))" />
<p:commandButton value="Cancel" immediate="true" update="buttonPanel" async="true"  actionListener="#{profileView.cancelProfile}" oncomplete="profileDialog.hide();" />

</p:dialog> 
</h:form>  

【问题讨论】:

  • 请添加您的页面代码。
  • 嗨,Matt Handy,我放置了我的 xhtml 页面

标签: jsf primefaces


【解决方案1】:

尝试在代码顶部写下你的咆哮,并在点击按钮时更新它。 好吧,在 IE8 上不起作用。

【讨论】:

    【解决方案2】:

    点击提交按钮后,所有字段都将首先被验证,如果其中一些为空,则会弹出所需的消息。所以保持提交相关数据在不同的标签下。不同提交按钮的表单基本不同

    【讨论】:

    • 你能详细说明你的答案吗?
    猜你喜欢
    • 1970-01-01
    • 2017-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多