I am having some issue setting values for Contact object in my form bean. Please see code below:
I have 2 jsps, a.jsp and b.jsp. In a.jsp I am able to see the contact information, when I click on edit, I cant see contact information in b.jsp page
Thanks
public class StudentsForm extends ActionForm{
private
String studentId;
private String firstName;
private String lastName;
private ContactVO contact;
public ContactVO getContact() {
return contact;
}
public void setContact(ContactVO contact) {
this.contact = contact;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
contact = new ContactVO();
}
}
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<link href="<c:url value='main.css'/>" rel="stylesheet" type="text/css"/>
<title><fmt:message key="label.students"/></title>
</head>
<body>
<div class="titleDiv"><fmt:message key="application.title"/></div>
<h1><fmt:message key="label.students"/></h1>
<c:url var="url" scope="page" value="/studentSetUp.do">
<c:param name="dispatch" value="setUpForInsertOrUpdate"/>
</c:url>
<a href="${url}">Add New Student Contact</a>
<br/><br/>
<table class="borderAll">
<tr>
<th><fmt:message key="label.firstName"/></th>
<th><fmt:message key="label.lastName"/></th>
<th><fmt:message key="label.address"/></th>
<th><fmt:message key="label.phonenum"/></th>
<th><fmt:message key="label.email"/></th>
<th> </th>
</tr>
<c:forEach var="std" items="${students}" varStatus="status">
<tr class="${status.index%2==0?'even':'odd'}">
<td class="nowrap"><c:out value="${std.firstName}"/></td>
<td class="nowrap"><c:out value="${std.lastName}"/></td>
<td class="nowrap"><c:out value="${std.contactVO.address}"/></td>
<td class="nowrap"><c:out value="${std.contactVO.phoneNumber}"/></td>
<td class="nowrap"><c:out value="${std.contactVO.email}"/></td>
<td class="nowrap">
<c:url var="url" scope="page" value="/studentSetUp.do">
<c:param name="studentId" value="${std.studentID}"/>
<c:param name="dispatch" value="setUpForInsertOrUpdate"/>
</c:url>
<a href="${url}">Edit</a>
<c:url var="url" scope="page" value="/studentProcess.do">
<c:param name="studentId" value="${std.studentID}"/>
<c:param name="dispatch" value="delete"/>
</c:url>
<a href="${url}">Delete</a>
</td>
</tr>
</c:forEach>
</table>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<c:set var="insertUpdateTitle" value="${!empty studentForm.studentId && studentForm.studentId != 0 ?'Update Student':'Add Student'}"/>
<html>
<head>
<link href="<c:url value='main.css'/>" rel="stylesheet" type="text/css"/>
<style>td { white-space:nowrap; }</style>
<title><c:out value="${insertUpdateTitle}"/></title>
</head>
<body>
<div class="titleDiv"><fmt:message key="application.title"/></div>
<h1><c:out value="${insertUpdateTitle}"/></h1>
<html:form action="/studentProcess">
<table>
<tr>
<td class="tdLabel"><fmt:message key="label.firstName"/>:</td>
<td><html:text property="firstName" size="40"/> <html:errors property="firstName"/></td>
</tr>
<tr>
<td class="tdLabel"><fmt:message key="label.lastName"/>:</td>
<td><html:text property="lastName" size="40"/> <html:errors property="lastName"/></td>
</tr>
<tr>
<td class="tdLabel"><fmt:message key="label.address"/>:</td>
<td><html:text property="contact.address" size="75"/> <html:errors property="contact.address"/></td>
</tr>
<tr>
<td class="tdLabel"><fmt:message key="label.phonenum"/>:</td>
<td><html:text property="contact.phoneNumber" size="15"/> <html:errors property="contact.phoneNumber"/></td>
</tr>
<tr>
<td class="tdLabel"><fmt:message key="label.email"/>:</td>
<td><html:text property="contact.email" size="15"/> <html:errors property="contact.email"/></td>
</tr>
<tr>
<td colspan="2">
<html:hidden property="studentId"/>
<input type="hidden" name="dispatch" value="insertOrUpdate"/>
<br/>
<input type="submit" value="<fmt:message key="button.label.submit"/>" class="butStnd"/>
<input type="submit" value="<fmt:message key="button.label.cancel"/>" class="butStnd" onclick="document.studentForm.dispatch.value='getAllStudents'"/>
</td>
</tr>
</table>
</html:form>
</body>
</html>