add Message to JSF FacesContext - Java JSF

Java examples for JSF:FacesContext

Description

add Message to JSF FacesContext

Demo Code


import java.util.Map;
import java.util.Map.Entry;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

public class Main{
    public static void main(String[] argv) throws Exception{
        String message = "java2s.com";
        addMessage(message);/* w  w  w.  ja v  a  2 s  .  c om*/
    }
    public static void addMessage(String message) {
        FacesMessage fMessage = new FacesMessage(message);
        FacesContext.getCurrentInstance().addMessage(fMessage.getSummary(),
                fMessage);
    }
}

Related Tutorials