J2EE學(xué)習(xí)筆記
          我們的失落……
          posts - 13,comments - 1,trackbacks - 0
          ActionForm 中定義一個(gè)數(shù)組 String[] selectedOptions 用于存放復(fù)選框被選中的值,
          數(shù)組 LabelValueBean[] possibleOptions 用于顯示所有的復(fù)選框的值。


          import org.apache.struts.action.ActionForm;
          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>
          posted on 2008-03-11 22:50 J2EE學(xué)習(xí)筆記 閱讀(290) 評(píng)論(0)  編輯  收藏 所屬分類: struts 、轉(zhuǎn)載

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 炎陵县| 文安县| 正宁县| 永新县| 崇左市| 象州县| 麟游县| 调兵山市| 东方市| 孟连| 民丰县| 博乐市| 梁平县| 巴东县| 临武县| 长垣县| 宜春市| 肃宁县| 闽清县| 霍山县| 和林格尔县| 永登县| 黄梅县| 太谷县| 赤峰市| 手游| 马龙县| 南召县| 和顺县| 苏州市| 清涧县| 栖霞市| 岗巴县| 河北省| 襄垣县| 同江市| 林口县| 德保县| 潼南县| 广汉市| 盘山县|