如何使Struts无线标签创建一个垂直的单选按钮列表 [英] How to make Struts radio tag create a vertical list of radio buttons
本文介绍了如何使Struts无线标签创建一个垂直的单选按钮列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用一个struts无线电标签,它正在填充一个对象列表,其中有两个字段:
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"/>
但是,这会产生一个单选按钮的水平列表,我试着给他们添加一个css样式:
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:
第一个对象
li>
第二个对象
第三个对象
first object second object third object
/ p>
what I want is:
第一个对象
第二个对象
/ li>
first object second object third object
推荐答案
其实很简单,我的意思是使用主题 simple
:)
its actually simple, i mean use theme simple
:)
<s:iterator value="myList">
<s:radio theme="simple" name="someNameToSubmit" list="#{id:name}"/><br>
</s:iterator>
这将使 name
id
作为提交
这篇关于如何使Struts无线标签创建一个垂直的单选按钮列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文