for (Iterator i = listing.columnIterator(); i.hasNext();)
{
ColumnDescriptor column = (ColumnDescriptor) i.next();
Output outColumn = response.createOutput(String.valueOf(colNum++));
if ("custom".equals(column.getViewer()))
{
outColumn.setAttribute("viewer", "text");
if (handler != null)
{
CellData cellData = handler.handleResult(request, response, listing, new SqlRowData(listing, set),
column);
outColumn.setContent(cellData.getValue());
outColumn.setAttribute("viewer", cellData.getViewer().toString());
outColumn.setAttribute("bundle", cellData.getBundle());
}
else
{
outColumn.setContent("");
}
}
else if ("combo".equals(column.getViewer()))
{
Object value = set.getObject(column.getAs());
outColumn.setAttribute("viewer", column.getViewer());
outColumn.setAttribute("bundle", column.getBundle());
outColumn.setContent(! StringTools.isTrimEmpty(value) ? "opt" + value : "-");
}
else if ("message".equals(column.getViewer()))
{
outColumn.setAttribute("viewer", column.getViewer());
Object value = set.getObject(column.getAs());
outColumn.setAttribute("bundle", column.getBundle());
String[] parts = value.toString().split("\\|");
StringBuffer sb = new StringBuffer(parts[0]);
for (int j = 1; j < parts.length; ++j)
{
if (parts[j].startsWith("?"))
{
sb.append("|" + set.getString(parts[j].substring(1).replace('.', '_')));
}
else
{
sb.append("|" + parts[j]);
}
}
outColumn.setContent(sb.toString());
}
else if (column.getViewer().startsWith("icon:"))
{
Object value = set.getObject(column.getAs());
String viewer = column.getViewer();
int slashPos = viewer.indexOf('|');
String iconTrue = viewer.substring(5, slashPos > 0 ? slashPos : viewer.length());
String iconFalse = slashPos > 0 ? viewer.substring(slashPos + 1, viewer.length()) : "blank";
outColumn.setAttribute("viewer", "icon");
outColumn.setContent(NumberTools.toBool(value, false) ? iconTrue : iconFalse);
}
else if (column.getViewer().startsWith("handler:"))
{
Object value = set.getObject(column.getAs());
outColumn.setAttribute("viewer", "text");
try
{
Class cellHandler = Class.forName(column.getViewer().substring(8));
String cellRes = cellHandler.getMethod("format", new Class[]
{
Object.class
}).invoke(null, value).toString();
outColumn.setContent(cellRes);
}
catch (InvocationTargetException x)
{
outColumn.setContent(x.getTargetException().toString());
}
catch (Exception x)
{
outColumn.setContent(x.toString());
}
}
else if (column.getViewer().startsWith("js:"))
{
String[] params = column.getViewer().split(":");
outColumn.setAttribute("viewer", "js");
outColumn.setContent(params[1]);
outColumn.setAttribute("name", column.getName());
outColumn.setAttribute("id", ids);
}
else if ("province".equals(column.getViewer()))
{
outColumn.setAttribute("viewer", column.getViewer());
Object country = null;
try
{
country = set.getObject(column.getAs() + "country");
}
catch (Exception ignored)
{
}
Object value = set.getObject(column.getAs());
if (! StringTools.isTrimEmpty(value))
{
outColumn.setContent((! StringTools.isTrimEmpty(country) ? country + "." : "")
+ StringTools.trim(value));
}
else
{
outColumn.setContent("");
}
}
else
{
outColumn.setAttribute("viewer", column.getViewer());
Object value = set.getObject(column.getAs());
outColumn.setContent(! StringTools.isTrimEmpty(value) ? value : "");
}
if (! column.isVisible())
{
outColumn.setAttribute("hide", "Y");
}
outItem.add(outColumn);
}