<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 &&!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 &&!args.validationFailed) {updateTable();}"
从<p:commandButton>
.
由于其他某些原因,无法省略<p:remoteCommand>
或设置与toautoUpdate
关联的属性。<p:messages>
false
当<p:commandButton>
按下给定时,要如何正常显示消息?