p:remoteCommand和p:autoUpdate =“true”的消息清除消息

时间:2015-08-04 09:50:30

标签: jsf primefaces remotecommand

<p:messages id="lockMessage"
            for="lockMessage"
            redisplay="false"
            showDetail="true"
            autoUpdate="true"
            closable="true"/>

<h:form id="form">
    <p:remoteCommand name="updateTable" update="dataTable" process="@this"/>

    <p:commandButton oncomplete="if(args &amp;&amp;!args.validationFailed) {updateTable();}"
                     actionListener="#{bean.action}"
                     value="Save"/>

    <p:dataTable id="dataTable"/>
</h:form>

豆子:

@Named
@ViewScoped
public class Bean implements Serializable {

    private static final long serialVersionUID = 1L;

    public Bean() {}

    public void action() {
        FacesContext facesContext = FacesContext.getCurrentInstance();

        // This is needed somewhere.

        Collection<String> renderIds = facesContext.getPartialViewContext().getRenderIds();
        renderIds.clear();
        renderIds.add("lockMessage");

        // Render the message using some conditional check.

        FacesMessage message = new FacesMessage();
        message.setSeverity(FacesMessage.SEVERITY_ERROR);
        message.setSummary("Summary");
        message.setDetail("Message");
        facesContext.addMessage("lockMessage", message);
    }
}

消息显示的时间很短,很快就会消失,当点击给定的<p:commandButton>时。

如果oncomplete="if(args &amp;&amp;!args.validationFailed) {updateTable();}"已移除<p:commandButton>,则会照常显示该消息。

由于其他原因,我们无法忽略<p:remoteCommand>或将与autoUpdate相关联的<p:messages>属性设置为false

当按下给定的<p:commandButton>时,要正常显示的消息是什么?

0 个答案:

没有答案