繁体   English   中英

如何在服务器端(bean)素数中指定id更新

[英]how to specified id update in server side (bean) primefaces

我的例子:

<p:growl id="growlId"/>
<h:form id="form">
    <h:inputText id="input" value="#{messageManagedBean.message}" 
                 required="true"
                 requiredMessage="input is not null!"/>
    <p:message for="input"/>
    <p:commandButton value="Execute JSF Lifecycle - Invoke Action One" 
                     validateClient="true" 
                     action="#{messageManagedBean.doSomeAction}" 
                     update="form growlId"></p:commandButton>   
</h:form>

public String doSomeAction() {
    if (!this.message.equals("")) {
        FacesContext.getCurrentInstance().addMessage("growlId", new FacesMessage("Header", "Success!"));
    }
    return "";
}

在这种情况下,我检查输入是否为空,将显示requiredMessage="input is not null!" 单击commandbutton ,但咆哮也显示此消息。 我想在服务器端(bean)中指定咆哮的ID,我尝试仅指定update="form"

<p:commandButton ...
                 action="#{messageManagedBean.doSomeAction}" 
                 update="form"></p:commandButton> 

但是,如果输入不为null,则在提交时,我不会收到咆哮的消息,谢谢大家!

我找到了一个解决方案,我正在使用RequestContext.getCurrentInstance().update("growlId");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM