Java 怎么创建JSF faces错误

2019年8月13日22:13:07 评论 30

1.简介

Java 怎么创建JSF faces错误?——请看下文。

2.代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */

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 = "tah1986.com";
        String summary = "tah1986.com";
        String detail = "tah1986.com";
        createFacesError(formId,summary,detail);
    }
    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;
    }
}

 

3.总结

示例代码演示了 Java 如何创建JSF faces错误,具体步骤参见示例代码。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: