📜  Primefaces低吼

📅  最后修改于: 2021-01-08 04:43:47             🧑  作者: Mango

PrimeFaces低吼

这是一个通知小部件,用于显示FacesMessages。它类似于JSF的标准h:messages组件。我们可以将咆哮声放置在应用程序网页中的任何位置。在JSF应用程序中咆哮的位置无关紧要。

默认情况下,它会在隐藏后显示6000毫秒。我们可以通过设置true坚持下去。它具有下面列出的各种其他属性。

怒吼属性

Attribute Default value Type Description
sticky false Boolean It is used to specify that the message should stay instead of hidden
automatically.
showSummary true Boolean It is used to show summery of the message.
showDetail false Boolean It is used to show detail of message.
globalOnly false Boolean It is used to set globally.
life 6000 Integer It is used to set display time of the message.
autoUpdate false Boolean It is used to set auto update mode.
redisplay true Boolean It is used to redisplay message.
for null String It is used to set name of associated key.
escape true Boolean It defines whether html would be escaped or not.
severity null String It is a comma separated list of severities to display only.

在下面的示例中,我们正在实现组件。本示例包含以下文件。

JSF文件

// growl.xhtml





Growl Messages


















ManagedBean

// Growl.java

package com.javatpoint;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
@ManagedBean
public class Growl {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void displayMessage() {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Login Successfuly", "Welcome: " + username));
}
}

输出: