You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Toni Nehme <tn...@hotmail.com> on 2002/06/28 15:41:16 UTC
How can I get the value of radio button in a table using iterator tag
I have a table that each row of this table has the following:
2 radiobottons, 2 other fields.
The headers for the columns are the following:
Optional, Compulsory, CourseId,description
My form looks like the following:
private ArrayList courses = new ArrayList();
public java.util.ArrayList getCourses()
{
return courses;
}
public void setCourses(java.util.ArrayList courses)
{
this.courses = courses;
}
public Course getCourse(int index)
{
return (Course) courses.get(index);
}
public void setCourse(int index, Course course)
{
courses.set(index,course);
}
My Course class looks like the following:
public class Course implements Serializable {
private String id = null;
private String desc = null;
private String status = null;
private final String OPTIONAL = 0;
private final String REQUIRED = 1;
public Course(String id, String desc)
{
this.id=id;
this.desc=desc;
}
public String getId(){return id;}
public void setId(String s){id = s;}
public String getDesc(){return desc;}
public void setDesc(String s){desc = s;}
public String getStatus()
{
return status;
}
public void setStatus(String stat)
{
status=stat;
}
My Jsp looks like the following:
<table border=1>
<tr>
<td>Optional</td>
<td>Required</td>
<td>CourseId</td>
<td>Description</td>
</tr>
<logic:iterate id="courses" name="CourseForm" property="courses">
<tr>
<td><html:radio name="courses" property="status" value="0"
indexed="true"/></td>
<td><html:radio name="courses" property="status" value="1"
indexed="true" /></td>
<td><bean:write name="courses" property="id"/></td>
<td><bean:write name="courses" property="desc"/></td>
</tr>
</logic:iterate>
</table>
My action when I click on the submit button to submit the form is:
CourseForm courseForm = (CourseForm) form;
ArrayList ar = courseForm.getCourses();
System.out.println("The courses === ar==== " + ar.toString());
My Problem is that when I make the radio selections in the table and click
on submit, I can not get the courses with their values
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: How can I get the value of radio button in a table using iterator tag
Posted by fabrice dewasmes <fd...@kaptech.com>.
Hi !
you're facing the same problem as me yesterday. Don't scratch your head too
long and see the post below :
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg34821.html
it's kind of a conclusion for (nearly ;))a monolog. You can't use indexed
property with a request scope. Try with session, it's magic !
Fabrice
> -----Message d'origine-----
> De : Toni Nehme [mailto:tnehme81@hotmail.com]
> Envoyé : vendredi 28 juin 2002 15:41
> À : struts-user@jakarta.apache.org
> Objet : How can I get the value of radio button in a table using
> iterator tag
>
>
>
> I have a table that each row of this table has the following:
> 2 radiobottons, 2 other fields.
>
> The headers for the columns are the following:
>
> Optional, Compulsory, CourseId,description
>
>
>
> My form looks like the following:
>
>
> private ArrayList courses = new ArrayList();
>
> public java.util.ArrayList getCourses()
> {
> return courses;
> }
>
> public void setCourses(java.util.ArrayList courses)
> {
> this.courses = courses;
> }
>
> public Course getCourse(int index)
> {
> return (Course) courses.get(index);
> }
>
> public void setCourse(int index, Course course)
> {
> courses.set(index,course);
> }
>
>
> My Course class looks like the following:
>
> public class Course implements Serializable {
>
> private String id = null;
> private String desc = null;
> private String status = null;
>
> private final String OPTIONAL = 0;
> private final String REQUIRED = 1;
>
> public Course(String id, String desc)
> {
> this.id=id;
> this.desc=desc;
> }
> public String getId(){return id;}
> public void setId(String s){id = s;}
>
> public String getDesc(){return desc;}
> public void setDesc(String s){desc = s;}
>
> public String getStatus()
> {
> return status;
> }
> public void setStatus(String stat)
> {
> status=stat;
> }
>
>
>
> My Jsp looks like the following:
>
>
> <table border=1>
> <tr>
> <td>Optional</td>
> <td>Required</td>
> <td>CourseId</td>
> <td>Description</td>
> </tr>
> <logic:iterate id="courses" name="CourseForm" property="courses">
> <tr>
> <td><html:radio name="courses" property="status" value="0"
> indexed="true"/></td>
> <td><html:radio name="courses" property="status" value="1"
> indexed="true" /></td>
> <td><bean:write name="courses" property="id"/></td>
> <td><bean:write name="courses" property="desc"/></td>
> </tr>
> </logic:iterate>
> </table>
>
>
>
>
>
> My action when I click on the submit button to submit the form is:
>
> CourseForm courseForm = (CourseForm) form;
>
> ArrayList ar = courseForm.getCourses();
> System.out.println("The courses === ar==== " + ar.toString());
>
>
>
> My Problem is that when I make the radio selections in the table
> and click
> on submit, I can not get the courses with their values
>
>
>
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>