Hi
In roseindia for abstract wizard form controller example contains half of the code. please send the remaing half of the code like controller classes....
In step 4
user2.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<html>
<head>
<title>Second Entry</title>
</head>
<body>
<form:form method="POST" commandName="user">
<center>
<table>
<tr>
<td align="right" width="20%"> <strong>Date of birth:</strong></td>
<td style="width: 50%">
<spring:bind path="user.dob">
<input type="text" name="dob" value="<c:out value="${status.value}"/>"/>
</spring:bind>
</td>
<td><font color="red"><form:errors path="dob"/></font>
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Address:</strong></td>
<td style="width: 50%">
<spring:bind path="user.address">
<input type="text" name="address" value="<c:out value="${status.value}"/>"/>
</spring:bind>
</td>
<td><font color="red"><form:errors path="address"/></font>
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Country:</strong></td>
<td style="width: 50%">
<spring:bind path="user.country">
<input type="text" name="country" value="<c:out value="${status.value}"/>"/>
</spring:bind>
</td>
<td><font color="red"><form:errors path="country"/></font>
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Qualification:</strong></td>
<td style="width: 50%">
<spring:bind path="user.qualification">
<input type="text" name="qualification" value="<c:out value="${status.value}"/>"/>
</spring:bind>
</td>
<td><font color="red"><form:errors path="qualification"/></font>
</td>
</tr>
<tr>
<td ></td>
<td style="width: 50%" >
<input type="submit" name="_target0" value="Previous"/>
<input type="submit" name="_target2" value="Next"/>
<input type="submit" name="_cancel" value="Cancel"/>
<input type="submit" name="_target2" value="Finish"/>
</td>
</tr>
</table>
</center>
</form:form>
</body>
</html>
continue..
user3.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<html>
<head>
<title>Show Details</title>
</head>
<body>
<form:form method="POST" commandName="user">
<center>
<table>
<tr>
<td style="width: 56%" colspan="2">
<strong>The Values entered are as follow
</strong>
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>First Name:</strong></td>
<td style="width: 56%">
${user.firstName}
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Last Name:</strong></td>
<td style="width: 56%">
${user.lastName}
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Email Id:</strong></td>
<td style="width: 56%">
${user.emailId}
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Contact:</strong></td>
<td style="width: 56%">
${user.contact}
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Gender:</strong></td>
<td style="width: 56%">
${user.gender}
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Date of Birth:</strong></td>
<td style="width: 56%">
${user.dob}
</td>
</tr>
<tr>
<td align="right" width="20%"><strong>Address:</strong></td>
<td style="width: 56%">
${user.address}
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Country:</strong></td>
<td style="width: 56%">
${user.country}
</td>
</tr>
<tr>
<td align="right" width="20%"> <strong>Qualification:</strong></td>
<td style="width: 56%">
${user.qualification}
</td>
</tr>
</table>
</center>
</form:form>
</body>
</html>
continue..
In step 5:
User.java:
package net.roseindia.web;
public class User {
private String firstName;
private String lastName;
private String emailId;
private String contact;
private String gender;
private String dob;
private String address;
private String country;
private String qualification;
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 setEmailId(String emailId){
this.emailId = emailId;
}
public String getEmailId(){
return emailId;
}
public void setContact(String contact){
this.contact = contact;
}
public String getContact(){
return contact;
}
public void setAddress(String address){
this.address = address;
}
public String getAddress(){
return address;
}
public void setGender(String gender){
this.gender = gender;
}
public String getGender(){
return gender;
}
public void setDob(String dob){
this.dob = dob;
}
public String getDob(){
return dob;
}
public void setCountry(String country){
this.country = country;
}
public String getCountry(){
return country;
}
public void setQualification(String qualification){
this.qualification = qualification;
}
public String getQualification(){
return qualification;
}
}
In step 6:
AWizardFormController.java
package net.roseindia.web;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractWizardFormController;
import org.springframework.web.servlet.view.RedirectView;
import net.roseindia.web.User;
public class AWizardFormController extends AbstractWizardFormController{
@Override
protected ModelAndView processCancel(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
// Logical code
System.out.println("processCancel");
return new ModelAndView(new RedirectView("user1.html"));
}
@Override
protected ModelAndView processFinish(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
// Logical code
System.out.println("processFinish");
return new ModelAndView(new RedirectView("user4.html"));
}
continue..
protected void validatePage(Object command, Errors errors, int page){
User user = (User) command;
if(page == 0){
if(user.getFirstName()==""){
errors.rejectValue("firstName", "error.too-high", null, "First Name cannot be empty.");
}
if(user.getLastName()==""){
errors.rejectValue("lastName", "error.too-high", null, "Last Name cannot be empty.");
}
if(user.getEmailId()==""){
errors.rejectValue("emailId", "error.too-high", null, "EmailId cannot be empty.");
}
if ((user.getEmailId() != "") || (user.getEmailId().length()) != 0) {
Pattern p=Pattern.compile(".+@.+\\.[a-z]+");
Matcher m=p.matcher(user.getEmailId());
boolean b=m.matches();
if(b!=true)
{
errors.rejectValue("emailId", "error.is.not.valid", "Email ID does not Valid ");
}
}
if(user.getContact()==""){
errors.rejectValue("contact", "error.too-high", null, "Contact cannot be empty.");
}
if ((user.getContact() != "") || (user.getContact().length()) != 0) {
Pattern pattern = Pattern.compile("\\d{1}-\\d{4}-\\d{6}");
Matcher matcher = pattern.matcher(user.getContact());
boolean con=matcher.matches();
if(con!=true)
{
errors.rejectValue("contact", "error.is.not.valid", "Enter Contact Number Like 0-9999-999999");
}
}
if(user.getGender()==""){
errors.rejectValue("gender", "error.too-high", null, "Gender cannot be empty.");
}
}
if(page == 1){
if(user.getDob()==""){
errors.rejectValue("dob", "error.too-high", null, "Date of birth cannot be empty.");
}
if ((user.getDob() != "") || (user.getDob().length()) != 0) {
Pattern pattern = Pattern.compile("\\d{2}/\\d{2}/\\d{4}");
Matcher matcher = pattern.matcher(user.getDob());
boolean DOB=matcher.matches();
if(DOB!=true)
{
errors.rejectValue("dob", "error.is.not.valid", "Enter Date of birth Like 01/02/1986 ");
}
}
if(user.getAddress()==""){
errors.rejectValue("address", "error.too-high", null, "Address cannot be empty.");
}
if(user.getCountry()==""){
errors.rejectValue("country", "error.too-high", null, "Country cannot be empty.");
}
if(user.getQualification()==""){
errors.rejectValue("qualification", "error.too-high", null, "Qualification cannot be empty.");
}
}
}
}
Thank you deepak its working well.