Message codes
Labels are resolved using a message code hierarchy.
Simply define one or more message sources specifying the properties you want.
Unless custom EntityMessageCodeResolver
instances are being used, message codes are generated as follows:
Message code | Description |
---|---|
Auditable.createdDate |
Output format for the Example: {0,date,medium} {0,time,short} |
Auditable.lastModifiedDate |
Output format for the Example: {0,date,medium} {0,time,short} |
Auditable.created |
Output format for the generated Example: {0,date,medium} {0,time,short} by {1} |
Auditable.lastModified |
Output format for the generated Example: {0,date,medium} {0,time,short} by {1} |
EntityModule.adminMenu |
Title of the root menu group for entity management. |
ModuleName.adminMenu |
Title of the menu group for the entities of that module. |
ModuleName.entities.enums.EnumName.EnumValue |
Message code for a single enum value label. Example: BookingApplicationModule.entities.enums.TicketType.VIP |
EntityPrefix.name.singular |
Label for an entity in singular form, for use outside or at the beginning of a sentence. Example: UserModule.entities.user.name.singular |
EntityPrefix.name.plural |
Label for an entity in plural form, for use outside or at the beginning of a sentence. Example: UserModule.entities.user.name.plural |
EntityPrefix.name.singular.inline |
Label for an entity in singular form, for use within a sentence. If not explicitly specified, the label is generated based by lower-casing the non-inline version. Example: UserModule.entities.user.name.singular.inline_ |
EntityPrefix.name.plural.inline |
Label for an entity in plural form, for use within a sentence. If not explicitly specified, the label is generated based by lower-casing the non-inline version. Example: UserModule.entities.user.name.plural.inline |
EntityPrefix.properties.propertyName |
Label for a single entity property. Example: UserModule.entities.user.properties.username |
EntityPrefix.properties.propertyName[description] |
Description text for a property. Used by default for form groups and fieldsets in a writable form configuration. If not empty, description text will be added before the control in a form group, and above the content of a fieldset. Example: UserModule.entities.user.properties.username[description] |
EntityPrefix.properties.propertyName[help] |
Help text for a property. Used by default for form groups and fieldsets in a writable form configuration. If not empty, help text will be added after the control in a form group, and below the content of a fieldset. Example: UserModule.entities.user.properties.username[help] |
EntityPrefix.properties.propertyName[tooltip] |
Tooltip text for a property. Used by default for form groups and fieldsets in a writable form configuration. If not empty, the tooltip icon will be added in the label of a form group, and in the legend of a fieldset. Example: UserModule.entities.user.properties.username[tooltip] |
EntityPrefix.properties.propertyName[placeholder] |
Placeholder text for a property. Will be used for certain controle like textbox. Example: UserModule.entities.user.properties.username[placeholder] |
EntityPrefix.validation.validatorKey |
Description text for a validation error message. Optionally can be suffixed with the specific property name. Example: UserModule.entities.user.validation.NotBlank, UserModule.entities.user.validation.alreadyExists.username You would then use errors.rejectValue( "username", "alreadyExists" ); after creating the above message code in your message sources. |
EntityPrefix.adminMenu |
Title of the admin menu item for this entity. Defaults to the singular name of the entity. |
EntityPrefix.adminMenu.general |
Name of the General tab. Usually the first tab that is also opened when creating a new entity. |
EntityPrefix.adminMenu.associationName |
Name of the tab for that association. Example: UserModule.entities.group.adminMenu.user.groups |
EntityPrefix.adminMenu.views[viewName] |
Name of the tab for the view with that name (if there is a menu item for that view). |
EntityPrefix.actions.actionName |
Name of the actions, usually the buttons or links on a page. Often you just want to replace these on a global level. Example: EntityModule.entities.actions.save, UserModule.entities.group.actions.cancel |
EntityPrefix.pageTitle.pageName |
Title of the page. Supports message code parameters. Example: UserModule.entities.user.pageTitle.update=Updating {1}: {2} |
EntityPrefix.pageTitle.pageName.subText |
Additional text that should be added as sub text (small) to the page header. Supports message code parameters. |
EntityPrefix.feedback.feedbackType |
Feedback message shown for the given feedback type. Example: UserModule.entities.user.feedback.validationErrors |
EntityPrefix.sortableTable.* |
Sortable table results and pager text keys. Example: UserModule.entities.user.sortableTable.resultsFound |
EntityPrefix.delete.* |
Delete view specific messages. Example: UserModule.entities.user.delete.confirmation |
EntityPrefix.entityQueryFilter.linkToAdvancedMode |
The label for the button to navigate from basic to advanced mode. |
EntityPrefix.entityQueryFilter.linkToBasicMode |
The label for the button to navigate from advanced to basic mode. |
EntityPrefix.entityQueryFilter.eqlPlaceholder |
The placeholder for the eql statement filter. |
EntityPrefix.entityQueryFilter.searchButton |
The label for the entity query filter on the search button. |
EntityPrefix.entityQueryFilter.eqlDescription |
An additional description for the eql statement filter. |
EntityPrefix.entityQueryFilter.convertibleToBasicMode[helpText] |
The descriptive text that should be shown when hovering over the "basic" mode button when the query is not convertible to basic mode. |
EntityPrefix.properties.propertyName[filterNotSelected] |
Label for the empty option in a filter control. |
EntityPrefix.properties.propertyName.value[empty] |
Label for the empty option of an entity property. |
EntityPrefix.properties.propertyName.value[true] |
Label that should be used instead of |
EntityPrefix.properties.propertyName.value[false] |
Label that should be used instead of |
EntityPrefix.properties.propertyName.value[notSet] |
Label that should be used for the |
Entity codes are camel cased, eg.
CarBrand
would become carBrand
EntityPrefix
Every code requested results in several codes being tried with a number of prefixes: The following prefixes are tried in oder:
-
(If association view) ModuleName.entities.sourceEntityName.associations[associationName]
-
ModuleName.entities.entityName
-
EntityModule.entities.entityName
-
EntityModule.entities
When rendering a view, the default prefix will be appended with a view type prefix as well. Usually of the form views[viewType].
Example lookup of property "name" on the default list view for entity "user":
-
MyModule.entities.user.views[listView].properties.name
-
MyModule.entities.user.properties.name
-
MyModule.entities.views[listView].properties.name
-
MyModule.entities.properties.name
-
EntityModule.entities.views[listView].properties.name
-
EntityModule.entities.properties.name
TIP: To get a better insight in the message codes generated, use the entity browser in the developer tools.
Message code parameters
Some message codes support parameters, if so, the following could be available:
-
{0}: entity name
-
{1}: entity name inline
-
{2}: label of the entity being modified (if known)
Customizing message code prefixes
The default message code prefix is MODULE_NAME.entities
.
It’s possible to configure the entity message codes that should be used for a specific module through configuration properties:
entityModule:
message-codes:
MyModule: prefix to use
You can specify multiple prefixes if you want, just realize this will have a big impact on the number of message codes tried.
Debugging message code lookups
You can trace the message codes being resolved by setting the logger named com.foreach.across.modules.entity.support.EntityMessageCodeResolver to TRACE level.
Default message codes
The following is a copy of EntityModule.properties which contains the default message codes for EntityModule.
EntityModule.adminMenu=Entity management
# Default actions
EntityModule.entities.actions.create=Create a new {1}
EntityModule.entities.actions.view=View {1} details
EntityModule.entities.actions.update=Modify {1}
EntityModule.entities.actions.delete=Delete {1}
EntityModule.entities.actions.save=Save
EntityModule.entities.actions.cancel=Cancel
EntityModule.entities.menu.delete=Delete
EntityModule.entities.menu.advanced=Advanced options
EntityModule.entities.buttons.delete=Delete
EntityModule.entities.feedback.entityCreated=New {1} has been created.
EntityModule.entities.feedback.entityUpdated={0} has been updated.
EntityModule.entities.feedback.entityDeleted={0} has been deleted.
EntityModule.entities.feedback.entityDeleteFailed=Exception deleting {1}: {3}.
EntityModule.entities.feedback.validationErrors=Unable to save, please check the form for one or more errors.
EntityModule.entities.feedback.entitySaveFailed=Something went wrong when saving the {1}. <br />Error code: <strong>{4}</strong> ({3}).
EntityModule.entities.pageTitle.create=Create a new {1}
EntityModule.entities.pageTitle.update=Modify {1}: {2}
EntityModule.entities.pageTitle.view=View {1} details: {2}
EntityModule.entities.pageTitle.delete=Delete {1}: {2}
EntityModule.entities.sortableTable.resultsFound={0,choice, 0#No {2}| 1#1 {1}| 1<{0} {2}} found.
EntityModule.entities.sortableTable.pager=Showing page {0,number,#} of {1,number,#}
EntityModule.entities.sortableTable.pager.page=page
EntityModule.entities.sortableTable.pager.ofPages=of
EntityModule.entities.sortableTable.pager.nextPage=next page
EntityModule.entities.sortableTable.pager.previousPage=previous page
EntityModule.entities.delete.confirmation=Are you sure you want to delete this {1} and all its associations?
EntityModule.entities.delete.deleteDisabled=Not possible to delete this {1}.
EntityModule.entities.delete.associations=The following items are associated with this {1}:
EntityModule.entities.delete.associatedResults={2} {1}
#
# Default validation messages
#
EntityModule.entities.validation.Size=Length should be between {2} and {1} characters.
EntityModule.entities.validation.Length=Length should be between {2} and {1} characters.
EntityModule.entities.validation.NotBlank=A value is required.
EntityModule.entities.validation.NotNull=A value is required.
EntityModule.entities.validation.NotEmpty=A value is required.
EntityModule.entities.validation.Email=Email address is not well-formed.
EntityModule.entities.validation.Min=Value should be greater than or equal to {1}.
EntityModule.entities.validation.Max=Value should be less than or equal to {1}.
EntityModule.entities.validation.alreadyExists=Another entity already has this value.
# Default control messages
BootstrapUiModule.SelectFormElementConfiguration.noneSelectedText=
# EntityQueryFilter messages
EntityModule.entities.entityQueryFilter.linkToAdvancedMode=Advanced
EntityModule.entities.entityQueryFilter.linkToBasicMode=Basic
EntityModule.entities.entityQueryFilter.eqlPlaceholder=
EntityModule.entities.entityQueryFilter.searchButton=
EntityModule.entities.entityQueryFilter.eqlDescription=
EntityModule.entities.entityQueryFilter.linkToBasicMode[impossibleTooltip]=Query can not be converted to basic mode.
Auditable.createdDate={0,date,medium} {0,time,short}
Auditable.lastModifiedDate={0,date,medium} {0,time,short}
Auditable.created={0,date,medium} {0,time,short} by {1}
Auditable.lastModified={0,date,medium} {0,time,short} by {1}