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


          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學習筆記 閱讀(293) 評論(0)  編輯  收藏 所屬分類: struts轉載

          只有注冊用戶登錄后才能發表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 朝阳市| 嵊州市| 万荣县| 驻马店市| 增城市| 福清市| 无为县| 竹北市| 平度市| 广河县| 巴彦县| 仲巴县| 岫岩| 左云县| 兴仁县| 读书| 龙江县| 金华市| 农安县| 长海县| 博罗县| 潍坊市| 峡江县| 黄山市| 南城县| 牡丹江市| 开鲁县| 彰化市| 巴东县| 五台县| 冕宁县| 山东省| 石泉县| 胶州市| 天全县| 额尔古纳市| 辽宁省| 九江市| 河源市| 柞水县| 哈巴河县|