I'm using a struts radio tag that is being populated with a list of objects that have two fields:
class MyAction {
List<MyObject> myList;
String selectedId
public String execute() {
...
myList = new ArrayList<MyObject>();
myList.add(new MyObject("1","first object");
myList.add(new MyObject("2","second object");
myList.add(new MyObject("3","second object");
...
}
// Getters and Setters for myList & selectedId
...
}
class MyObject {
String id;
String name;
MyObject(String id, String name) {
this.id = id;
this.name = name;
}
// Getters and Setters for id & name
...
}
Here's what I was using on my page to display the list of radio buttons
<s:radio key="selectedId" list="myList" listKey="id" listValue="name"/>
However, this yields a horizontal list of radio buttons. I tried adding a css style to them:
<style>
.vertical input { display: block; }
</style>
But this causes the labels and the radio buttons to show up on separate lines as well, instead of the radio button and label on the same line:
first object
second object
third object
what I want is:
first object
second object
third object
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…