• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checkbox in Iterator

 
Smita Ahuja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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]);
}
 
Joe Ess
Bartender
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use indexed properties to do arrays of values.
 
Smita Ahuja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe,

Could you please share any example for this..
Thanks
 
Joe Ess
Bartender
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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: 28
  • Mark post as helpful
  • send pies
  • 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;
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic