网站首页 新闻首页 网页设计图形动画软件编程网站开发办公软件操作系统数据库网络技术认证考试范文资料黑客攻防 书籍教程 进入论坛

Struts 中 Multibox 的用法

http://www.diybl.com/ 2007-2-6  网络 点击:  [ 评论 ]
文章搜索:    【点击打包该文章】


在 ActionForm 中定义一个数组 String[] selectedOptions 用于存放复选框被选中的值,

数组 LabelValueBean[] possibleOptions 用于显示所有的复选框的值。

import org.apache.struts.util.LabelValueBean; . . . public class MyActionForm extends ActionForm {   private LabelValueBean[] possibleOptions;   private String[] selectedOptions;    public MyActionForm()   {      // Initialise the LabelValueBeans in the possibleOptions array.     LabelValueBean[] lvBeans = new LabelValueBean[4];      lvBeans[0] = new LabelValueBean("Alpha", "A");     lvBeans[1] = new LabelValueBean("Beta", "B");     lvBeans[2] = new LabelValueBean("Charlie", "C");     lvBeans[3] = new LabelValueBean("Delta", "D");      this.possibleOptions = lvBeans;   }    public LabelValueBean[] getPossibleOptions()   {     return possibleOptions;   }    public String[] getSelectedOptions()   {     return selectedOptions;   }    public void setSelectedOptions(String[] selectedOptions)   {     this.selectedOptions = selectedOptions;   } }

在 JSP 中使用以下代码:



<logic:iterate name="myActionForm" id="item" property="possibleOptions">   <html:multibox property="selectedOptions">     <bean:write name="item" property="value" />   </html:multibox>     <bean:write name="item" property="label" /><br /> </logic:iterate>

欢迎光临DIY部落,点击这里查看更多文章教程   【点击打包该文章】
如果图片或页面不能正常显示请点击这里 站内搜索:   
上一篇文章:SCWCD1.4的资料
下一篇文章:在csdn上看到的怪问题

文章评论

请您留言

 

最新新闻