【发布时间】:2020-11-19 07:56:05
【问题描述】:
我是 wicket 的新手,我想向标签添加一个属性(名为 other-id)。代码如下:
private String getName(ExampleList list) {
return getBrandName() + " " + getString("ExampleList." + list.name());
}
IModel<List<ExampleList>> listModel = new AbstractReadOnlyModel<List<ExampleList>>() {
@Override
public List<ExampleList> getObject() {
return availableTechnologies.getObject().keySet().stream().collect(Collectors.toList());
}
};
ListView<ExampleList> example = new ListView<ExampleList>("list", listModel) {
@Override
protected void populateItem(ListItem<ExampleList> el) {
el.add(new Radio<ExampleList>("radio", item.getModel()));
el.add(new Label("labelName", getName(el.getModelObject())));
}
};
这是对应的html:
<li wicket:id="list" class="radio">
<input wicket:id="radio" type="radio" name="radioChoice"/>
<label wicket:for="radio"><wicket:container wicket:id="labelName" /></label>
</li>
我想将 other-id 添加到带有标签名称的标签到 other-id 中。直到现在我都试过了
el.add(new Label("labelName", getName(el.getModelObject())).add(new AttributeAppender("other-id", getName(el.getModel())));
但我的标签中没有出现任何内容。 我也在html中尝试过:
<label wicket:for="radio" other-id= wicket:id="labelName">
但在我最后一次尝试时它给了我错误。 关于如何做到这一点的任何想法?
【问题讨论】:
标签: html attributes label wicket