@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; }
@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; }
/** * {@inheritDoc} */ @Override public String getResource(String messageKey, String defaultValue, Object... objects) { Locale locale = RequestContextUtils.getLocale(request); String message = null; // Both title and titleKey attributes are not used if (messageKey == null || StringUtils.isBlank(messageKey) && StringUtils.isNotBlank(defaultValue)) { message = StringUtils.capitalize(defaultValue); } // the titleKey attribute is used else { try { message = messageSource.getMessage(messageKey, null, locale); } catch (NoSuchMessageException e) { logger.warn("No message found with the key {} and locale {}.", messageKey, locale); if (StringUtils.isBlank(message)) { message = UNDEFINED_KEY + messageKey + UNDEFINED_KEY; } } } return message; } }
/** * {@inheritDoc} */ @Override public String getResource(String messageKey, String defaultValue, Object... objects) { Locale locale = RequestContextUtils.getLocale(request); String message = null; // Both title and titleKey attributes are not used if (messageKey == null || StringUtils.isBlank(messageKey) && StringUtils.isNotBlank(defaultValue)) { message = StringUtils.capitalize(defaultValue); } // the titleKey attribute is used else { try { message = messageSource.getMessage(messageKey, null, locale); } catch (NoSuchMessageException e) { logger.warn("No message found with the key {} and locale {}.", messageKey, locale); if (StringUtils.isBlank(message)) { message = UNDEFINED_KEY + messageKey + UNDEFINED_KEY; } } } return message; } }
message = StringUtils.capitalize(defaultValue);
message = StringUtils.capitalize(defaultValue);
@Override public BuildStep auto(DatatablesCriterias criteria) { for (ColumnDef columnDef : criteria.getColumnDefs()) { HtmlColumn headerColumn = new HtmlColumn(true, ""); headerColumn.getColumnConfiguration().getOptions().put(DatatableOptions.TITLE, StringUtils.capitalize(columnDef.getName())); headerColumn.getColumnConfiguration().setColumnElements(new ArrayList<ColumnElement>()); headerColumn.getColumnConfiguration().getColumnElements() .add(new ColumnElement(columnDef.getName(), null, null, null)); headerColumns.add(headerColumn); } return this; } }
message = StringUtils.capitalize(defaultValue);
@Override public BuildStep auto(DatatablesCriterias criteria) { for (ColumnDef columnDef : criteria.getColumnDefs()) { HtmlColumn headerColumn = new HtmlColumn(true, ""); headerColumn.getColumnConfiguration().getOptions().put(DatatableOptions.TITLE, StringUtils.capitalize(columnDef.getName())); headerColumn.getColumnConfiguration().setColumnElements(new ArrayList<ColumnElement>()); headerColumn.getColumnConfiguration().getColumnElements() .add(new ColumnElement(columnDef.getName(), null, null, null)); headerColumns.add(headerColumn); } return this; } }
@Override public String getResource(String messageKey, String defaultValue, Object... params) { String message = null; PageContext pageContext = null; // I'm so ashamed about that... pageContext = (PageContext) params[0]; // Both title and titleKey attributes are not used if (messageKey == null || StringUtils.isBlank(messageKey) && StringUtils.isNotBlank(defaultValue)) { message = StringUtils.capitalize(defaultValue); } // the titleKey attribute is used else { OgnlValueStack stack = (OgnlValueStack) TagUtils.getStack(pageContext); for (Object o : stack.getRoot()) { if (o instanceof TextProvider) { TextProvider tp = (TextProvider) o; message = tp.getText(messageKey, UNDEFINED_KEY + messageKey + UNDEFINED_KEY); break; } } } return message; } }