• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving List Of Objects from JSP through Struts 1.3 Form Bean

 
lokesh venkata
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have difficulties in Capturing list of Java Objects back into the Forma bean of the action class when i submit/save the jsp.

[code]
public class EmployeeForm extends ActionForm {
List<EmployeeVO> employeeVOList;
getEmployeeVOList(){ return employeeVOList;}
setEmployeeVOList(List employeeVOList){ this.employeeVOList = employeeVOList;}
}
[code]

---------------------------------------------------------------------------------
[code]

public class EmployeeVO {
private String lastName;private String firstName;
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
}
[code]

--------------------------------
[code] from jsp

<logic:iterate id="record" property="employeeVOList" type="EmployeeVO" name="EmployeeForm" indexId="index">
<TR>
<TD>
<input type="text" name="record[<bean:write name='index'/>].EmployeeVO.lastName"
value="<bean:write name='record' property='lastName'/>" />
</TD>
<TD >
<input type="text" name="record[<bean:write name='index'/>].EmployeeVO.firstName"
value="<bean:write name='record' property='firstName'/>" /></TD>
</TR>
</logic:iterate>
[code]

--------------------------------
Results are getting displayed correctly with the above code.But, After submitting the above JSP, in the action class I am trying to the following.

[code]
EmployeeForm employeeForm = (EmployeeForm)form;
List<EmployeeVO> listEmp = employeeForm.getEmployeeList();
[code]

But listEmp is always coming null and is not getting the values from the JSP.

i am expecting the List of EmployeeVO objects with the new values entered in the form bean after submitting the above jsp.

Please Advice.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64993
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Two things:

1) Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.

2) Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic