Class FacesMessage
- All Implemented Interfaces:
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 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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class used to represent message severity levels in a typesafe enumeration. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
ResourceBundle
identifier for messages whose message identifiers are defined in the JavaServer Faces specification.static final FacesMessage.Severity
Message severity level indicating that an error has occurred.static final FacesMessage.Severity
Message severity level indicating that a serious error has occurred.static final FacesMessage.Severity
Message severity level indicating an informational message rather than an error.static final FacesMessage.Severity
Message severity level indicating that an error might have occurred.static final List
ImmutableList
of validFacesMessage.Severity
instances, in ascending order of their ordinal value.static final Map
ImmutableMap
of validFacesMessage.Severity
instances, keyed by name. -
Constructor Summary
ConstructorDescriptionConstruct a newFacesMessage
with no initial values.FacesMessage
(String summary) Construct a newFacesMessage
with just a summary.FacesMessage
(String summary, String detail) Construct a newFacesMessage
with the specified initial values.FacesMessage
(FacesMessage.Severity severity, String summary, String detail) Construct a newFacesMessage
with the specified initial values. -
Method Summary
Modifier and TypeMethodDescriptionReturn the localized detail text.Return the severity level.Return the localized summary text.boolean
void
rendered()
Marks this message as having been rendered to the client.void
Set the localized detail text.void
setSeverity
(FacesMessage.Severity severity) Set the severity level.void
setSummary
(String summary) Set the localized summary text.
-
Field Details
-
FACES_MESSAGES
ResourceBundle
identifier for messages whose message identifiers are defined in the JavaServer Faces specification.- See Also:
-
SEVERITY_INFO
Message severity level indicating an informational message rather than an error.
-
SEVERITY_WARN
Message severity level indicating that an error might have occurred.
-
SEVERITY_ERROR
Message severity level indicating that an error has occurred.
-
SEVERITY_FATAL
Message severity level indicating that a serious error has occurred.
-
VALUES
Immutable
List
of validFacesMessage.Severity
instances, in ascending order of their ordinal value. -
VALUES_MAP
Immutable
Map
of validFacesMessage.Severity
instances, keyed by name.
-
-
Constructor Details
-
FacesMessage
public FacesMessage()Construct a new
FacesMessage
with no initial values. The severity is set to Severity.INFO. -
FacesMessage
Construct a new
FacesMessage
with just a summary. The detail isnull
, the severity is set toSeverity.INFO
. -
FacesMessage
Construct a new
FacesMessage
with the specified initial values. The severity is set to Severity.INFO.- Parameters:
summary
- Localized summary message textdetail
- Localized detail message text- Throws:
IllegalArgumentException
- if the specified severity level is not one of the supported values
-
FacesMessage
Construct a new
FacesMessage
with the specified initial values.- Parameters:
severity
- the severitysummary
- Localized summary message textdetail
- Localized detail message text- Throws:
IllegalArgumentException
- if the specified severity level is not one of the supported values
-
-
Method Details
-
getDetail
Return the localized detail text. If no localized detail text has been defined for this message, return the localized summary text instead.
-
setDetail
Set the localized detail text.
- Parameters:
detail
- The new localized detail text
-
getSeverity
Return the severity level.
-
setSeverity
Set the severity level.
- Parameters:
severity
- The new severity level- Throws:
IllegalArgumentException
- if the specified severity level is not one of the supported values
-
getSummary
Return the localized summary text.
-
setSummary
Set the localized summary text.
- Parameters:
summary
- The new localized summary text
-
isRendered
public boolean isRendered()- Returns:
true
ifrendered()
has been called, otherwisefalse
- Since:
- 2.0
-
rendered
public void rendered()Marks this message as having been rendered to the client.
- Since:
- 2.0
-