如何在ajax事件后清除ace:对话框中的h:消息?

时间:2015-02-25 17:54:37

标签: ajax forms validation jsf icefaces

我有一个按钮(Make Popup Visible),可以看到弹出窗口。提交表单(提交表单)时,有时会在h:messages字段中显示错误消息,这是预期的。

我的问题是,当我关闭弹出窗口(Make Popup Invisible)然后重新打开它(Make Popup Visible)时,h:messages字段仍然填充了旧的错误消息。

有什么方法可以在按下(Make Popup Visible)时清除消息?我不想做整页提交来执行此操作。

按钮可见性:

<h:form id="mainForm">
    <h:commandButton value="Make Popup Visible"> 
        <f:ajax listener="#{controller.prepareDelete(item)}" render=":deleteItemPopup"/>
    </h:commandButton>
</h:form>

弹出:

<ace:dialog id="deleteItemPopup" visible="#{controller.deleting}">
    <h:panelGroup rendered="#{controller.deleting}" layout="block">
        <h:messages for="deleteItemPopupForm"/>
        <h:form id="deleteItemPopupForm">                                

            <ui:insert name="content">
                This contains a form which, when submitted, can cause
                an error message to be created and populate the h:messages
                field
            </ui:insert>

            <h:commandButton value="Submit The Form" action="#{controller.delete}"/>
            <h:commandButton value="Make Popup Invisible">
                <f:ajax listener="#{controller.cancel}" render=":deleteItemPopup"/>
            </h:commandButton>

        </h:form>
    </h:panelGroup>
</ace:dialog>

命令:

public void prepareDelete(Item item) {
    deleting = true;
}

public void cancel() {
    deleting = false;
}

public void delete() {
    .
    .
    .
    } catch (MyException ex) {
        FacesUtils.sendMessage("deleteItemPopupForm", ex);
    }

}

1 个答案:

答案 0 :(得分:0)

看起来ICEfaces对消息做了一些特殊的事情:

http://www.icesoft.org/JForum/posts/list/19753.page#71521

我将此添加到我的web.xml文件中,消息现在消失了:

<context-param>
    <param-name>org.icefaces.messagePersistence</param-name>
    <param-value>false</param-value>
</context-param>