* @see org.apache.wicket.MarkupContainer#onRender()
*/
@Override
protected void onRender()
{
Response response = RequestCycle.get().getResponse();
double widths[] = computeColumnWidths();
NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH);
nf.setMaximumFractionDigits(0);
nf.setMaximumFractionDigits(2);
for (int i = 0; i < columns.size(); ++i)
{
Component component = components.get(i);
IRenderable renderable = renderables.get(i);
IColumn column = columns.get(i);
// write the wrapping column markup
response.write("<span class=\"b_\" style=\"width:" + nf.format(widths[i]) + "%\">");
// determine whether we should render the left border
if (!treeHasLeftColumn && (i == 0))
{
response.write("<span class=\"d_\">");
}
else
{
response.write("<span class=\"c_\">");
}
if (component != null) // is there a component for current column?
{
// render the component
component.render();
}
else if (renderable != null) // no component - try to render
// renderable
{
renderable.render(node, response);
}
else
{
// no renderable or component. fail
throw new IllegalStateException(
"Either renderable or cell component must be created for this noode");
}
// end of wrapping markup
response.write("</span></span>\n");
// does this component span over other columns
int span = column.getSpan(node);
if (span > 1)
{
// iterate through the columns and if any of them has a
// component,
// render the component to null response (otherwise the
// component will
// complain that it hasn't been rendered
for (int j = 1; (j < span) && (i < components.size()); ++j)
{
++i;
if (components.get(i) != null)
{
Response old = RequestCycle.get().setResponse(NullResponse.getInstance());
(components.get(i)).render();
RequestCycle.get().setResponse(old);
}
}
}