• 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

dynamic number of struts:checkbox

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody help me?
I am using <html:checkbox> and know that I can use indexed property to have dynamic number of check boxes.
But, i am unable to get the values in form bean.
Can anybody please please put a sample code.
I have read over various sites it is very confusing and I am completely lost
 
AmanSingh SIdhu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also for the above I have dynamic rows ie Result set from data base,
Against each row is a check box, SO I do not know either the name or the number of check boxes I am going to have.
But I need to retrieve only the rows that have been check and submit them back to
 
AmanSingh SIdhu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Here is my complete problem,
And the solution that i am using.
Can anybody let me know what wrong am I doing?

test.jsp
*******
<logic:iterate name = "list" id = "line">
<tr >
<td align = "center" >
<html:checkbox name="line" property = "fieldA" indexed = "true" value = "true" ></html:checkbox>
</td>
<td align="Center"><bean:write name ="line" property = "message" /></td>
</tr>
</logic:iterate>

TestForm.java
*************
Line[] line = new Line[]{};

public Line[] getLine() {
return line;
}

public void setLine(Line[] line) {
this.line = line;
}

public Line getLine(int index){
while(index>=line.length){
line[index] = new Line();

}
return (Line) line[index];
}
Line.java
**********
boolean fieldA;

public boolean isFieldA() {
return fieldA;
}

public boolean getFieldA(){
return fieldA;
}


Now when i run theis i get error:
javax.servlet.ServletException: No getter method for property fieldA of bean line

my understanding about indexed fields is that getLine[0] will be called, which is a Line object and that does have getter method for fieldA.

Also I read in some places that name attribute for dynamic check box should be same as id attribute forlogi:iterate tag.

Can anybody please help me.

Thanks A lot
public void setFieldA(boolean fieldA) {
this.fieldA = fieldA;
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic