FacesMessage (Java EE 5)

Java EE API


javax.faces.application Class FacesMessage

java.lang.Object
  extended by javax.faces.application.FacesMessage
All Implemented Interfaces:
Serializable

public class FacesMessage
extends Object
implements Serializable

Implements: java.io.Serializable
Inner classes: FacesMessage.Severity

FacesMessage 表示单个验证(或其他)消息,通常与视图中的特定组件关联。可以基于特定的 messageId 创建 javax.faces.application.FacesMessage 实例。该规范定义必须有 javax.faces.application.FacesMessage 实例的 messageId 的集合。

创建给定 messageIdFacesMessage 实例时,该实现必须采用下列步骤:

    调用 Application#getMessageBundle。如果为非 null,则定位到命名的 ResourceBundle 同时使用当前 javax.faces.component.UIViewRoot 中的 Locale,并查看该 ResourceBundle 是否有参数 messageId 的值。如果有,则将该值视为 FacesMessagesummary。如果没有,或者 Application#getMessageBundle 返回了 null,则查找按常量 #FACES_MESSAGES 的值命名的 ResourceBundle,并查看它是否有参数 messageId 的值。如果有,则将该值视为 FacesMessagesummary。如果没有,则该 FacesMessage 实例没有初始化信息。

    在所有情况下,如果找到了该 {messageId}ResourceBundle,则可以进一步在键 {messageId}_detail 下查找相应的 ResourceBundle。将此值(如果存在)用作返回的 FacesMessagedetail

    确保执行 FacesMessagesummarydetail 所需的任何参数替换。

英文文档:

FacesMessage represents a single validation (or other) message, which is typically associated with a particular component in the view. A FacesMessage instance may be created based on a specific messageId. The specification defines the set of messageIds for which there must be FacesMessage instances.

The implementation must take the following steps when creating FacesMessage instances given a messageId:

    Call Application.getMessageBundle(). If non-null, locate the named ResourceBundle, using the Locale from the current UIViewRoot and see if it has a value for the argument messageId. If it does, treat the value as the summary of the FacesMessage. If it does not, or if Application.getMessageBundle() returned null, look in the ResourceBundle named by the value of the constant FACES_MESSAGES and see if it has a value for the argument messageId. If it does, treat the value as the summary of the FacesMessage. If it does not, there is no initialization information for the FacesMessage instance.

    In all cases, if a ResourceBundle hit is found for the {messageId}, look for further hits under the key {messageId}_detail. Use this value, if present, as the detail for the returned FacesMessage.

    Make sure to perform any parameter substitution required for the summary and detail of the FacesMessage.

See Also:
Serialized Form

Nested Class Summary
static class
 
Field Summary
static String
static FacesMessage.Severity
static FacesMessage.Severity
static FacesMessage.Severity
static FacesMessage.Severity
static List
static Map
 
Constructor Summary
 
Method Summary
 String
 FacesMessage.Severity
 String
 void
 void
 void
 
Methods inherited from class java.lang.Object
 

Field Detail

英文文档:

FACES_MESSAGES

public static final String FACES_MESSAGES

ResourceBundle identifier for messages whose message identifiers are defined in the JavaServer Faces specification.

See Also:
Constant Field Values


英文文档:

SEVERITY_INFO

public static final FacesMessage.Severity SEVERITY_INFO

Message severity level indicating an informational message rather than an error.


英文文档:

SEVERITY_WARN

public static final FacesMessage.Severity SEVERITY_WARN

Message severity level indicating that an error might have occurred.


英文文档:

SEVERITY_ERROR

public static final FacesMessage.Severity SEVERITY_ERROR

Message severity level indicating that an error has occurred.


英文文档:

SEVERITY_FATAL

public static final FacesMessage.Severity SEVERITY_FATAL

Message severity level indicating that a serious error has occurred.


英文文档:

VALUES

public static final List VALUES

Immutable List of valid FacesMessage.Severity instances, in ascending order of their ordinal value.


英文文档:

VALUES_MAP

public static final Map VALUES_MAP

Immutable Map of valid FacesMessage.Severity instances, keyed by name.

Constructor Detail

public FacesMessage()

构造无初始值的新 javax.faces.application.FacesMessage。严重性设置为 Severity.INFO。

英文文档:

FacesMessage

public FacesMessage()

Construct a new FacesMessage with no initial values. The severity is set to Severity.INFO.


public FacesMessage(String summary)

构造只有一个摘要的新 javax.faces.application.FacesMessage。详细信息为 null,严重性设置为 Severity.INFO

英文文档:

FacesMessage

public FacesMessage(String summary)

Construct a new FacesMessage with just a summary. The detail is null, the severity is set to Severity.INFO.


public FacesMessage(String summary, String detail)

构造带指定初始值的新 javax.faces.application.FacesMessage。严重性设置为 Severity.INFO。

summary 已本地化的摘要消息文本
detail 已本地化的详细消息文本
ThrowsIllegalArgumentException: 如果指定的严重性级别不是支持的值之一
英文文档:

FacesMessage

public FacesMessage(String summary,
                    String detail)

Construct a new FacesMessage with the specified initial values. The severity is set to Severity.INFO.

Parameters:
summary - Localized summary message text
detail - Localized detail message text
Throws:
IllegalArgumentException - if the specified severity level is not one of the supported values


public FacesMessage(FacesMessage.Severity severity, String summary, String detail)

构造带指定初始值的新 FacesMessage

severity 严重性
summary 已本地化的摘要消息文本
detail 已本地化的详细消息文本
ThrowsIllegalArgumentException: 如果指定的严重性级别不是支持的值之一
英文文档:

FacesMessage

public FacesMessage(FacesMessage.Severity severity,
                    String summary,
                    String detail)

Construct a new FacesMessage with the specified initial values.

Parameters:
severity - the severity
summary - Localized summary message text
detail - Localized detail message text
Throws:
IllegalArgumentException - if the specified severity level is not one of the supported values

Method Detail

public String getDetail()

返回已本地化的详细文本。如果没有为此消息定义已本地化的详细文本,则返回已本地化的摘要文本。

英文文档:

getDetail

public String getDetail()

Return the localized detail text. If no localized detail text has been defined for this message, return the localized summary text instead.


public void setDetail(String detail)

设置已本地化的详细文本。

detail 新的已本地化的详细文本
英文文档:

setDetail

public void setDetail(String detail)

Set the localized detail text.

Parameters:
detail - The new localized detail text

public FacesMessage.Severity getSeverity()

返回严重性级别。

英文文档:

getSeverity

public FacesMessage.Severity getSeverity()

Return the severity level.


public void setSeverity(FacesMessage.Severity severity)

设置严重性级别。

severity 新的严重性级别
ThrowsIllegalArgumentException: 如果指定的严重性级别不是支持的值之一
英文文档:

setSeverity

public void setSeverity(FacesMessage.Severity severity)

Set the severity level.

Parameters:
severity - The new severity level
Throws:
IllegalArgumentException - if the specified severity level is not one of the supported values

public String getSummary()

返回已本地化的摘要文本。

英文文档:

getSummary

public String getSummary()

Return the localized summary text.


public void setSummary(String summary)

设置已本地化的摘要文本。

summary 新的已本地化的摘要文本
英文文档:

setSummary

public void setSummary(String summary)

Set the localized summary text.

Parameters:
summary - The new localized summary text


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!