Html Wicket在标签上添加其他id
我是wicket的新手,我想向标签添加一个属性(名为other id)。代码如下:Html Wicket在标签上添加其他id,html,attributes,label,wicket,Html,Attributes,Label,Wicket,我是wicket的新手,我想向标签添加一个属性(名为other id)。代码如下: private String getName(ExampleList list) { return getBrandName() + " " + getString("ExampleList." + list.name()); } IModel<List<ExampleList>> listModel = new AbstractRea
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())));
}
};
Radio<ExampleList> radio = new Radio<>("radio", item.getModel())
radio.setLabel(Model.of(getName(el.getModelObject())));
el.add(radio);
但我的标签上什么也没有。
我还尝试了html:
<label wicket:for="radio" other-id= wicket:id="labelName">
但在我最后一次尝试时,它给了我错误。
你知道怎么做吗?要在表单组件上设置标签,需要使用
setLabel
方法。在populateItem
方法中,可以执行以下操作:
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())));
}
};
Radio<ExampleList> radio = new Radio<>("radio", item.getModel())
radio.setLabel(Model.of(getName(el.getModelObject())));
el.add(radio);
问题是您将AttributeAppender添加到了
wicket:container
。此元素仅渲染其主体,即标签的文本,但不会渲染标记本身,因此也不会渲染其属性
您可以将标记更改为:
<label wicket:for="radio" wicket:id="labelName"></label>
这样,AttributeAppender将向
元素添加新属性。不幸的是,我无法更改html。我试过了,但它给了我另一个错误,所以我应该保持wicket的格式:containerInternet失败消息出现,而不是带有特定列表的页面。请创建一个演示该问题的小型应用程序,并在GitHub/GitLab/BitBucket/上共享它。。。我们来看看!
<label wicket:for="radio" wicket:id="labelName"></label>