File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Multiboxes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiboxes" Watch "Multiboxes" New topic


Mohammed Niaz M.

Joined: Apr 28, 2007
Posts: 27
Hi All,
Its a struts project.
Im using html:multibox tag and it use to select the multi boxes and delete the selected boxes.

In this im having fields like name,dob,age,height,country..

Im not cleared about how to use the multiboxes, below is the code.

In listA.jsp page
<input name="submit3" type="button" value="Delete"
calling "deleteUsers()" /></td>

<logic resent name="OBList">
<% int count = 0; %>
<logic:iterate id="OB" name="OBList" type="com.integrosys.cms.ui.test.bus.OBA" scope="page">
<tr class="<%=count++%2==0?"even":"odd"%>">
<td class="index"><%=count%></td>
<td><%=OB.getName() %></td>
<td><%=OB.getDob() %></td>
<td><%=OB.getAge() %></td>
<td><%=OB.getGender() %></td>
<td><%=OB.getHeight() %></td>
<td><%=OB.getWeight() %></td>

<td><%=AHelper.getCountryName(OB.getCountry()) %></td>
<td style="text-align:center"><select name="select3" onChange="JumpOnSelectactive(this, '<%=OB.getName() %>')">
<option selected="selected" >Please Select</option>
<option value="edit">Edit</option>
<option value="view">View</option>
<!--option value="delete">Delete</option-->
<td><html:multibox property="name" value="<%=OB.getName()%" /></td>
</logic resent>

document.forms[0].action="";(how to pass the multi name )

Thanks in Advanced
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'm afraid there's a bit of a flaw in your design. The user could check more than one box to delete, but it looks like your Action is only equipped to delete one record at a time. Since it is not possible to submit the same page more than once, you're going to need an action that can delete more than one record at a time.

Once you've created such an action, you can do something like this:

[ July 04, 2007: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
Mohammed Niaz M.

Joined: Apr 28, 2007
Posts: 27
Hi Merrill,
Thanks for your reply and its working but i have to work in Action to perform the deleting more names.
I let you know the process.
Mohammed Niaz M.

Joined: Apr 28, 2007
Posts: 27
Hi Merrill,
still im not able to delete more than one name
var boxes = document.getElementsByName('name');
var uri = '';
var atLeastOneBoxChecked = false;
for (var i=0;i<boxes.length;i++) {
if (boxes[i].checked) {
atLeastOneBoxChecked = true;
uri = uri + "&name=" + boxes[i].value;
deleteNameList[i] = boxes[i].value; //Added
if (atLeastOneBoxChecked) {
<html:multibox property="name" value="<% OB.getName() %>" />
----------------------Whether i pass the value array instead of OB.getName() to bean

In Formbean
i decalred

String[] deleteNameList;

public String[] getDeleteNameList(){
return deleteNameList;

public void setDeleteNameList(String[] deleteNameList){

this.deleteNameList = deleteNameList;

public String getName() {
return name;

public void setName(String name) { = name;

In the URL:

The deleteNameList array is passing to bean but i cannt assign the multi-value to name field or deleteNameList


Thanks In Advanced.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The code you've added won't work. It will not create a well-formed URI. Besides, it isn't necessary. Just use the code I gave you as-is and add the following line to your Action:

Because the URI passes the parameter "name" multiple times in the query string, the getParameterValues() method returns a string array with one element for each value. In the example you gave, deletedEvents would contain {"fds", "hyg"}. You can then iterate through this array and process the delete for each item.

As an alternative to calling the getParameterValues method, you could simply define the name property as a string array in your ActionForm bean.
Mohammed Niaz M.

Joined: Apr 28, 2007
Posts: 27
Hi Merrill,
Im using struts based framework but some additional classes are added they are Mapper,Commands,Declared input parameters and output results � controlled scope.
Im using AAction n AForm.

The Action File


AMapper Class

DeleteACommand Class

AHelper Class

AProxy Class


AForm Class


Still im able to delete only one Name.

Can you help out..

Thanks in Advanced
-- Added UBB [ c o d e ] [ / c o d e ] tags to make code easier to read
[ July 06, 2007: Message edited by: Merrill Higginson ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864

Let me explain what I posted earlier. I said that your code will not produce a well-formed URL, and that is still the case. A well-formed url has the format: etc. Your code does not put the required ampersand between parameters, nor the equal sign between parameter name and value. I've shown you what needs to go into the URL and now its up to you to write code that will produce a well-formed URL.

I'm afraid I'm not going to be able to help you integrate this change into this rather cumbersome framework you're working with. I don't understand how it works, and even with the large amount of code you've already posted, you'd still have to post a lot more of it before I'd even begin to understand it.

Aside from that, writing your code for you is not what I'm here for. I'm simply pointing out to you certain principles and truths about Struts and JavaScript, and then it's up to you to apply them. My advice would be to talk to your supervisor or someone at your company who either wrote or is familiar with this framework and get them to help you make it work for deleting multiple rows.

Having said that, below is a simple Action class that would accomplish the task without your framework. It may help you in figuring out how to make it work within your framework.

[ July 06, 2007: Message edited by: Merrill Higginson ]
Rauhl Roy
Ranch Hand

Joined: Aug 01, 2006
Posts: 401

very nice one and good example for new developers
I agree. Here's the link:
subject: Multiboxes
jQuery in Action, 3rd edition