The moose likes Struts and the fly likes form bean is not getting updated upon submit in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "form bean is not getting updated upon submit in jsp" Watch "form bean is not getting updated upon submit in jsp" New topic

form bean is not getting updated upon submit in jsp

jagadish cheluri

Joined: Jan 15, 2010
Posts: 3
Hi all,

I have been javascript:emoticon(''); for last 3 days with this issue, Please help me out.

Let me explain the scenario first.
Here we go,

I have a arraylist of VO objects(called A) defined in a form bean.
Each VO object in turn contains arraylists of two VO objects (called B & C) and some primitive attributes.
I could able to populate data in jsp successfully(Whatever data i prepare in action class ). But, if I edit any inner VO object data(data of B & C VO's), up on submit , the form bean is not getting updated.

Please let me know , if you need more info abt this issue. Any help will be appreciated.

Shak Smith

Joined: Feb 19, 2010
Posts: 12
Can you please post the code?
(jsp, class, struts.action)
Fidel Edwards
Ranch Hand

Joined: Mar 19, 2008
Posts: 234
Hi Jagdish,

Could you declare each VO as Serialize? I have come up with same type of situations earlier.

Please let me know if this solves your problem. Good Luck...
jagadish cheluri

Joined: Jan 15, 2010
Posts: 3
Sorry for the late reply, I was out of town.

Hi Fidel,
Thanks for the reply. I have the VO's implemented Serializable already , still its not working.

Hi Shak,

See code pasted below:
Form Bean:

public class TimesheetForm extends ActionForm{
private String firstName;
private String lastName;
private String employeeID;
private String employeeStatus;
private ArrayList<WeekVO> weeksList;
private String dowhat;

public TimesheetForm() {

public void setFirstName(String firstName) {
this.firstName = firstName;

public String getFirstName() {
return firstName;

public void setLastName(String lastName) {
this.lastName = lastName;

public String getLastName() {
return lastName;

public void setEmployeeID(String employeeID) {
this.employeeID = employeeID;

public String getEmployeeID() {
return employeeID;

public void setEmployeeStatus(String employeeStatus) {
this.employeeStatus = employeeStatus;

public String getEmployeeStatus() {
return employeeStatus;

public void setWeeksList(ArrayList<WeekVO> weeksList) {
this.weeksList = weeksList;

public ArrayList<WeekVO> getWeeksList() {
return weeksList;

public void setDowhat(String dowhat) {
this.dowhat = dowhat;

public String getDowhat() {
return dowhat;

public WeekVO getWeeksList(int index)
// make sure that orderList is not null
if(this.weeksList == null)
this.weeksList = new ArrayList<WeekVO>();

// indexes do not come in order, populate empty spots
while(index >= this.weeksList.size())
this.weeksList.add(new WeekVO());

// return the requested item
return weeksList.get(index);




1st VO:

public class WeekVO implements Serializable{

private String weekStartDate;
private String weekEndDate;
private String status;
private String workSchedule;
private String totalWorkHoursEntered;
private String totalLeaveHoursEntered;
private String usualNoOfHoursPerWeek;

private ArrayList<HoursWorkedVO> hoursWorkedList;
private ArrayList<LeaveTakenVO> leaveTakenList;

// setters and getters for above attributes.

2nd VO :

public class HoursWorkedVO implements Serializable {
private String projectCode;
private String Description;

private String monWorkedHours;
private String tueWorkedHours;
private String wedWorkedHours;
private String thuWorkedHours;
private String friWorkedHours;
private String satWorkedHours;
private String sunWorkedHours;

// setters and getters for above attributes.

3rd VO:

public class LeaveTakenVO implements Serializable{
private String leaveType;
private String description;

private String monLeaveHours;
private String tueLeaveHours;
private String wedLeaveHours;
private String thuLeaveHours;
private String friLeaveHours;
private String satLeaveHours;
private String sunLeaveHours;

// setters and getters for above attributes.



<%@ taglib uri="struts-bean" prefix="bean"%>
<%@ taglib uri="struts-html" prefix="html"%>
<%@ taglib uri="struts-logic" prefix="logic"%>
<%@ taglib uri="" prefix="nested"%>

<%@ taglib uri="c" prefix="c"%>

<%@ page contentType="text/html;charset=windows-1252"%>
<bean:define id="timesheetForm" name="timesheet_form_bean" type="com.bean.TimesheetForm"/>

<script language="javascript" src="js/functions.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function doAction(key,form)
form.<%=WtlcActionKeys.DO_WHAT%>.value = key;

function validateWtlcEnterTimeForm(){

// document.getElementsByName("weeksList[0].hoursWorkedList[0].monWorkedHours").value= document.getElementById("hoursWorkedList[0].monWorkedHours").value;
doAction('<%=WtlcActionKeys.SAVE_WORK_LEAVE_ENTRY%>', document.timesheet_form_bean);
return true;


<h1>Time Entry</h1>
<html:form action="/" styleId="timesheet_form_bean" onsubmit="return validateWtlcEnterTimeForm()">
<html:hidden property="<%=WtlcActionKeys.DO_WHAT%>" value="<%=timesheetForm.getDowhat()%>" />
<table border="0" cellpadding="0" cellspacing="0" class="font100" title="" summary="" align="center" width="100%">
<td class="fontbold"><bean:write name="timesheet_form_bean" property="<%=WtlcAppKeys.FIRST_NAME%>"/> <bean:write name="timesheet_form_bean" property="<%=WtlcAppKeys.LAST_NAME%>"/> </td>
<td> <span class="fontbold"> <%=WtlcAppKeys.EMPLOYEE_ID_NUMBER_TITLE%>: </span><bean:write name="timesheet_form_bean" property="<%=WtlcAppKeys.EMPLOYEE_ID_NUMBER%>"/></td>
<td><span class="fontbold"><%=WtlcAppKeys.EMPLOYMEE_STATUS_TITLE%>: </span><bean:write name="timesheet_form_bean" property="<%=WtlcAppKeys.EMPLOYMEE_STATUS%>"/> </td>
<td height="10" colspan="3"> </td>

<logic:empty name="timesheet_form_bean" property="weeksList" >
<td align="center" colspan="6"><span class="error"><%=WtlcAppKeys.NO_DATA_AVAILABLE%></span></td>
<logic:notEmpty name="timesheet_form_bean" property="weeksList">
<nested:nest property="weeksList">
<nested:iterate id="weeksList" property="weeksList" name="timesheet_form_bean" type="gov.virginia.doe.wtlc.common.WeekVO" indexId="ctr1">



<table border="0" cellpadding="0" cellspacing="0" class="colorbox2 font100" title="" summary="" align="center" width="100%">
<td class="datasize" >

<span class="fontbold">
<FONT color =blue><span class="fontbold">Week of <bean:write name="weeksList" property="<%=WtlcAppKeys.WEEK_START_DATE%>"/>-<bean:write name="weeksList" property="<%=WtlcAppKeys.WEEK_END_DATE%>"/> </span></FONT>


<tr> <td height="1" colspan="2"> </td></tr>
<td colspan="2">
<table id="masterDataTable" width="100%" cellpadding="1" border="0" cellspacing="0"
class="colorbox borderleft1 borderright1 borderbottom1">
<tr class="tableheader"> <td align="center" colspan="8"><%=WtlcAppKeys.HOURS_WORKED_TITLE%></td></tr>
<tr class="tableheader">
<th scope="row" width="50%" class="fontbold font85" id="projectCodes" align="left"><%=WtlcAppKeys.PROJECT_CODE_TITLE%> </th>
<th scope="row" class="fontbold font85" id="mon"> <%=WtlcAppKeys.MONDAY_TITLE%><br><nested:write name="weeksList" property="<%=WtlcAppKeys.MONDAY_DATE%>"/> </th>
<th scope="row" class="fontbold font85" id="tue"> <%=WtlcAppKeys.TUESDAY_TITLE%><br><nested:write name="weeksList" property="<%=WtlcAppKeys.TUESDAY_DATE%>"/> </th>
<th scope="row" class="fontbold font85" id="wed"> <%=WtlcAppKeys.WEDNESDAY_TITLE%><br><nested:write name="weeksList" property="<%=WtlcAppKeys.WEDNESDAY_DATE%>"/> </th>
<th scope="row" class="fontbold font85" id="thu"> <%=WtlcAppKeys.THURSDAY_TITLE%><br><nested:write name="weeksList" property="<%=WtlcAppKeys.THURSDAY_DATE%>"/> </th>
<th scope="row" class="fontbold font85" id="fri"> <%=WtlcAppKeys.FRIDAY_TITLE%><br><nested:write name="weeksList" property="<%=WtlcAppKeys.FRIDAY_DATE%>"/></th>
<th scope="row" class="fontbold font85" id="sat"> <%=WtlcAppKeys.SATURDAY_TITLE%><br><nested:write name="weeksList" property="<%=WtlcAppKeys.SATURDAY_DATE%>"/> </th>
<th scope="row" class="fontbold font85" id="sun"> <%=WtlcAppKeys.SUNDAY_TITLE%><br><nested:write name="weeksList" property="<%=WtlcAppKeys.SUNDAY_DATE%>"/> </th>

<nested:iterate id="hoursWorkedList" property="hoursWorkedList" type="gov.virginia.doe.wtlc.common.HoursWorkedVO" indexId="ctr">
<tr class="borderbottom3">
<td headers="projectCodes"><nested:write name="hoursWorkedList" property="<%=WtlcAppKeys.PROJECT_CODE%>"/>-<nested:write name="hoursWorkedList" property="<%=WtlcAppKeys.PROJECT_DESCRIPTION%>"/></td>
<td headers="mon" align="center">

<nested:text property="<%=WtlcAppKeys.MONDAY_WORKED_HOURS%>" name="hoursWorkedList" indexed="true" size="3"/>

<td headers="tue" align="center">
<nested:text property="<%=WtlcAppKeys.TUESDAY_WORKED_HOURS%>" name="hoursWorkedList" indexed="true" size="3"/>

<td headers="wed" align="center">
<nested:text property="<%=WtlcAppKeys.WEDNESDAY_WORKED_HOURS%>" name="hoursWorkedList" indexed="true" size="3"/>

<td headers="thu" align="center">
<nested:text property="<%=WtlcAppKeys.THURSDAY_WORKED_HOURS%>" name="hoursWorkedList" indexed="true" size="3"/>

<td headers="fri" align="center">
<nested:text property="<%=WtlcAppKeys.FRIDAY_WORKED_HOURS%>" name="hoursWorkedList" indexed="true" size="3"/>

<td headers="sat" align="center">
<nested:text property="<%=WtlcAppKeys.SATURDAY_WORKED_HOURS%>" name="hoursWorkedList" indexed="true" size="3"/>

<td headers="sun" align="center">
<nested:text property="<%=WtlcAppKeys.SUNDAY_WORKED_HOURS%>" name="hoursWorkedList" indexed="true" size="3"/>



<tr class="colorbox">
<td colspan="3">

<input type="submit" name="Submit Time Entry Data" value="Save" class="button" tabindex="<%=tabindex++%>"></input>    




<tr> <td height="10"> </td></tr>

I have not included any action class code because i dont have anything in it other than a call to service layer (which will set data in form bean to populate in jsp) and a ActionForward as shown below:


In the service class , I have JDBC calls to get the required info to populate data in form bean.

Please lemme know if you need any further details.

Fidel Edwards
Ranch Hand

Joined: Mar 19, 2008
Posts: 234
Hi Jagdish,
Please put your code inside code block which will provide more readability to your code.

I agree. Here's the link:
subject: form bean is not getting updated upon submit in jsp
It's not a secret anymore!