This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Checkbox List

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am really struggling to do the following:

I have an array list i.e.

List codes = new ArrayList();
code.add("Code 1");
code.add("Code 2");
code.add("Code 3");
code.add("Code 4");
code.add("Code 5");

This list is then kept in application scope and i retrieve it in a jsp(test.jsp) and store it in a bean i.e.

<bean efine name="codesBean" etc../>

My question is how do i declare a checkbox for each value in the list stored in the "codesBean" bean and then retrive the selected checkboxes in the forms
TestForm.java selectedCodes array variable.

For instance when the form is submitted and the appropriate ActionForm is called, how can i declare all the checkboxes to one variable of type array or collection, list, etc.
So that the variable in the ActionForm is populated with the values from the selected checkboxes.

Thankyou for any help as i really cant figure this one out.

Cheers,

Patrick
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would use the <html:multibox> tag for this. You would loop through the list and create an html:multibox tag for each item item in the list. Example:

Note: The above example assumes that your web application is Servlet Version 2.4 or above. If not, you will have to use the html-el tags instead of the html tags in order to use an EL expression in a tag attribute.
[ March 21, 2007: Message edited by: Merrill Higginson ]
 
Patrick McDonogh
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merrill

I see you have replied to all my posts.
You truly are a guru.
Have a great week
 
reply
    Bookmark Topic Watch Topic
  • New Topic