/** * Formats the text to be displayed as the header by wraping it in a link if sorting is enabled. * Alt (hint) is localized, please define in your property file for messages the property * "sorting" * * @param columnInfo The ColumnInfo. * @param tableInfo The TableInfo. * @param info The ValueListInfo. * @return The formated HTML. */ public String getHeaderLabel( ColumnInfo columnInfo, TableInfo tableInfo, ValueListInfo info, Map includeParameters) { ValueListConfigBean config = tableInfo.getConfig(); Map parameters = new HashMap(includeParameters); if (columnInfo.getDefaultSort() != null) { // Get the current sort column and direction. String column = info.getSortingColumn(); Integer direction = info.getSortingDirection(); parameters.put( ValueListInfo.PAGING_NUMBER_PER + tableInfo.getId(), String.valueOf(info.getPagingNumberPer())); parameters.put(ValueListInfo.PAGING_PAGE + tableInfo.getId(), "1"); parameters.put( ValueListInfo.SORT_COLUMN + tableInfo.getId(), columnInfo.getAdapterPropertyName()); parameters.put( ValueListInfo.SORT_DIRECTION + tableInfo.getId(), ((columnInfo.getAdapterPropertyName().equals(column)) ? (ValueListInfo.ASCENDING.equals(direction) ? ValueListInfo.DESCENDING : ValueListInfo.ASCENDING) : columnInfo.getDefaultSort())); if (info.isFocusEnabled()) { parameters.put( ValueListInfo.DO_FOCUS + tableInfo.getId(), info.isDoFocusAgain() ? "true" : "false"); if (info.getFocusProperty() != null) { parameters.put(ValueListInfo.FOCUS_PROPERTY + tableInfo.getId(), info.getFocusProperty()); } if (info.getFocusValue() != null) { parameters.put(ValueListInfo.FOCUS_VALUE + tableInfo.getId(), info.getFocusValue()); } } StringBuffer sb = new StringBuffer(); renderHeaderLabelLink(sb, columnInfo, tableInfo, info, parameters); if (columnInfo.getAdapterPropertyName().equals(column)) { if (usePadding) { sb.append(" "); } sb.append("<img src=\"") .append(getImageHome((HttpServletRequest) tableInfo.getPageContext().getRequest())) .append("/sort("); sb.append( (ValueListInfo.ASCENDING.equals(direction) ? ValueListInfo.DESCENDING : ValueListInfo.ASCENDING)); sb.append(").png\" border=\"0\"/>"); } else if (columnInfo.getDefaultSort() != null) { Locale locale = config .getLocaleResolver() .resolveLocale((HttpServletRequest) (tableInfo.getPageContext().getRequest())); String altSort; try { altSort = config .getDisplayHelper() .help( tableInfo.getPageContext(), config.getMessageSource().getMessage("sorting", null, "Sort", locale)); } catch (JspException e) { LOGGER.error( "getHeaderLabel() - Error getting property 'sorting' : " + e.getMessage() + " Locale locale = " + locale + ", String column = " + column + " using defalt hint for sorting images."); altSort = "Sort"; } sb.append(((usePadding) ? " " : "")) .append("<img alt=\"") .append(altSort) .append("\" src=\"") .append(getImageHome((HttpServletRequest) tableInfo.getPageContext().getRequest())) .append("/sort(null).png\" border=\"0\"/>"); } return sb.toString(); } else { return columnInfo.getTitle(); } }