Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

form bean is not getting updated upon submit in jsp

 
jagadish cheluri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks,
Jagadish
 
Shak Smith
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please post the code?
(jsp, class, struts.action)
 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
}


}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

VO's


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.
}


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


JSP


<%@ taglib uri="struts-bean" prefix="bean"%>
<%@ taglib uri="struts-html" prefix="html"%>
<%@ taglib uri="struts-logic" prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" 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;
form.submit();
}

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;
}
</script>

<%

<h1>Time Entry</h1>
<html:form action="/timeEntry.do" 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%">
<tr>
<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>
</tr>
<tr>
<td height="10" colspan="3"> </td>
</tr>


<logic:empty name="timesheet_form_bean" property="weeksList" >
<tr>
<td align="center" colspan="6"><span class="error"><%=WtlcAppKeys.NO_DATA_AVAILABLE%></span></td>
</tr>
</logic:empty>
<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">


<fieldset>
<legend>

</legend>

<table border="0" cellpadding="0" cellspacing="0" class="colorbox2 font100" title="" summary="" align="center" width="100%">
<tr>
<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>
</span>

</td>
</tr>



<tr> <td height="1" colspan="2"> </td></tr>
<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>
</tr>

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

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

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

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

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

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



</tr>

</nested:iterate>


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


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

</td>
</tr>
</table>

</td>
</tr>
</table>
</fieldset>

</nested:iterate>
</nested:nest>
</logic:notEmpty>

<tr> <td height="10"> </td></tr>
</table>
</html:form>



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:

service.loadTimesheets(timesheetForm);
ActionForward(fwdPath);

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
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jagdish,
Please put your code inside code block which will provide more readability to your code.


Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic