Class FacesMessage
- java.lang.Object
-
- jakarta.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
FacesMessageinstance may be created based on a specificmessageId. The specification defines the set ofmessageIds for which there must beFacesMessageinstances.The implementation must take the following steps when creating
FacesMessageinstances given amessageId:Call
Application.getMessageBundle(). If non-null, locate the namedResourceBundle, using theLocalefrom the currentUIViewRootand see if it has a value for the argumentmessageId. If it does, treat the value as thesummaryof theFacesMessage. If it does not, or ifApplication.getMessageBundle()returnednull, look in theResourceBundlenamed by the value of the constantFACES_MESSAGESand see if it has a value for the argumentmessageId. If it does, treat the value as thesummaryof theFacesMessage. If it does not, there is no initialization information for theFacesMessageinstance.In all cases, if a
ResourceBundlehit is found for the{messageId}, look for further hits under the key{messageId}_detail. Use this value, if present, as thedetailfor the returnedFacesMessage.Make sure to perform any parameter substitution required for the
summaryanddetailof theFacesMessage.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFacesMessage.SeverityClass used to represent message severity levels in a typesafe enumeration.
-
Field Summary
Fields Modifier and Type Field Description static StringFACES_MESSAGESResourceBundleidentifier for messages whose message identifiers are defined in the Jakarta Faces specification.static FacesMessage.SeveritySEVERITY_ERRORMessage severity level indicating that an error has occurred.static FacesMessage.SeveritySEVERITY_FATALMessage severity level indicating that a serious error has occurred.static FacesMessage.SeveritySEVERITY_INFOMessage severity level indicating an informational message rather than an error.static FacesMessage.SeveritySEVERITY_WARNMessage severity level indicating that an error might have occurred.static ListVALUESImmutableListof validFacesMessage.Severityinstances, in ascending order of their ordinal value.static MapVALUES_MAPImmutableMapof validFacesMessage.Severityinstances, keyed by name.
-
Constructor Summary
Constructors Constructor Description FacesMessage()Construct a newFacesMessagewith no initial values.FacesMessage(FacesMessage.Severity severity, String summary, String detail)Construct a newFacesMessagewith the specified initial values.FacesMessage(String summary)Construct a newFacesMessagewith just a summary.FacesMessage(String summary, String detail)Construct a newFacesMessagewith the specified initial values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDetail()Return the localized detail text.FacesMessage.SeveritygetSeverity()Return the severity level.StringgetSummary()Return the localized summary text.booleanisRendered()voidrendered()Marks this message as having been rendered to the client.voidsetDetail(String detail)Set the localized detail text.voidsetSeverity(FacesMessage.Severity severity)Set the severity level.voidsetSummary(String summary)Set the localized summary text.
-
-
-
Field Detail
-
FACES_MESSAGES
public static final String FACES_MESSAGES
ResourceBundleidentifier for messages whose message identifiers are defined in the Jakarta 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
Listof validFacesMessage.Severityinstances, in ascending order of their ordinal value.
-
VALUES_MAP
public static final Map VALUES_MAP
Immutable
Mapof validFacesMessage.Severityinstances, keyed by name.
-
-
Constructor Detail
-
FacesMessage
public FacesMessage()
Construct a new
FacesMessagewith no initial values. The severity is set to Severity.INFO.
-
FacesMessage
public FacesMessage(String summary)
Construct a new
FacesMessagewith just a summary. The detail isnull, the severity is set toSeverity.INFO.- Parameters:
summary- the summary.
-
FacesMessage
public FacesMessage(String summary, String detail)
Construct a new
FacesMessagewith 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
FacesMessagewith 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.
- Returns:
- the localized detail text.
-
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.
- Returns:
- 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.
- Returns:
- 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:
trueifrendered()has been called, otherwisefalse- Since:
- 2.0
-
rendered
public void rendered()
Marks this message as having been rendered to the client.
- Since:
- 2.0
-
-