This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Struts and the fly likes How to get results from indexed fields???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to get results from indexed fields????" Watch "How to get results from indexed fields????" New topic

How to get results from indexed fields????

danelle luft

Joined: May 24, 2004
Posts: 1
I have a form that uses a collection of objects (a data transfer object) to display a list of data. One of which is a checkbox. I want to get all the rows back on the submit and loop through them to get the ones that they checked to process them. PROBLEM is I can't get anything on the submit.
Here is the form.

<form-bean name="boRequestListForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="results" type="java.util.Collection"/>
<form-property name="requestType" type="java.lang.String"/>
<form-property name="sortBy" type="java.lang.String"/>
<form-property name="submitParam" type="java.lang.String"/>
<form-property name="requestInd" type="java.lang.String"/>
<form-property name="displayHeading" type="java.lang.String" />
<form-property name="methodToCall" type="java.lang.String" />
<form-property name="approveCBX" type="java.lang.String"/>

Here is a snippet from the jsp:
<logic:iterate id="list" name="boRequestListForm" property="results" type="">
<tr >
<td><bean:write name="list" property="ticketNo"/></td>
<td><bean:write name="list" property="moduleDesc"/> </td>
<td><bean:write name="list" property="plantDesc"/> </td>
<td><html:checkbox indexed="true" name="list" property="approveCBX"/></td>
<td><bean:write name="list" property="roleName"/> </td>
<html:hidden indexed="true" name="list" property="requestInd"/>

On submit, the action doesn't get ANYTHING back. Everything is null. HELP PLEASE? What am I doing wrong???
Marcus Pant

Joined: May 21, 2004
Posts: 7
i guess the iterate id and the form-property name have to be the same. try the following. sounds stupid, but worked for me...

if this doesn't work, I'll have a look at some sample code at home and post it to you.
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

<form-property name="requestInd" type="java.lang.String"/>
<form-property name="approveCBX" type="java.lang.String"/>

Shouldn't those be some kind of collection?
I thought that indexed only worked with submitting collections.

A good workman is known by his tools.
Alister Pate
Ranch Hand

Joined: Sep 13, 2002
Posts: 34
Oddly, that does seem to work.

I presume it works because it references the collection in your bean - so if you have a collection of addresses, addresses[1].id works while address[1].id doesn't - because there is no address collection to be accessed.

Does that sound like a fair solution?
Alister Pate
Ranch Hand

Joined: Sep 13, 2002
Posts: 34
For "fair" please read "sensible"! Too much negotiation in my day today....
I agree. Here's the link:
subject: How to get results from indexed fields????
It's not a secret anymore!