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

时间:2018-07-30 08:19:11

标签: wicket

我在wicketpage上工作,我想在其中显示包含两列的动态表。 第一列应具有DownloadLink。第二列包含一个简单标签。 问题是检票口的第一栏显示为空,所以我看不到下载链接。 在这种情况下,如何为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>

1 个答案:

答案 0 :(得分:3)

您可以按照以下方式设置链接名称:

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

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

相关问题