呵呵,有点看不懂你的意思,什么是“collection所在的bean”????
不过可以贴一下jsp中使用的代码,并简单说明一下。
<html:select property="station">
<html:optionsCollection name="stationList" value="value" label="label" />
</html:select>
说明一下,至于<html:select/>中的property就不多解释了,对应的是ActionForm Bean中的某个station属性。
在<html:optionsCollection/>中的name属性对应的是一个Collection类集对象,该对象中的元素是bean,该bean有两个属性,分别是label和value。希望这些说明能对楼主有帮助。
不过可以贴一下jsp中使用的代码,并简单说明一下。
<html:select property="station">
<html:optionsCollection name="stationList" value="value" label="label" />
</html:select>
说明一下,至于<html:select/>中的property就不多解释了,对应的是ActionForm Bean中的某个station属性。
在<html:optionsCollection/>中的name属性对应的是一个Collection类集对象,该对象中的元素是bean,该bean有两个属性,分别是label和value。希望这些说明能对楼主有帮助。
<html:optionsCollection name"cat" property="options"/>
</html:select>
同时使用NAME和PROPERTY,属性指定对象的名称和字段,将调用该对象的值获取方法以返回一个用来生成选项的集合
这样不知道行不行,collection类对象我一般是通过在Action中用request.setAttribute("typeList",list)的方式来传递给页面,然后在页面中使用 <logic:iterate/>来迭代.
或者最简单的方法就是继承TagSupport类,自己写个和struts中的html或者logic等tag一样的tag,然后在页面中调用,这个方法个人感觉更好.
我也来补充一下,这里name代表一个存储在某个作用域中的bean,即page,request,session,或者application存放的的变量名
如是在进这页面前有一个request.setAttribe("stationList",list);
list的可以是任何收集类!
list可以是对象
如user对象,有一个userId,userName,有相应的getter方法
则可以这样写
<html:optionsCollection name="stationList" value="userId" label="userName" />
这里,就把userId作为值,userName作为显示text在select里了
<html:textarea name="PRITeamForm" property="teamData.teamDesc" cols="50" rows="6"/>
<html:hidden name="PRITeamForm" property="teamData.orgID" /><logic:notEmpty name="PRITeamForm" property="teamList">collections 1 info is object
<logic:iterate indexId="index" id="info" name="PRITeamForm" property="teamList">
<logic:iterate indexId="index" id="info" name="PersonAuthForm" property="userAuthList" type="com.queryPersonAuth.bo.UserAuthData"><bean:write name="info" property="userInfo.userName" />-->info.userInfo.userName<bean:write name="index" />num
select collection 1 optionsCollection
使用LabelValueBean作下拉框
<html:select name="PersonAuthForm" property="orgId" onchange="changeOrg()">
<html:option value="-1">-不选择-</html:option>
<html:optionsCollection name="PersonAuthForm" property="orgList"/>
//display select and the object is labelobject key--value -->LabelValueBean
</html:select>
使用自定义bean 作下拉框
<bean:define id ="sec" name="workloadForm" property="secList" scope="request"/>
<html:select name="workloadForm" property="queryConditionData.sectionId" >
<html:options collection ="sec" property="id" labelProperty="label"/> ----id属性值为 value label属性值为 label
</html:select> <bean:define id="teamList" name="TeamForm" property="teamList" type="java.util.Vector" />
if(teamList!=null&&teamList.size()>0)
<a name="position"></a>
<script>
location.href="#position";
</script>定义对象
<bean:define id="WorkConsignData" name="WorkConsignForm" property="workConsignData" type="com.workconsign.bo.WorkConsignData"/>定义变量
<bean:define id="cssstyle"><%= index.intValue() % 2 %></bean:define>使用
<logic:equal name="cssstyle" value="0"> class="even"</logic:equal><logic:notEmpty name="PRIGroupUserForm" property="userList"> <logic:present name="insertRole">
<font color=red> 不允许添加同样的角色</font>
</logic:present>