The use of Multibox in Struts

Source: Internet
Author: User
Tags array return

Define an array string[] selectedoptions in Actionform to hold the value of the check box being selected.

Array labelvaluebean[] Possibleoptions is used to display the values of all check boxes.

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;   } }

Use the following code in the JSP:

<logic:iterate name= "Myactionform" id= "item" property= "Possibleoptions" >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.