Hi folks,

I have a problem which I have a kludgy solution for, and have to believe
there is a more elegant way of doing it...  Here's the scenario.

The page displays a non-editable list of records in a database, with a
checkbox at the beginning of each row.  The list is indeterminate length,
based on selection criteria entered by the user in the previous page.  The
user selects n number of rows, using the check boxes.  Those rows are to be
deleted from the database.

The trick is that the rows have a three column key.  One is constant based
on the user, so I need to get 2 pieces of information from each row before
I can delete it.

My kludge is to have the value of the checkboxes be the indexId of the
logic:iterate.  Each row has two hidden input fields, with the two required
key values.  Something like this:

  <logic:iterate id="item" name="listForm" property="txnList" type
="Transaction" indexId="counter">
    <tr>
      <td width="69" align="center">
        <input type="checkbox" name="selectedTxns" value="<%=counter%>"/>
      </td>
      ....  display data ...
      <td width="88"><%=item.getTotal()%></td>
      <!-- Hidden input fields so we can retrieve all the required data
about the selected transaction... -->
      <td class="sidelink" width="1">
        <input type="hidden" name="orderIds" value="<%=item.getOrderID
()%>"/>
      </td>
      <td class="sidelink" width="1">
        <input type="hidden" name="deptAreas" value="<%=item.getDeptArea
()%>"/>
      </td>
    </tr>
  </logic:iterate>

In the formData bean, I have three String [ ] attributes to accept the
values of the checkbox and the two hidden fields.

The problem is that since there is data in the hidden input fields for
every row, I get every value back in the array, instead of only the data
for the rows which are checked.  What I have to do in the action is read
the values from the String [ ] for the checkbox , and use that value as the
index into the other two string arrays.

Like I said, its kludgy, but it works...

But, I have to believe there's a way to send back an array of beans, with
only the values of the fields for those rows which are checked, but I can't
find anything in books or searching the web which describes how to do this.

Does anyone have a cleaner way to do this type of thing?

Thanx!

c'ya
Mike
----
Mike Boucher                  [EMAIL PROTECTED]
Edgil Associates              www.edgil.com

"Don't take life too seriously, you'll never get out of it alive!"


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to