com.github.dandelion.datatables.core.configuration
Interface ConfigurationLoader

All Known Implementing Classes:
StandardConfigurationLoader

public interface ConfigurationLoader

Interface for all configuration loaders.

The default implementation is the StandardConfigurationLoader class but it can be replaced by another class that implements this interface thanks to the DatatablesConfigurator.

Since:
0.9.0
Author:
Thibault Duchateau

Field Summary
static String DEFAULT_GROUP_NAME
           
static String DT_DEFAULT_PROPERTIES
           
static String DT_USER_PROPERTIES
           
static String DT_USER_PROPERTIES_LOCATION
           
static String I18N_LOCALE_RESOLVER
           
static String I18N_MESSAGE_RESOLVER
           
static String STANDALONE_BUNDLES_TO_EXCLUDE
           
 
Method Summary
 Properties loadDefaultConfiguration()
           Load the default configuration from the internal properties file and both: stores the properties inside a class field returns the properties if they need to be used outside of the class
 Properties loadUserConfiguration(Locale locale)
           Load the user configuration which can be localized thanks to the given locale.
 void resolveConfigurations(Map<String,Map<ConfigToken<?>,Object>> map, Locale locale, javax.servlet.http.HttpServletRequest request)
           Resolve configuration groups for the given locale.
 Set<String> resolveGroups(Locale locale)
           Return a set containing all configuration groups.
 

Field Detail

DT_DEFAULT_PROPERTIES

static final String DT_DEFAULT_PROPERTIES
See Also:
Constant Field Values

DT_USER_PROPERTIES_LOCATION

static final String DT_USER_PROPERTIES_LOCATION
See Also:
Constant Field Values

DT_USER_PROPERTIES

static final String DT_USER_PROPERTIES
See Also:
Constant Field Values

DEFAULT_GROUP_NAME

static final String DEFAULT_GROUP_NAME
See Also:
Constant Field Values

STANDALONE_BUNDLES_TO_EXCLUDE

static final String STANDALONE_BUNDLES_TO_EXCLUDE
See Also:
Constant Field Values

I18N_LOCALE_RESOLVER

static final String I18N_LOCALE_RESOLVER
See Also:
Constant Field Values

I18N_MESSAGE_RESOLVER

static final String I18N_MESSAGE_RESOLVER
See Also:
Constant Field Values
Method Detail

loadDefaultConfiguration

Properties loadDefaultConfiguration()

Load the default configuration from the internal properties file and both:

Returns:
the default properties

loadUserConfiguration

Properties loadUserConfiguration(Locale locale)

Load the user configuration which can be localized thanks to the given locale.

Once the bundle loaded, it is converted into Properties.

Parameters:
locale - The current locale used to load the right properties file.
Returns:
the ResourceBundle containing the user configuration.

resolveGroups

Set<String> resolveGroups(Locale locale)

Return a set containing all configuration groups.

Note that the i18n.locale.resolver is a special property that must not be taken into account because it is group-independent.

Parameters:
locale - The current locale.
Returns:
the resolved groups.

resolveConfigurations

void resolveConfigurations(Map<String,Map<ConfigToken<?>,Object>> map,
                           Locale locale,
                           javax.servlet.http.HttpServletRequest request)

Resolve configuration groups for the given locale.

The default properties file (datatables-default.properties) already contains the 'global' group: this is the group of configuration that is used for all tables in the application.

Inside the user properties files (datatables_XX.properties), users can:

For example, if the user properties file contains:
group1.i18n.msg.search=My label
group1.i18n.msg.processing=My other label

the ConfigurationLoader must create a group called 'group1' containing all properties present in the 'global' group but where i18n.msg.search and i18n.msg.processing are overriden with the user's ones.

Note that:

Parameters:
map - The map to update after the resolution of the configuration groups.
locale - The current locale used to get the right properties file from the resource bundle.
request - The request sent by the browser.


Copyright © 2013–2014 Dandelion Project. All rights reserved.