public class FacesMessage
extends java.lang.Object
implements java.io.Serializable
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 messageId
s 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 namedResourceBundle
, using theLocale
from the currentUIViewRoot
and see if it has a value for the argumentmessageId
. If it does, treat the value as thesummary
of theFacesMessage
. If it does not, or ifApplication.getMessageBundle()
returnednull
, look in theResourceBundle
named by the value of the constantFACES_MESSAGES
and see if it has a value for the argumentmessageId
. If it does, treat the value as thesummary
of theFacesMessage
. If it does not, there is no initialization information for theFacesMessage
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 thedetail
for the returnedFacesMessage
.Make sure to perform any parameter substitution required for the
summary
anddetail
of theFacesMessage
.
Modifier and Type | Class and Description |
---|---|
static class |
FacesMessage.Severity
Class used to represent message severity levels in a typesafe enumeration.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FACES_MESSAGES
ResourceBundle identifier for messages whose message identifiers are defined in the Jakarta Server Faces
specification. |
static FacesMessage.Severity |
SEVERITY_ERROR
Message severity level indicating that an error has occurred.
|
static FacesMessage.Severity |
SEVERITY_FATAL
Message severity level indicating that a serious error has occurred.
|
static FacesMessage.Severity |
SEVERITY_INFO
Message severity level indicating an informational message rather than an error.
|
static FacesMessage.Severity |
SEVERITY_WARN
Message severity level indicating that an error might have occurred.
|
static java.util.List |
VALUES
Immutable
List of valid FacesMessage.Severity instances, in ascending
order of their ordinal value. |
static java.util.Map |
VALUES_MAP
Immutable
Map of valid FacesMessage.Severity instances, keyed by name. |
Constructor and Description |
---|
FacesMessage()
Construct a new
FacesMessage with no initial values. |
FacesMessage(FacesMessage.Severity severity,
java.lang.String summary,
java.lang.String detail)
Construct a new
FacesMessage with the specified initial values. |
FacesMessage(java.lang.String summary)
Construct a new
FacesMessage with just a summary. |
FacesMessage(java.lang.String summary,
java.lang.String detail)
Construct a new
FacesMessage with the specified initial values. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDetail()
Return the localized detail text.
|
FacesMessage.Severity |
getSeverity()
Return the severity level.
|
java.lang.String |
getSummary()
Return the localized summary text.
|
boolean |
isRendered() |
void |
rendered()
Marks this message as having been rendered to the client.
|
void |
setDetail(java.lang.String detail)
Set the localized detail text.
|
void |
setSeverity(FacesMessage.Severity severity)
Set the severity level.
|
void |
setSummary(java.lang.String summary)
Set the localized summary text.
|
public static final java.lang.String FACES_MESSAGES
ResourceBundle
identifier for messages whose message identifiers are defined in the Jakarta Server Faces
specification.
public static final FacesMessage.Severity SEVERITY_INFO
Message severity level indicating an informational message rather than an error.
public static final FacesMessage.Severity SEVERITY_WARN
Message severity level indicating that an error might have occurred.
public static final FacesMessage.Severity SEVERITY_ERROR
Message severity level indicating that an error has occurred.
public static final FacesMessage.Severity SEVERITY_FATAL
Message severity level indicating that a serious error has occurred.
public static final java.util.List VALUES
Immutable List
of valid FacesMessage.Severity
instances, in ascending
order of their ordinal value.
public static final java.util.Map VALUES_MAP
Immutable Map
of valid FacesMessage.Severity
instances, keyed by name.
public FacesMessage()
Construct a new FacesMessage
with no initial values. The severity is set to
Severity.INFO.
public FacesMessage(java.lang.String summary)
Construct a new FacesMessage
with just a summary. The detail is null
,
the severity is set to Severity.INFO
.
summary
- the summary.public FacesMessage(java.lang.String summary, java.lang.String detail)
Construct a new FacesMessage
with the specified initial values. The severity is set
to Severity.INFO.
summary
- Localized summary message textdetail
- Localized detail message textjava.lang.IllegalArgumentException
- if the specified severity level is not one of the supported valuespublic FacesMessage(FacesMessage.Severity severity, java.lang.String summary, java.lang.String detail)
Construct a new FacesMessage
with the specified initial values.
severity
- the severitysummary
- Localized summary message textdetail
- Localized detail message textjava.lang.IllegalArgumentException
- if the specified severity level is not one of the supported valuespublic java.lang.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(java.lang.String detail)
Set the localized detail text.
detail
- The new localized detail textpublic FacesMessage.Severity getSeverity()
Return the severity level.
public void setSeverity(FacesMessage.Severity severity)
Set the severity level.
severity
- The new severity leveljava.lang.IllegalArgumentException
- if the specified severity level is not one of the supported valuespublic java.lang.String getSummary()
Return the localized summary text.
public void setSummary(java.lang.String summary)
Set the localized summary text.
summary
- The new localized summary textpublic boolean isRendered()
true
if rendered()
has been called, otherwise false
public void rendered()
Marks this message as having been rendered to the client.