iterating radio buttons

hi experts, i have a search button and it will display a list of results on the same page. Now I want to display a radio button on each list of record in the jsp using struts tag. how can i achieve this? That way I can check any of the displayed result for further manipulation.
thanks
KirtipurItagolAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrigankCommented:
Need to Extend the struts tabletag.
0
KirtipurItagolAuthor Commented:
any other options?? Here's my tag:
<tr class="tableHeader">
<logic:present name="searchForm" property="results">
      <logic:iterate id="result" name="searchForm" property="results">
 <td height="20" class="tableHeader"><radio button appears below this header></td>
 <td class="tableHeader"><bean:write name="result" property="legalEntityName"/>Legal Entity Name</td>
 <td class="tableHeader"><bean:write name="result" property="existingAccountNumber"/>Account Number</td>
 <td class="tableHeader"><bean:write name="result" property="legalCountry"/>Country</td>
 <td class="tableHeader"><bean:write name="result" property="existingCurrency"/>Currency</td>
 <td class="tableHeader"><bean:write name="result" property="orgTypeCd"/>Organization Type</td>
<td class="tableHeader" align="center"><bean:write name="result" property="branch"/>Branch</td>
</logic:iterate>
</tr>
</logic:present>
0
mrigankCommented:
Use a checkbox

<td height="20" class="tableHeader"><INPUT TYPE=CHECKBOX NAME="CHECKED_RESULTS" value="<bean:write name="result" property="legalEntityName"/>"></td>


In your Java class use
request.getParameterNames("CHECKED_RESULTS");

It shall return a comma separated value of all checked legalEntityNames.

Let me know if it helps

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

mrigankCommented:
sorry it is

request.getParameterValues("CHECKED_RESULTS");
0
KirtipurItagolAuthor Commented:
My Bad. Actually the code goes like this:
This is my table columns:
<logic:present name="searchForm" property="results">
      <logic:iterate id="result" name="searchForm" property="results">
<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0>

<tr class="tableHeader">
 <td height="20" class="tableHeader"></td>
 <td class="tableHeader">Legal Entity Name</td>
 <td class="tableHeader">Account Number</td>
 <td class="tableHeader">Country</td>
 <td class="tableHeader">Currency</td>
 <td class="tableHeader">Organization Type</td>
<td class="tableHeader" align="center">Citigroup Branch</td>
</tr>

<tr bgcolor="white">
And this is how it will iterate when it fetches data from the database in the same jsp page:


 <td class="detailsCenter" align="center"><html:radio property="selectAccount"/></td>
 <td class="details"><bean:write name="result" property="legalEntityName"/></td>
 <td class="details"><a href="/accntData.do"><bean:write name="result" property="existingAccountNumber"/></a></td>
 <td class="details"><bean:write name="result" property="legalCountry"/></td>
 <td class="details"><bean:write name="result" property="existingCurrency"/></td>
 <td class="details"><bean:write name="result" property="orgTypeCd"/></td>
 <td class="details"><bean:write name="result" property="branch"/></font></td>      
</tr>
Am I doing it correctly?? By the way in the action form i have getters and setters for all the form fields. And in my action class I've:
public class SearchAction extends Action{
      public ActionForward execute(ActionMapping mapping, ActionForm form,
               HttpServletRequest request, HttpServletResponse response)
               throws IOException, ServletException {      
         
               
                ArrayList results = new ArrayList();
                        SearchDAO objDAO = new SearchDAO();

               
                searchForm searchForm = (searchForm) form;
                //perform  search based on what criteria was entered
                results = objDAO.getSearchResult(searchForm.getLegalEntityName(),
                              searchForm.getOrgTypeCd(),searchForm.getExistingAccountNumber(),searchForm.getBranch());
           
                searchForm.setResults(results);
               
                //forward control to this actions input page
                return mapping.getInputForward();
                        
      }
}

First of all I'm wondering whether i'm doing it correctly and second of all I'm not totally sure about iterating through the radio buttons. help me out folks.
0
mrigankCommented:
Did  you try the approach that I have posted ?
0
KirtipurItagolAuthor Commented:
mrigank, i want to display the result on a table in a same jsp with four search criteria. Upon fetching datas, it will display the results in six columns in the same page with a radio button on each result. So it would be something like this after the user clicks the submit button:

<logic:present name="searchForm" property="results">
      <logic:iterate id="result" name="searchForm" property="results">
<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0>

<tr class="tableHeader">
 <td height="20" class="tableHeader"></td>
 <td class="tableHeader">Legal Entity Name</td>
 <td class="tableHeader">Account Number</td>
 <td class="tableHeader">Country</td>
 <td class="tableHeader">Currency</td>
 <td class="tableHeader">Organization Type</td>
<td class="tableHeader" align="center">Citigroup Branch</td>
</tr>

<tr bgcolor="white">

 <td class="detailsCenter" align="center"><html:radio property="selectAccount"/></td>
 <td class="details"><bean:write name="result" property="legalEntityName"/></td>
 <td class="details"><a href="/accntData.do"><bean:write name="result" property="existingAccountNumber"/></a></td>
 <td class="details"><bean:write name="result" property="legalCountry"/></td>
 <td class="details"><bean:write name="result" property="existingCurrency"/></td>
 <td class="details"><bean:write name="result" property="orgTypeCd"/></td>
 <td class="details"><bean:write name="result" property="branch"/></font></td>      
</tr>

</TABLE>
</logic:iterate>
 </logic:present>

So I will use your code in action class like :
request.getParameterValues("selectAccount");//this will get the radio button and in the jsp page, with iterate tag, will iterate with each result. Is that right?
Server in my IDE is still uninstalled, I'm just trying to work on the problem before the project initiation. Thanks
0
mrigankCommented:
Replace <html:radio property="selectAccount"/>

with


<td height="20" class="tableHeader"><INPUT TYPE=CHECKBOX NAME="selectAccount" value="<bean:write name="result" property="legalEntityName"/>"></td>


In your Java class use
request.getParameterNames("selectAccount");

and try it  out.
Am just sugesting to use a checkbox.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KirtipurItagolAuthor Commented:
and also in the form bean i have to have getters and setters for the selectAccount, isn't that right?? But why not radio button??
0
mrigankCommented:
you can do that. For checkboxes, if the box is not checked ,  then you get a null else a not  null value. That should be your check.

A checkbox fits here much better than a radio button.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.