【发布时间】:2016-06-09 14:19:09
【问题描述】:
所以我尝试使用带有以下代码的 IndexedContainer 将图像添加到我的网格中:
//picture
String imgURL = (String)ds.child(PHOTO).getValue();//gets the image URL from the DB
System.out.println(imgURL);
ExternalResource picture = new ExternalResource(imgURL);
System.out.println(picture.getURL());
Image image = new Image(PICTURE, picture);
image.setHeight("5px");
item.getItemProperty(PICTURE).setValue(image);
我没有得到图片,而是得到了 Image 对象的 toString()。 println 都打印正确的 URL。另请注意,这适用于表格,但不适用于网格。知道为什么吗?
【问题讨论】:
-
哪个 println 打印了正确的 URL? PICTURE 有什么价值?
-
两者都有。这是网格单元格中显示的内容:com.vaadin.ui.Image@1e37c05d
-
答案有帮助吗?请提供反馈。