Saturday, March 28, 2009

Multiple Value Selection using Checkbox in Struts

How to design a page in struts using CheckBox for choosing 2 or more values?

Perform the following steps:

1. Action Form: Design a form with Array of Objects of String type.
String[] selectedValues = { };

2. JSP: Populate the values that it can hold using logic:iterate tag.
<html:checkBox .... property="selectedValues" value="<%=obj[i].getValue()%>" ..... >

3. After Form submission: the selected values will be placed in selectedValues property

4. Now, in Action, iterate the collection, to identify the selected DTO object.
This needs to be designed as per the requirements.
For example, based on 'selectedValues', pick up the selected objects from the one collection into another,
so that the business routine can use the resultant collection.

Have Fun...

2 comments:

Ashu said...

Hi Swathika,

This is Venkat, Your blog is nice and informative, I am having similar blog for Java J2EE Technologies. Please Visit and share your opinion.

www.java-j2ee-technologies.blogspot.com

Thanks
Venkat

Info Pedia said...

free download music and video click this link !!
lagupedia
stafaband
download lagu
download video