【问题标题】:How to repeat downloadLink inside repeatingView Wicket?如何在 repeatingView Wicket 中重复 downloadLink?
【发布时间】:2018-07-30 16:29:06
【问题描述】:

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

【问题讨论】:

    标签: wicket


    【解决方案1】:

    您可以像下面这样设置链接名称:

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

    这会将链接设置为&lt;a href="yourHref"&gt;Download&lt;/a&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多