首页 > 解决方案 > Primefaces p:ajax调用后消息消失

问题描述

我的问题是p:messages错误消息闪烁然后消失。我知道我在 h:commandButton 上的 ajax 清除了表单,但我需要将消息保留在表单中,并且我无法让我的方法以其他方式运行 IE p:commandButtononclick。

我的 card.xhtml 模板中的 xhtml 代码片段:

        <h:form id="cardForm">      
          <p:messages closable="true" id="msg">
            <p:autoUpdate disabled="true"/>
          </p:messages>
    
          <h:commandButton
            value="Add card to profile"
            actionListener="#{cust.addCardToProfile('cards.xhtml')}"
            rendered="#{not cart}">
            <p:ajax oncomplete="addCardToProfile();" update=":cardForm:msg"/>
           </h:commandButton>
        <h:form>

如何正确运行我的“addCardToProfile();” -方法和更新消息,使其停留在屏幕上。

原始xhtml:

    ...
  <p:remoteCommand name="addCard2OptionList"
   actionListener="#{saml2IdPLoginController.addCard2OptionList}"/>
    ...
      <p:outputPanel id="userCard">
          <ui:define name="content">
            <ui:include src="/WEB-INF/templates/card.xhtml"/>
          </ui:define>
      </p:outputPanel>

正如@Melloware 所建议的,它可能与RemoteCommand组件有关。

标签: jsfprimefaces

解决方案


推荐阅读