You are right.... Just create a panel and place the image there.... Try this
import org.apache.wicket.ResourceReference; import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.model.IModel; 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 ImagePanel(componentId, FALSE_IMG)); else item.add(new ImagePanel(componentId, TRUE_IMG)); } } where import org.apache.wicket.ResourceReference; import org.apache.wicket.markup.html.image.NonCachingImage; import org.apache.wicket.markup.html.panel.Panel; public class ImagePanel extends Panel { private static final long serialVersionUID = 1L; /** * @param id */ public ImagePanel(String id, ResourceReference image) { super(id); add(new NonCachingImage("image", image)); } } and ImagePanel.html <html> <body> <wicket:panel> <img wicket:id="image"/> </wicket:panel> </body> </html> Ernesto On Mon, Jan 4, 2010 at 2:49 PM, chinedu efoagui <chinedub...@gmail.com>wrote: > I applied you class with a few modifications it gave me this error. > I think it is expecting an img tag somewhere > > [code] > WicketMessage: Component cell must be applied to a tag of type 'img', > not '<span wicket:id="cell">' (line 0, column 0) > [markup = > file:/C:/Users/bond/.netbeans/6.8/apache-tomcat-6.0.20_base/work/Catalina/localhost/hr/loader/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.html > <!-- > > <wicket:panel> > <thead wicket:id="topToolbars"> > <wicket:container wicket:id="toolbar"></wicket:container> > </thead> > <thead wicket:id="bottomToolbars"> > <wicket:container wicket:id="toolbar"></wicket:container> > </thead> > <tbody> > <tr wicket:id="rows"> > <td wicket:id="cells"> > <span wicket:id="cell">[cell]</span> > </td> > </tr> > </tbody> > </wicket:panel> > > , index = 21, current = '<span wicket:id="cell">' (line 27, column 4)] > at > org.apache.wicket.markup.MarkupStream.throwMarkupException(MarkupStream.java:465) > at org.apache.wicket.Component.checkComponentTag(Component.java:3475) > at > org.apache.wicket.markup.html.image.Image.onComponentTag(Image.java:228) > at > org.apache.wicket.markup.html.image.NonCachingImage.onComponentTag(NonCachingImage.java:124) > at org.apache.wicket.Component.renderComponent(Component.java:2597) > at > org.apache.wicket.markup.html.WebComponent.onRender(WebComponent.java:62) > at org.apache.wicket.Component.render(Component.java:2457) > at > org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1414) > at > org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1577) > at > org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1501) > at org.a > [code] > > On Mon, Jan 4, 2010 at 2:04 PM, chinedu efoagui <chinedub...@gmail.com> > wrote: > > thank i will try it and give u feed back > > > > On Mon, Jan 4, 2010 at 2:02 PM, Ernesto Reinaldo Barreiro > > <reier...@gmail.com> wrote: > >> 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 > >>> > >>> > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >