Java examples for JSF:Message
JSF info message
/**//from w ww . jav a 2 s .co m * License: src/main/resources/license/escidoc.license */ import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage.Severity; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import org.apache.log4j.Logger; public class Main{ public static void main(String[] argv) throws Exception{ String summary = "java2s.com"; info(summary); } /** * @param summary summary text */ public static void info(String summary) { info(summary, null, null); } /** * @param summary summary text */ public static void info(String summary, String detail) { info(summary, detail, null); } /** * @param component associated <code>UIComponent</code> * @param summary summary text */ public static void info(UIComponent component, String summary) { info(summary, null, component); } /** * @param summary summary text */ public static void info(String summary, String detail, UIComponent component) { message(summary, detail, component, FacesMessage.SEVERITY_INFO); } /** * @param summary summary text */ public static void message(String summary, String detail, UIComponent component, Severity severity) { FacesMessage fm = new FacesMessage(severity, summary, detail); if (component == null) { FacesContext.getCurrentInstance().addMessage(null, fm); } else { FacesContext.getCurrentInstance().addMessage(component.getId(), fm); } } }