private final static String tableSuffix = "</table>";
@Override
public Widget render(RenderMetaData metaData, String groupName, Map<String, FormItem> groupItems)
{
SafeHtmlBuilder builder = new SafeHtmlBuilder();
builder.appendHtmlConstant(tablePrefix);
// build html structure
ArrayList<String> itemKeys = new ArrayList<String>(groupItems.keySet());
ArrayList<FormItem> values = new ArrayList<FormItem>(groupItems.values());
// Remove the hidden items from both lists. Iterate from the back so that removal doesn't
// require adjustment of the numbering.
for (int i=values.size() - 1; i >= 0; i--) {
if (!values.get(i).render()) {
values.remove(i);
itemKeys.remove(i);
}
}
//int colWidth = 100/(metaData.getNumColumns()*2);
builder.appendHtmlConstant("<colgroup class='cols_"+metaData.getNumColumns()+"'>");
for(int col=0; col<metaData.getNumColumns(); col++)
{
// it's two TD's per item (title & value)
builder.appendHtmlConstant("<col class='form-item-title-col'/>");
builder.appendHtmlConstant("<col class='form-item-col'/>");
}
builder.appendHtmlConstant("</colgroup>");
int i=0;
while(i<itemKeys.size())
{
builder.appendHtmlConstant("<tr>");
int col=0;
for(col=0; col<metaData.getNumColumns(); col++)
{
int next = i + col;
if(next<itemKeys.size())
{
FormItem item = values.get(next);
createItemCell(metaData, builder, itemKeys.get(next), item);
}
else
{
break;
}
}
builder.appendHtmlConstant("</tr>");
i+=col;
}
builder.appendHtmlConstant(tableSuffix);
HTMLPanel panel = new HTMLPanel(builder.toSafeHtml());
// inline widget
for(String key : itemKeys)
{
FormItem item = groupItems.get(key);