Reputation: 93
Hi let me tell you i searched a lot but i could not find what i wanted
here is the scenario
there is table in my jsp which is being loaded through iterator which is ArrayList<Report>
report has three attributes parameter,observation,designed
in the JSP i will show the first and third column values through iterator
<s:iterator value="ReportList" status="status" var="obj">
<tr>
<td><s:property value="%{#obj.parameter}" /></td>
<td><s:textfield theme="simple" name="valOfSim" /></td>
<td><s:property value="%{#obj.designed}" /></td>
</tr>
</s:iterator>
Parameter observation designed X 10 y 11 Z 12
now i have to capture the second value which has been entered kindly help!
EDIT: my code
Let me explain first preload method will be called and the values will be prepopulated through ArrayList<Obj>
and then the user will enter the value for observation then am capturing that through this
<td><s:textfield theme="simple" name="obj[%{#status.index}].observation" /></td>
after that a submit button will be there onclicking that submit method of action class will be called
which prints the value entered by user (here am getting NULL)
import mypro.web.utility.SpringServiceLocator;
public class myAction extends ActionSupport implements
ModelDriven,SessionAware,ServletRequestAware,Preparable {
private Map<String, Object> session;
private Model model = new Model();
public void prepare()
{
Obj obj = new Obj();
Obj obj2 = new Obj();
Obj obj3 = new Obj();
obj.setDesigned("10");
obj.setParameter("X");
model.getReportList().add(obj1);
obj.setDesigned("11");
obj.setParameter("y");
model.getReportList().add(obj2);
obj.setDesigned("12");
obj.setParameter("Z");
model.getReportList().add(obj3);
}
public String preload()
{
return "success";
}
public String submit()
{
System.out.println("------------------------------------------------------
&&&&&&&&&:"+model.getReportList().size());
for(Obj obj : model.getReportList)
{
System.out.println("the value is to be checked"+obj.getObservation());//value which will be entered by user
System.out.println("the value is to be checked"+obj.getRefcode()); //value which was added in the prepare method
}
return "success";
}
public Object getModel() {
return model;
}
Upvotes: 0
Views: 2117
Reputation: 50203
Change this:
<s:textfield theme="simple" name="valOfSim" />
to this:
<s:textfield theme="simple" name="obj[%{#status.index}].observation" value="" />
This will
observation
field of the obj
element; This way, IF your Action has a setter
for your obj element (and not only a getter),
when you will submit the form containing your iterated elements, you will retrieve all the observation
values inserted by the user in your ArrayList<Obj>
...
Upvotes: 1