Java – wicket – radio buttons and label elements
•
Java
In my wicket application, I have a page with radio buttons and < label for = "..." > Content:
<input type="radio" wicket:id="today" id="today" /> <label for="today">Today</label>
However, when the ID attribute of the radio button changes automatically, the for attribute of the label label remains unchanged, and inconsistency will occur (the label is no longer linked to the button) What is the best way to solve this problem? Now, let me say this:
add( new Label("todayLabel","Today") .add(new AttributeModifier( "for",new Model<String>(today.getMarkupId() )));
But that's not very good Is there another clearer way to link these to labels?
Solution
Use formcomponentlabel:
add(new FormComponentLabel("todayLabel",today));
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码