|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=RUNTIME) @Documented @Target(value=FIELD) public @interface MessageParam
Adds information to a field of an exception about which parameter in a message it provides information.
ParentMessageParam
Optional Element Summary | |
---|---|
String |
detailsParamIndex The index of the place holder in the details message text the field provides information for. |
String |
headerParamIndex The index of the place holder in the header message text the field provides information for. |
String |
implicationsParamIndex The index of the place holder in the implications message text the field provides information for. |
String |
summaryParamIndex The index of the place holder in the summary message text the field provides information for. |
String |
todoParamIndex The index of the place holder in the todo message text the field provides information for. |
String |
urlParamIndex The index of the place holder in the URL message text the field provides information for. |
String |
value The index of the place holder in the message text the field provides information for. |
public abstract String value
If the index is not the same for every message text, use
headerParamIndex()
summaryParamIndex()
detailsParamIndex()
implicationsParamIndex()
todoParamIndex()
urlParamIndex()
If the index is not sufficient, because there is a certain property within the referenced entity/value object, an OGNL (Object-Graph Navigation Language) expression is added to access a particular value. The basic syntax for this is
Syntax: Index with OGNL expression
index:ognl-expression
Index with OGNL Expression
1:user.name
Here we show some examples on how this annotation is used.
Example 1
You want to include the value of a property.
Annotation: Index without OGNL Path
@MessageParam("0") protected final String name; @MessageParam("1") protected final String description;
Message bundle content
msgX=For '' 0
The placeholder at index zero (0
) is replaced by the name the placeholder at index one (1
) is replaced by the description.
Example 2
You want to display the canonical name of a referenced class.
Annotation: Index and OGNL Path
@MessageParam("0:canonicalName") protected final Class<?> clazz;
Message bundle content
msgY=The class with name '' 0
The placeholder at index zero (0
) is replaced by the canonical name
of the referenced class.
Example 3
If several properties of a referenced entity are to be displayed at different indices, separate them by commas.
Annotation: Several Properties
@MessageParam("0:user.name,2:user.id,3:description") protected final Context context; @MessageParam("1") protected final Date date;
Message bundle content
msgZ= 1,date
This uses the user's name
for the placeholder with index 0
, the identifier (id
) of the user at index 2
and the descriptive text of the context ( description
) at index 3
. The Context
class in this example provides a property user
and description
, the user provides the properties name
and id
. The date provides information for index 1
to show that the indices of several message parameters are not required to be consecutive.
public abstract String headerParamIndex
public abstract String summaryParamIndex
public abstract String detailsParamIndex
public abstract String implicationsParamIndex
public abstract String todoParamIndex
public abstract String urlParamIndex
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |