I haven't tried it but this might work

public class BooleanImageColumn extends PropertyColumn<Boolean> {

    private static final long serialVersionUID = 1L;


    private static final ResourceReference TRUE_IMG = new
ResourceReference(BooleanImageColumn.class, "true.gif");
    private static final ResourceReference FALSE_IMG = new
ResourceReference(BooleanImageColumn.class, "false.gif");

    public BooleanImageColumn(IModel<String> displayModel, String
propertyExpression) {
        super(displayModel, propertyExpression);
    }

    public BooleanImageColumn(IModel<String> displayModel, String
sortProperty, String propertyExpression) {
        super(displayModel, sortProperty, propertyExpression);
    }


    @Override
    public void populateItem(Item<ICellPopulator<Boolean>> item, String
componentId, IModel<Boolean> rowModel) {
        if(rowModel.getObject() == null ||
rowModel.getObject().equals(Boolean.FALSE))
            item.add(new NonCachingImage(componentId, FALSE_IMG));
        else
            item.add(new NonCachingImage(componentId, TRUE_IMG));
    }
}

Just place a "true.gif" and a "false.gif" on the same package as
BooleanImageColumn.

Ernesto

On Mon, Jan 4, 2010 at 1:31 PM, chinedu efoagui <chinedub...@gmail.com>wrote:

> hello
> I have a an object which contains a boolean field (true ,false) it renders
> well.
> I want to do is instead on of it showing true or false on the cell. I
> want it to show an image if it is true and another image if the
> attribute is false?
> Please how can i achieve this?
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to