- java.lang.Object
-
- javax.faces.application.FacesMessage
-
- All Implemented Interfaces:
- Serializable
public class FacesMessage extends Object implements 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 specificmessageId
. The specification defines the set ofmessageId
s for which there must beFacesMessage
instances.The implementation must take the following steps when creating
FacesMessage
instances given amessageId
: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
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
FacesMessage.Severity
Class used to represent message severity levels in a typesafe enumeration.
-
Field Summary
Fields Modifier and Type Field and Description static String
FACES_MESSAGES
ResourceBundle
identifier for messages whose message identifiers are defined in the JavaServer 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 List
VALUES
ImmutableList
of validFacesMessage.Severity
instances, in ascending order of their ordinal value.static Map
VALUES_MAP
ImmutableMap
of validFacesMessage.Severity
instances, keyed by name.
-
Constructor Summary
Constructors Constructor and Description FacesMessage()
Construct a newFacesMessage
with no initial values.FacesMessage(FacesMessage.Severity severity, String summary, String detail)
Construct a newFacesMessage
with the specified 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description String
getDetail()
Return the localized detail text.FacesMessage.Severity
getSeverity()
Return the severity level.String
getSummary()
Return the localized summary text.boolean
isRendered()
void
rendered()
Marks this message as having been rendered to the client.void
setDetail(String detail)
Set the localized detail text.void
setSeverity(FacesMessage.Severity severity)
Set the severity level.void
setSummary(String summary)
Set the localized summary text.
-
-
-
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 validFacesMessage.Severity
instances, in ascending order of their ordinal value.
-
VALUES_MAP
public static final Map VALUES_MAP
Immutable
Map
of validFacesMessage.Severity
instances, keyed by name.
-
-
Constructor Detail
-
FacesMessage
public FacesMessage()
Construct a new
FacesMessage
with no initial values. The severity is set to Severity.INFO.
-
FacesMessage
public FacesMessage(String summary)
Construct a new
FacesMessage
with just a summary. The detail isnull
, the severity is set toSeverity.INFO
.
-
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 textdetail
- Localized detail message text- Throws:
IllegalArgumentException
- if the specified severity level is not one of the supported values
-
FacesMessage
public FacesMessage(FacesMessage.Severity severity, String summary, String detail)
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 Detail
-
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.
-
setDetail
public void setDetail(String detail)
Set the localized detail text.
- Parameters:
detail
- The new localized detail text
-
getSeverity
public FacesMessage.Severity getSeverity()
Return the severity level.
-
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
-
getSummary
public String getSummary()
Return the localized summary text.
-
setSummary
public void setSummary(String summary)
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
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/08/2025 13:04:27 Cette version de la page est en cache (à la date du 21/08/2025 13:04:27) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 24/12/2007, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/faces/application/FacesMessage.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.