File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Saving List Of Objects from JSP through Struts 1.3 Form Bean

lokesh venkata
Greenhorn

Joined: Sep 28, 2010
Posts: 1
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

Joined: Jan 10, 2002
Posts: 60781
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
 
wood burning stoves
 
subject: Saving List Of Objects from JSP through Struts 1.3 Form Bean
 
Similar Threads
Set bean property values
Indexed Setting/properties
Help! Form to update multiple records upon save
form bean is not getting updated upon submit in jsp
SOS--------display data collection from database