public class JsMessagesRegistry extends Object implements EventListener<ResourceBundleChangedEvent>
Modifier and Type | Field and Description |
---|---|
static String |
CATEGORY_ADMINISTRATION
Built-in category for JS messages required in the administration pages
|
static String |
CATEGORY_COMMON
Built-in category for JS messages required in pages like login, full screen messages,
imprint, terms of use, registration
|
static String |
CATEGORY_PORTAL
Built-in category for JS messages required in the portal page
|
Constructor and Description |
---|
JsMessagesRegistry()
Creates the registry
|
Modifier and Type | Method and Description |
---|---|
void |
addMessageKeys(String providerId,
String category,
Set<String> messageKeys)
Add message keys to the named category.
|
String |
getJsMessages(javax.servlet.http.HttpServletRequest request,
String category)
Returns a string representation of a Javascript object with the localized messages of the
given category.
|
String |
getJsMessages(Locale locale,
String category)
Returns a string representation of a Javascript object with the localized messages of the
given category.
|
long |
getLastModificationTimestamp(String category)
Get timestamp of the last modification of the messages of the category.
|
Class<ResourceBundleChangedEvent> |
getObservedEvent()
Defines the types of events about which this listener will be informed.
|
void |
handle(ResourceBundleChangedEvent event)
Is called by the
EventDispatcher when the observed event was fired. |
void |
removeMessageKeysOfProvider(String provider)
Remove all message keys of the given provider.
|
public static final String CATEGORY_COMMON
public static final String CATEGORY_ADMINISTRATION
public static final String CATEGORY_PORTAL
public void addMessageKeys(String providerId, String category, Set<String> messageKeys)
providerId
- an identifier of the providing instance. This argument is required for removing
the messages later on.category
- the category to extend with further message keys. This can be one of the built-in
categories (use the CATEGORY_* constants) or a new one provided by a plugin.messageKeys
- the message keys to addIllegalArgumentException
- in case the category is null, empty or blankpublic String getJsMessages(javax.servlet.http.HttpServletRequest request, String category)
request
- the current requestcategory
- the category to retrieve. This can be one of the CATEGORY_* constants or a
category defined by a plugin.public String getJsMessages(Locale locale, String category)
locale
- the locale to usecategory
- the category to retrieve. This can be one of the CATEGORY_* constants or a
category defined by a plugin.public long getLastModificationTimestamp(String category)
category
- the name of the categorypublic Class<ResourceBundleChangedEvent> getObservedEvent()
EventListener
getObservedEvent
in interface EventListener<ResourceBundleChangedEvent>
public void handle(ResourceBundleChangedEvent event)
EventListener
EventDispatcher
when the observed event was fired.handle
in interface EventListener<ResourceBundleChangedEvent>
event
- the event that was firedpublic void removeMessageKeysOfProvider(String provider)
provider
- the providerCopyright © 2019 Communote team. All rights reserved.