浏览 3431 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-02-24
在项目实际开发中,终于了解了html:select标签和html:options 的使用方法。 代码片断如下: <html:select property="answerableDepId" onchange="getAccountList();"> <html:options collection="depList" property="id"labelProperty="name" /> </html:select> <html:select property="answerablePersonId"> <html:options collection="personList" property="id" labelProperty="realname" /> </html:select> 以上是两个下拉列表框级联(分别是负责部门和部门负责人),其中第一个下拉列表框的onChange事件触发Ajax事件。 1)<html:select>标签中的property一般是在form bean中定义的属性,用于将用户最终选择的值传递给后台的Action做相应处理。 2)<html:select> 与<html:options> 这两个标签联合使用,其中<html:options>标签中的collection属性,如上面代码中的personList是在jsp范围中的一个集合对象(注意:不是formbean中的属性),该集合中的每个元素必须是一个实体,并且该实体必须具有getId()和getRealname()方法,其中id 和realname 属性正是<html:options>标签中的property和labelProperty指定的属性. 3)<html:options>标签中的property用作选项的值(用作后台处理),而labelProperty(用作给用户显示选项的内容). 4)每次触发onChange事件都会通过选择负责部门而默认绑定该部门人员下拉列表中的第一个,即该部门负责人列表中的第一个人. 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |