• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Checkbox in Iterator

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

My company is having one old application in struts 1.2 with java 1.4,
they want to make some changes in that application, they are looking for checkboxws in iteartor
I worked like below
formbean contains:
private String[] tenderChk;
jsp:
<logic:iterate name="tenderersList" id="tenderer">
<tr class="data">
<html:form action="SetupTenderersAction.do">
<html:hidden name="tenderer" property="tendererId"/>
<html:hidden property="mode" value="firstTimeEdit"/>
<html:hidden name="tenderFormBean" property="projectId"/>
<td>
<input type="checkbox" id="chk" name="tenderChk" value="<bean:write name="tenderer" property="tendererId" />"/>

I want tendererId value in array tenderChk;, so that I could work on its action, but I am not getting any value in my action class
TenderFormBean tenderFormBean = (TenderFormBean) form;
String checkbox[] = tenderFormBean.getTenderChk();
System.out.println("---checkbox--->>"+checkbox);

List list1 = Arrays.asList(checkbox);

System.out.println("----List1===>>>"+list1);

for(int i=0;i<checkbox.length;i++)
{
System.out.println("--for=="+checkbox[i]);
}
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to use indexed properties to do arrays of values.
 
Smita Ahuja
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe,

Could you please share any example for this..
Thanks
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you didn't follow the link in my post that takes you to an excellent example? Googling for "Struts Indexed Properties" will get you others as well.
 
Smita Ahuja
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Joe,

But my list is a Vector and I am getting it in jsp through request.setAttribute(in action)
How to set indexId in logic:iterate for the Vector List.

Vector tenderersList = tenderDelegate.loadTenderersList(tenderFormBean);

request.setAttribute("tenderFormBean", tenderFormBean);
request.setAttribute("tenderersList", tenderersList);
and Jsp:
<logic:iterate name="tenderersList" id="tenderer" >
<tr class="data">
<html:form action="SetupTenderersAction.do">
<html:hidden name="tenderer" property="tendererId"/>
<html:hidden property="mode" value="firstTimeEdit"/>
<html:hidden name="tenderFormBean" property="projectId"/>
<td>

<input type="checkbox" name="tenderChk" value="<bean:write name="tenderer" property="tendererId"/>"/>
</td>
and formbean is :

public class TendererFormBean extends ValidatorForm {
private String[] tenderChk;

public String[] getTenderChk() {
return tenderChk;
}


public void setTenderChk(String[] tenderChk) {
this.tenderChk = tenderChk;
}
}
reply
    Bookmark Topic Watch Topic
  • New Topic