Top Description Inners Fields Constructors Methods
jakarta.faces.application

public Class FacesMessage

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
jakarta.faces.component.MessageFactory.BindingFacesMessage, jakarta.faces.convert.MessageFactory.BindingFacesMessage, jakarta.faces.validator.MessageFactory.BindingFacesMessage, jakarta.faces.webapp.MessageFactory.BindingFacesMessage
Static Imports
java.util.Arrays.asList, .Collections.unmodifiableList, .Collections.unmodifiableMap

FacesMessage represents a single validation (or other) message, which is typically associated with a particular component in the view. A jakarta.faces.application.FacesMessage instance may be created based on a specific messageId. The specification defines the set of messageIds for which there must be jakarta.faces.application.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 jakarta.faces.component.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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
FacesMessage.Severity

Class used to represent message severity levels in a typesafe enumeration.

Field Summary

Modifier and TypeField and Description
private static Map<String, FacesMessage.Severity>
private transient String
public static final String
FACES_MESSAGES

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

private transient boolean
private static final long
private transient FacesMessage.Severity
public static final FacesMessage.Severity
SEVERITY_ERROR

Message severity level indicating that an error has occurred.

private static final String
public static final FacesMessage.Severity
SEVERITY_FATAL

Message severity level indicating that a serious error has occurred.

private static final String
public static final FacesMessage.Severity
SEVERITY_INFO

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

private static final String
public static final FacesMessage.Severity
SEVERITY_WARN

Message severity level indicating that an error might have occurred.

private static final String
private transient String
private static final FacesMessage.Severity[]
values

Array of all defined values, ascending order of ordinal value.

public static final List<E>
VALUES

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

public static final Map<K, V>
VALUES_MAP

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

Constructor Summary

AccessConstructor and Description
public
FacesMessage()

Construct a new jakarta.faces.application.FacesMessage with no initial values.

public
FacesMessage(String
the summary.
summary
)

Construct a new jakarta.faces.application.FacesMessage with just a summary.

public
FacesMessage(String
Localized summary message text
summary
,
String
Localized detail message text
detail
)

Construct a new jakarta.faces.application.FacesMessage with the specified initial values.

public
FacesMessage(FacesMessage.Severity
the severity
severity
,
String
Localized summary message text
summary
,
String
Localized detail message text
detail
)

Construct a new FacesMessage with the specified initial values.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the localized detail text.
getDetail
()

Return the localized detail text.

public FacesMessage.Severity

Returns:

the severity level.
getSeverity
()

Return the severity level.

public String

Returns:

the localized summary text.
getSummary
()

Return the localized summary text.

public boolean

Returns:

true if rendered() has been called, otherwise false
isRendered
()

private void
readObject(ObjectInputStream
The binary input of the object to be read
in
)

Reconstruct jakarta.faces.application.FacesMessage from serialized artifacts.

public void
rendered()

Marks this message as having been rendered to the client.

public void
setDetail(String
The new localized detail text
detail
)

Set the localized detail text.

public void
setSeverity(FacesMessage.Severity
The new severity level
severity
)

Set the severity level.

public void
setSummary(String
The new localized summary text
summary
)

Set the localized summary text.

private void
writeObject(ObjectOutputStream
The target stream to which the object will be written.
out
)

Persist jakarta.faces.application.FacesMessage artifacts, including the non serializable Severity.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_MODIFIABLE_MAPback to summary
private static Map<String, FacesMessage.Severity> _MODIFIABLE_MAP
detailback to summary
private transient String detail
FACES_MESSAGESback to summary
public static final String FACES_MESSAGES

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

renderedback to summary
private transient boolean rendered
serialVersionUIDback to summary
private static final long serialVersionUID
severityback to summary
private transient FacesMessage.Severity severity
SEVERITY_ERRORback to summary
public static final FacesMessage.Severity SEVERITY_ERROR

Message severity level indicating that an error has occurred.

SEVERITY_ERROR_NAMEback to summary
private static final String SEVERITY_ERROR_NAME
SEVERITY_FATALback to summary
public static final FacesMessage.Severity SEVERITY_FATAL

Message severity level indicating that a serious error has occurred.

SEVERITY_FATAL_NAMEback to summary
private static final String SEVERITY_FATAL_NAME
SEVERITY_INFOback to summary
public static final FacesMessage.Severity SEVERITY_INFO

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

SEVERITY_INFO_NAMEback to summary
private static final String SEVERITY_INFO_NAME
SEVERITY_WARNback to summary
public static final FacesMessage.Severity SEVERITY_WARN

Message severity level indicating that an error might have occurred.

SEVERITY_WARN_NAMEback to summary
private static final String SEVERITY_WARN_NAME
summaryback to summary
private transient String summary
valuesback to summary
private static final FacesMessage.Severity[] values

Array of all defined values, ascending order of ordinal value. Be sure you include any new instances created above, in the same order.

VALUESback to summary
public static final List<E> VALUES

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

VALUES_MAPback to summary
public static final Map<K, V> VALUES_MAP

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

Constructor Detail

FacesMessageback to summary
public FacesMessage()

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

FacesMessageback to summary
public FacesMessage(String summary)

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

Parameters
summary:String

the summary.

FacesMessageback to summary
public FacesMessage(String summary, String detail)

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

Parameters
summary:String

Localized summary message text

detail:String

Localized detail message text

Exceptions
IllegalArgumentException:
if the specified severity level is not one of the supported values
FacesMessageback to summary
public FacesMessage(FacesMessage.Severity severity, String summary, String detail)

Construct a new FacesMessage with the specified initial values.

Parameters
severity:FacesMessage.Severity

the severity

summary:String

Localized summary message text

detail:String

Localized detail message text

Exceptions
IllegalArgumentException:
if the specified severity level is not one of the supported values

Method Detail

getDetailback to summary
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:String

the localized detail text.

getSeverityback to summary
public FacesMessage.Severity getSeverity()

Return the severity level.

Returns:FacesMessage.Severity

the severity level.

getSummaryback to summary
public String getSummary()

Return the localized summary text.

Returns:String

the localized summary text.

isRenderedback to summary
public boolean isRendered()
Returns:boolean

true if rendered() has been called, otherwise false

Since
2.0
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException

Reconstruct jakarta.faces.application.FacesMessage from serialized artifacts.

Parameters
in:ObjectInputStream

The binary input of the object to be read

Exceptions
IOException:
Any of the usual Input/Output related exceptions.
ClassNotFoundException:
Class of a serialized object cannot be found.
renderedback to summary
public void rendered()

Marks this message as having been rendered to the client.

Since
2.0
setDetailback to summary
public void setDetail(String detail)

Set the localized detail text.

Parameters
detail:String

The new localized detail text

setSeverityback to summary
public void setSeverity(FacesMessage.Severity severity)

Set the severity level.

Parameters
severity:FacesMessage.Severity

The new severity level

Exceptions
IllegalArgumentException:
if the specified severity level is not one of the supported values
setSummaryback to summary
public void setSummary(String summary)

Set the localized summary text.

Parameters
summary:String

The new localized summary text

writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException

Persist jakarta.faces.application.FacesMessage artifacts, including the non serializable Severity.

Parameters
out:ObjectOutputStream

The target stream to which the object will be written.

Exceptions
IOException:
Any of the usual Input/Output related exceptions.
jakarta.faces.application back to summary

public Class FacesMessage.Severity

extends Object
implements Comparable
Class Inheritance
All Implemented Interfaces
java.lang.Comparable

Class used to represent message severity levels in a typesafe enumeration.

Field Summary

Modifier and TypeField and Description
private static int
nextOrdinal

Static counter returning the ordinal value to be assigned to the next instance that is created.

private final int
ordinal

The ordinal value assigned to this instance.

pack-priv String
severityName

The (optional) name for this severity.

Constructor Summary

AccessConstructor and Description
private
Severity(String newSeverityName)

Private constructor to disable the creation of new instances.

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(Object
The other object to be compared to
other
)

Implements java.lang.Comparable.compareTo.

Compare this jakarta.faces.application.FacesMessage.Severity instance to the specified one.

public int

Returns:

the ordinal.
getOrdinal
()

Return the ordinal value of this FacesMessage.Severity instance.

public String
toString()

Overrides java.lang.Object.toString.

Return a String representation of this FacesMessage.Severity instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

nextOrdinalback to summary
private static int nextOrdinal

Static counter returning the ordinal value to be assigned to the next instance that is created.

ordinalback to summary
private final int ordinal

The ordinal value assigned to this instance.

severityNameback to summary
pack-priv String severityName

The (optional) name for this severity.

Constructor Detail

Severityback to summary
private Severity(String newSeverityName)

Private constructor to disable the creation of new instances.

Method Detail

compareToback to summary
public int compareTo(Object other)

Implements java.lang.Comparable.compareTo.

Compare this jakarta.faces.application.FacesMessage.Severity instance to the specified one. Returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.

Parameters
other:Object

The other object to be compared to

Returns:int

Doc from java.lang.Comparable.compareTo.

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
getOrdinalback to summary
public int getOrdinal()

Return the ordinal value of this FacesMessage.Severity instance.

Returns:int

the ordinal.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return a String representation of this FacesMessage.Severity instance.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override