de.smartics.exceptions.i18n.message
Annotation Type MessageParam


@Retention(value=RUNTIME)
@Documented
@Target(value={FIELD,METHOD})
public @interface MessageParam

Adds information to a field of an exception about which parameter in a message it provides information.

See Also:
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.
 

value

public abstract String value
The index of the place holder in the message text the field provides information for. The index is zero based.

If the index is not the same for every message text, use

to override this (default) index.

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}''
this is the description: {1}

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\
'' cannot be found.}

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} at {1,time}: For user ''{0}'' (ID={2}) this is the description: {3}

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.

Default:
""

headerParamIndex

public abstract String headerParamIndex
The index of the place holder in the header message text the field provides information for.

Default:
""

summaryParamIndex

public abstract String summaryParamIndex
The index of the place holder in the summary message text the field provides information for.

Default:
""

detailsParamIndex

public abstract String detailsParamIndex
The index of the place holder in the details message text the field provides information for.

Default:
""

implicationsParamIndex

public abstract String implicationsParamIndex
The index of the place holder in the implications message text the field provides information for.

Default:
""

todoParamIndex

public abstract String todoParamIndex
The index of the place holder in the todo message text the field provides information for.

Default:
""

urlParamIndex

public abstract String urlParamIndex
The index of the place holder in the URL message text the field provides information for.

Default:
""


Copyright © 2007-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.