File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Saving List Of Objects from JSP through Struts 1.3 Form Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Saving List Of Objects from JSP through Struts 1.3 Form Bean" Watch "Saving List Of Objects from JSP through Struts 1.3 Form Bean" New topic

Saving List Of Objects from JSP through Struts 1.3 Form Bean

lokesh venkata

Joined: Sep 28, 2010
Posts: 1

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

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


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] from jsp

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

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.

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

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

Joined: Jan 10, 2002
Posts: 63841

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.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Saving List Of Objects from JSP through Struts 1.3 Form Bean
It's not a secret anymore!