You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by Marc Sulivan <ar...@yahoo.com> on 2008/10/13 14:20:02 UTC
How to show a image on a table column
Dear friends I need to show an image on a table column. How can I do that?
Thanks
Marc Sulivan
Re: How to show a image on a table column
Posted by Bob Schellink <sa...@gmail.com>.
Hi Marc,
Its usually best to ask on the user list so I'll cc there as well.
Marc Sulivan wrote:
> Dear friends I need to show an image on a table column. How can I do that?
The Decorator should do what you want:
Column column = new Column("image");
column.setDecorator(new Decorator() {
public String render(Object row, Context context) {
Customer customer = (Customer) row;
String contextPath = getContext().getRequest().getContextPath();
String pathToImage = customer.getPathToImage();
// example image location -> /images/mycorp.jpg
return "<img src='" + contextPath + pathToImage + "'/>";
}
});
table.addColumn(column);
kind regards
bob
Re: How to show a image on a table column
Posted by Bob Schellink <sa...@gmail.com>.
Hi Marc,
Its usually best to ask on the user list so I'll cc there as well.
Marc Sulivan wrote:
> Dear friends I need to show an image on a table column. How can I do that?
The Decorator should do what you want:
Column column = new Column("image");
column.setDecorator(new Decorator() {
public String render(Object row, Context context) {
Customer customer = (Customer) row;
String contextPath = getContext().getRequest().getContextPath();
String pathToImage = customer.getPathToImage();
// example image location -> /images/mycorp.jpg
return "<img src='" + contextPath + pathToImage + "'/>";
}
});
table.addColumn(column);
kind regards
bob