Struts中 html:radio,html:multibox,html:select 使用实例

  1. Struts中 <html:radio> <html:multibox> <html:select> 使用
  2. jsp:
  3.     <html:form action="/checkBox">
  4.         <logic:iterate id="item" name="checkBoxForm" property="possibleOptions">
  5.    <html:multibox property="selectedOptions">
  6.      <bean:write name="item" property="ID"/>
  7.    </html:multibox>
  8.      <bean:write name="item" property="countryID"/>
  9.  </logic:iterate>
  10.  <br>
  11.  <logic:iterate id="item2" name="checkBoxForm" property="possibleOptions">
  12.  <html:radio property="radioSelected" value="${item2.ID}"></html:radio>
  13.  <bean:write name="item2" property="countryID"/>
  14.  </logic:iterate>
  15.  <html:select property="dropDownSelected">
  16.      <html:optionsCollection property="possibleOptions" label="countryID" value="ID"/>
  17.  </html:select>
  18.             <html:submit/><html:cancel/>
  19.         </html:form>
  20. CheckBoxForm:
  21. public class CheckBoxForm extends ActionForm {
  22.     private ArrayList<Country> possibleOptions;
  23.     private String[] selectedOptions;
  24.     private String radioSelected;
  25.     private String dropDownSelected;
  26.        public String getRadioSelected() {
  27.         return radioSelected;
  28.     }
  29.     public void setRadioSelected(String radioSelected) {
  30.         this.radioSelected = radioSelected;
  31.     }
  32.     public  CheckBoxForm()
  33.        {
  34.            possibleOptions=Dbutil.getBindTable();
  35.          // Initialise the LabelValueBeans in the possibleOptions array.
  36. //       LabelValueBean[] lvBeans = new LabelValueBean[4];
  37. //   
  38. //       lvBeans[0] = new LabelValueBean("Alpha", "A");
  39. //       lvBeans[1] = new LabelValueBean("Beta", "B");
  40. //       lvBeans[2] = new LabelValueBean("Charlie", "C");
  41. //       lvBeans[3] = new LabelValueBean("Delta", "D");
  42.      
  43. //       this.possibleOptions = lvBeans;
  44.                
  45.            
  46.         }
  47.     public ArrayList<Country> getPossibleOptions() {
  48.         return possibleOptions;
  49.     }
  50.     public void setPossibleOptions(ArrayList<Country> possibleOptions) {
  51.         this.possibleOptions = possibleOptions;
  52.     }
  53.     public String[] getSelectedOptions()
  54.     {
  55.        return selectedOptions;
  56.     }
  57.     public void setSelectedOptions(String[] selectedOptions)
  58.     {
  59.       this.selectedOptions = selectedOptions;
  60.     }
  61.     public String getDropDownSelected() {
  62.         return dropDownSelected;
  63.     }
  64.     public void setDropDownSelected(String dropDownSelected) {
  65.         this.dropDownSelected = dropDownSelected;
  66.     }
  67. }
  68. Struts_config:
  69. <form-beans >
  70.     <form-bean name="checkBoxForm" type="wang.CheckBoxForm" />
  71.   </form-beans>
  72.  <action
  73.       attribute="loginForm"
  74.       input="/login.jsp"
  75.       name="loginForm"
  76.       path="/login"
  77.       scope="request"
  78.       type="wang.LoginAction">
  79.       <forward name="seccess" path="/seccess.jsp" />
  80.       <forward name="fail" path="/fail.jsp" />
  81.       <forward name="aaa" path="/checkBox.jsp" />
  82.     </action>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值