如何在 repeatingView Wicket 中重复下载链接?

How to repeat downloadLink inside repeatingView Wicket?

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

    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"));

这会将 link 设置为 <a href="yourHref">Download</a>