ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);
DefaultRowTag rowTag = (DefaultRowTag) JspUtils.getParent(this, DefaultRowTag.class);
ValueListConfigBean config = rootTag.getConfig();
appendClassCellAttribute(rowTag.getRowStyleClass());
if (locale == null)
{
locale = config.getLocaleResolver().resolveLocale((HttpServletRequest) pageContext.getRequest());
}
if (rowTag.getCurrentRowNumber() == 0) // if this is the 1st row == the one with cell headers
{
String titleKey = getTitleKey();
String label = (titleKey == null) ? getTitle() : config.getMessageSource().getMessage(titleKey, null, titleKey, locale);
ColumnInfo columnInfo = new ColumnInfo(config.getDisplayHelper().help(pageContext, label), getAdapterProperty(), defaultSort,
getAttributes());
// Process toolTip if any
// toolTip or toolTipKey is set => get the string and put it into the ColumnInfo
String toolTipKey = getToolTipKey();
columnInfo.setToolTip((toolTipKey == null) ? getToolTip() : config.getMessageSource().getMessage(toolTipKey, null, toolTipKey,
locale));
columnInfo.setNestedList(this.nestedColumnInfoList);
rowTag.addColumnInfo(columnInfo);
}
DisplayProvider displayProvider = rowTag.getDisplayProvider();
StringBuffer sb = new StringBuffer(displayProvider.getCellPreProcess(getCellAttributes()));
boolean hasBodyContent = false;
if (displayProvider.doesIncludeBodyContent() && bodyContent != null && bodyContent.getString() != null
&& bodyContent.getString().trim().length() > 0)
{
sb.append(bodyContent.getString().trim());
bodyContent.clearBody();
hasBodyContent = true;
}
{
if (property != null && rowTag.getBeanName() != null)
{
try
{
Object bean = pageContext.getAttribute(rowTag.getBeanName());
if (bean != null)
{
Object value = null;
try
{
value = PropertyUtils.getProperty(bean, property);
}
catch (Exception e)
{
//Do nothing, if you want to handle this exception, then
// use a try catch in the body content.
LOGGER.error("<vlh:column> Error getting property='" + property + "' from the iterated JavaBean name='"
+ rowTag.getBeanName() + "'\n The row's JavaBean was >>>" + bean
+ "<<<\n Check the syntax or the spelling of the column's property!");
}
if (value != null)
{
if (sum != null && value instanceof Number)
{
double doubleValue = ((Number) value).doubleValue();
Double sumValue = (Double) pageContext.getAttribute(sum);
if (sumValue == null)
{
sumValue = new Double(doubleValue);
}
else
{
sumValue = new Double(sumValue.doubleValue() + doubleValue);
}
pageContext.setAttribute(sum, sumValue);
}
if( ! hasBodyContent)
{
String formattedValue = JspUtils.format(value, format, locale);
if (groupKey == null
|| (config.getCellInterceptor() == null || !config.getCellInterceptor().isHidden(pageContext, groupKey,
property, formattedValue)))
{
sb.append(displayProvider.emphase(formattedValue, getEmphasisPattern(), getColumnStyleClass()));
}
}
}
else if (!hasBodyContent)
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("The property '" + property + "' of the iterated JavaBean '" + bean + "' is null!");
}
Object nullValue = (defaultValue == null) ? config.getNullToken() : defaultValue;
if (groupKey == null
|| (config.getCellInterceptor() == null || !config.getCellInterceptor().isHidden(pageContext, groupKey,
property, nullValue)))
{
sb.append(nullValue);
}
}