Defines an instance name format pattern in the form {0}|{1}, where
- {0} - format string as for
String.format(java.lang.String, java.lang.Object...)
, or a name of this object method, returning string,
with #
symbol in the beginning.
- {1} - comma-separated list of field names, corresponding to format {0}. These fields are also used for
defining a
_minimal
view of this entity.
Extra spaces between parts are not allowed.
Format string example:
@NamePattern("%s : %s|name,address")
Method example:
@NamePattern("#getCaption|login,name")
public class User extends StandardEntity {
...
public String getCaption() {
String pattern = AppContext.getProperty("cuba.user.namePattern");
if (StringUtils.isBlank(pattern)) {
pattern = "{1} [{0}]";
}
MessageFormat fmt = new MessageFormat(pattern);
return fmt.format(new Object[] {login, name});
}
}