create JSF Faces Error - Java JSF

Java examples for JSF:JSF Error

Description

create JSF Faces Error

Demo Code


import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

public class Main{
    public static void main(String[] argv) throws Exception{
        String formId = "java2s.com";
        String summary = "java2s.com";
        String detail = "java2s.com";
        createFacesError(formId,summary,detail);
    }/*  w ww .  j a va2  s  .  c o m*/
    public static void createFacesError(String formId, String summary,
            String detail) {
        getFacesContext().addMessage(formId,
                createFacesMessageError(summary, detail));
    }
    private static FacesContext getFacesContext() {
        return FacesContext.getCurrentInstance();
    }
    private static FacesMessage createFacesMessageError(String summary,
            String detail) {
        FacesMessage message = new FacesMessage();
        message.setDetail(detail);
        message.setSummary(summary);
        message.setSeverity(FacesMessage.SEVERITY_ERROR);
        return message;
    }
}

Related Tutorials