/** * <p> * Returns a new instance of {@link TableConfiguration} corresponding to * {@link ConfigLoader#DEFAULT_GROUP_NAME}, i.e. containing all global * configuration. * </p> * <p> * The instance is duplicated from the template instance stored in the * {@link #OPTIONS_BY_GROUP_BY_LOCALE} map. * </p> * * @param tableId * The DOM id of the HTML table. * @param request * The current request. * @return a new and initialized instance of {@link TableConfiguration}. */ public static TableConfiguration newInstance(String tableId, HttpServletRequest request) { return newInstance(tableId, request, ConfigLoader.DEFAULT_GROUP_NAME); }
@Override protected Map<String, Object> getPageContext() { Map<Locale, Map<String, Map<Option<?>, Object>>> store = TableConfigurationFactory.getConfigurationStore(); Locale currentLocale = DatatableConfigurator.getLocaleResolver().resolveLocale(context.getRequest()); List<Map<String, Object>> groupsJson = new ArrayList<Map<String, Object>>(); int index = 0; for (Entry<String, Map<Option<?>, Object>> entry : store.get(currentLocale).entrySet()) { Map<String, Object> groupJson = new HashMap<String, Object>(); groupJson.put("groupName", StringUtils.capitalize(entry.getKey())); groupJson.put("options", getGroupOptions(entry.getValue())); groupJson.put("active", index == 0 ? "active" : ""); groupsJson.add(groupJson); index++; } Map<String, Object> pageContext = new HashMap<String, Object>(); pageContext.put("groups", groupsJson); pageContext.put("page-header", PAGE_NAME); return pageContext; }
resolveGroupsForLocale(locale, request);
@Override protected Map<String, Object> getPageContext() { Map<Locale, Map<String, Map<Option<?>, Object>>> store = TableConfigurationFactory.getConfigurationStore(); Locale currentLocale = DatatableConfigurator.getLocaleResolver().resolveLocale(context.getRequest()); List<Map<String, Object>> groupsJson = new ArrayList<Map<String, Object>>(); int index = 0; for (Entry<String, Map<Option<?>, Object>> entry : store.get(currentLocale).entrySet()) { Map<String, Object> groupJson = new HashMap<String, Object>(); groupJson.put("groupName", StringUtils.capitalize(entry.getKey())); groupJson.put("options", getGroupOptions(entry.getValue())); groupJson.put("active", index == 0 ? "active" : ""); groupsJson.add(groupJson); index++; } Map<String, Object> pageContext = new HashMap<String, Object>(); pageContext.put("groups", groupsJson); pageContext.put("page-header", PAGE_NAME); return pageContext; }
resolveGroupsForLocale(locale, request);
/** * <p> * Returns a new instance of {@link TableConfiguration} corresponding to * {@link ConfigLoader#DEFAULT_GROUP_NAME}, i.e. containing all global * configuration. * </p> * <p> * The instance is duplicated from the template instance stored in the * {@link #OPTIONS_BY_GROUP_BY_LOCALE} map. * </p> * * @param tableId * The DOM id of the HTML table. * @param request * The current request. * @return a new and initialized instance of {@link TableConfiguration}. */ public static TableConfiguration newInstance(String tableId, HttpServletRequest request) { return newInstance(tableId, request, ConfigLoader.DEFAULT_GROUP_NAME); }
private List<Map<String, Object>> getTableOptions(HtmlTable htmlTable, HttpServletRequest request) { Map<Locale, Map<String, Map<Option<?>, Object>>> store = TableConfigurationFactory.getConfigurationStore(); Locale locale = null; if (request != null) { locale = DatatableConfigurator.getLocaleResolver().resolveLocale(request); } else { locale = Locale.getDefault(); } List<Map<String, Object>> tableOptions = new ArrayList<Map<String, Object>>(); for (Entry<Option<?>, Object> entry : store.get(locale) .get(htmlTable.getTableConfiguration().getOptionGroupName()).entrySet()) { tableOptions.add(new MapBuilder<String, Object>() .entry("name", entry.getKey().getName()).entry("value", entry.getValue() instanceof Extension ? entry.getValue().getClass().getCanonicalName() : entry.getValue()) .entry("precedence", entry.getKey().getPrecedence()).create()); } return tableOptions; } }
public HtmlTable(String id, HttpServletRequest request, HttpServletResponse response, String groupName, Map<String, String> dynamicAttributes) { this.tag = "table"; this.originalId = id; this.id = processId(id); this.dynamicAttributes = dynamicAttributes; this.tableConfiguration = TableConfigurationFactory.newInstance(id, request, groupName); }
private List<Map<String, Object>> getTableOptions(HtmlTable htmlTable, HttpServletRequest request) { Map<Locale, Map<String, Map<Option<?>, Object>>> store = TableConfigurationFactory.getConfigurationStore(); Locale locale = null; if (request != null) { locale = DatatableConfigurator.getLocaleResolver().resolveLocale(request); } else { locale = Locale.getDefault(); } List<Map<String, Object>> tableOptions = new ArrayList<Map<String, Object>>(); for (Entry<Option<?>, Object> entry : store.get(locale) .get(htmlTable.getTableConfiguration().getOptionGroupName()).entrySet()) { tableOptions.add(new MapBuilder<String, Object>() .entry("name", entry.getKey().getName()).entry("value", entry.getValue() instanceof Extension ? entry.getValue().getClass().getCanonicalName() : entry.getValue()) .entry("precedence", entry.getKey().getPrecedence()).create()); } return tableOptions; } }
public HtmlTable(String id, HttpServletRequest request, HttpServletResponse response, String groupName, Map<String, String> dynamicAttributes) { this.tag = "table"; this.originalId = id; this.id = processId(id); this.dynamicAttributes = dynamicAttributes; this.tableConfiguration = TableConfigurationFactory.newInstance(id, request, groupName); }