如何在repeatingView Wicket内重复下载链接



我正在处理wicketpage,我想在其中显示一个包含两列的动态表。第一列应该有一个DownloadLink。第二列包含一个简单的标签。问题是wicket显示了一个空的第一列,所以我看不到下载链接。在这种情况下,我如何向downloadLink添加标签?

ListDataProvider<String> listDataProvider = new ListDataProvider<String>(filesPaths);
DataView<String> dataView = new DataView<String>("rows", listDataProvider) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(Item<String> item) {
String filePath = item.getModelObject();
RepeatingView repeatingView = new RepeatingView("dataRow");
String idLink = repeatingView.newChildId();
DownloadLink link = new DownloadLink(idLink, new File(filePath));
link.add(new Label(idLink + "label", filePath));
repeatingView.add(link);
Label label = new Label(repeatingView.newChildId(), "(TEST)");
label.add(new AttributeModifier("style", "color:  blue;"));
repeatingView.add(label);
item.add(repeatingView);
}
}; 
add(dataView);

这是html页面的一部分。

<table>
<tr wicket:id="rows">
<td wicket:id="dataRow"></td>
</tr>
</table>

您可以设置链接名称,如下所示:

downloadLink.setBody(Model.of("Download"));

这将设置到<a href="yourHref">Download</a>的链接

最新更新