Maybe something like this?
PropertyColumn<Asset> propertyColumn = new PropertyColumn<Asset>(
new Model<String>("AuditTrain"), "audit_train") {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Asset>> item,
String componentId, IModel<Asset> rowModel) {
if(rowModel.getObject().getAudit_train() != null)
super.populateItem(item, componentId, rowModel);
else {
item.add(new Label(componentId, "No audit train"));
item.add(new AttributeModifier("class",true, new
Model<String>("noaudit")));
}
}
};
Best,
Ernesto
On Sat, Jan 2, 2010 at 4:18 AM, Norman Elton <[email protected]> wrote:
> I've created a DataTable, which works great. I'd like to define the
> behavior if a property returns NULL. For instance, this column
> retrieves the AuditTrain object for a given Asset:
>
> columns.add(new PropertyColumn<Asset>(new Model<String>("Audit
> Train"), "audit_train");
>
> If the AuditTrain is NULL, I get a null-pointer exception. Ideally,
> I'd like to return a column-specific string and css class. Seems that
> I need to define a new IColumn.
>
> Any pointers? Has this been done before?
>
> Thanks,
>
> Norman
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>