I want to add a column containing images in each cell of a table in wicket framework. I make the table in a java class and have a createColumns() method as the following:
private List<IColumn> createColumns() {
List<IColumn> columns = new ArrayList<IColumn>();
// Create the columns that will be displayed, second param is the sort
// order
// Use column position for aggregate functions
// Otherwise the query uses column aliases so these need to match here
columns.add(new PropertyColumn(new Model("Status"), "code") {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item item, String componentId, IModel model) {
Object[] values = ((ArrayWrapper) model.getObject()).getArray();
setStatus((Integer) values[0]);
item.add(new Image(componentId, new ResourceReference(this.getClass(), getStatus())));
}
});
columns.add(new PropertyColumn(new Model("First"), "2", "array[1]"));
columns.add(new PropertyColumn(new Model("Last"), "3", "array[2]"));
columns.add(new PropertyColumn(new Model("Sender"), "sender",
"array[4]"));
columns.add(new PropertyColumn(new Model("Receiver"), "receiver",
"array[5]"));
columns.add(new HeaderlessColumn() {
private static final long serialVersionUID = 1L;
public void populateItem(Item cellItem, String componentId,
IModel rowModel) {
cellItem.add(new ActionPanel(componentId, rowModel));
};
});
return columns;
}
The html file is simply as the following:
<html xmlns:wicket="http://wicket.sourceforge.net/">
<body>
<wicket:extend>
<table align="center" wicket:id="results"></table>
</wicket:extend>
</body>
</html>
But I get an exception which is:
org.apache.wicket.markup.MarkupException: Component cell must be applied to a tag of type 'img', not '' (line 0, column 0)
And it's related to the lines that I make the column for image. Can anyone help me how I can make it?