abstract wizard form controller

abstract wizard form controller

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

View Answers

July 22, 2011 at 4:57 PM

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>

July 22, 2011 at 4:58 PM

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>

July 22, 2011 at 4:59 PM

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

July 22, 2011 at 5:01 PM

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"));

    }

July 22, 2011 at 5:02 PM

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.");              
                }
            }
        }
    }

July 22, 2011 at 5:34 PM

Thank you deepak its working well.









Related Tutorials/Questions & Answers:
abstract wizard form controller
abstract wizard form controller  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
Simple Form Controller Example
Example of using Simple Form Controller Page 2 In this page we... the previous page check it at Example of using Simple Form Controller Step 7... the project src folder to validate the wrong data entry in the user.jsp form fields
Advertisements
Null value when i set interface object in form controller - Spring
Null value when i set interface object in form controller   Hi all... interface object in form Controller. public void setOHBillManager(OHBillManager.... when i call this method in form controller ohbillManager.saveBill(ohbill); i
controller
; import com.dao.*; /** * Servlet implementation class Controller */ public class Controller extends HttpServlet { private static final long serialVersionUID...#HttpServlet() */ public Controller() { super(); // TODO Auto
ModuleNotFoundError: No module named 'wizard'
ModuleNotFoundError: No module named 'wizard'  Hi, My Python... 'wizard' How to remove the ModuleNotFoundError: No module named 'wizard'... to install padas library. You can install wizard python with following command
abstract class
abstract class  Can there be an abstract class with no abstract methods
abstract method
abstract method  Can we have abstract class with no abstract methods
Abstract class
Abstract class  Can an abstract class be final
Abstract class
Abstract class  what is an Abstract class
abstract method
abstract method  is final method is in abstract class
Controller in Spring
Controller in Spring  Hello Sir please help that how to write Controller in Spring web thanks in advance   Hi you can write the Spring Controller by extending the abstract class AbstractController or by using
abstract method
abstract method  Can a concrete class have an abstract method
Abstract and Interface
Abstract and Interface  what is the difference between Abstract and Interface accurateatly
abstract class
abstract class   Explain the concept of abstract class and it?s use with a sample program.   Java Abstract Class An abstract class is a class that is declared by using the abstract keyword. It may or may not have
Abstract class
Abstract class  j   An Abstract class is a base class which... with an abstract keyword. For more information, visit the following links: http://www.roseindia.net/help/java/a/java-abstract-class.shtml http://www.roseindia.net/java
abstract class
abstract class  abstract class AbstractClass{ } is possible and compile the class or any compile time error occur tell me the answer Blockquote
abstract class
abstract class  what is abstract class .why we use it or what is the need of this class?   Abstract class is like base class which contains abstract method and cannot instantiated.   Please go through
form
form   Can I prevent a form from being submitted again
Demonstrates Wizard
WizardPage implements the wizard pages. In the NamePage, we have create a form... Demonstrates Wizard       This section illustrates you how to implement the wizard. In SWT
Abstract class
Abstract class  Calendar cal=Calendar.getInstance() We know that Calendar is an abstract class so it can't be instantiated. So how we can say that cal is an instance of Calendar??? Beginner Question I suppose. Thanks in advace
ModuleNotFoundError: No module named 'djangoproject_wizard'
ModuleNotFoundError: No module named 'djangoproject_wizard'  Hi...: No module named 'djangoproject_wizard' How to remove the ModuleNotFoundError: No module named 'djangoproject_wizard' error? Thanks   Hi
ModuleNotFoundError: No module named 'kinto-wizard'
ModuleNotFoundError: No module named 'kinto-wizard'  Hi, My Python... 'kinto-wizard' How to remove the ModuleNotFoundError: No module named 'kinto-wizard' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'wizard_interface'
ModuleNotFoundError: No module named 'wizard_interface'  Hi, My... named 'wizard_interface' How to remove the ModuleNotFoundError: No module named 'wizard_interface' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'data-wizard'
ModuleNotFoundError: No module named 'data-wizard'  Hi, My Python... 'data-wizard' How to remove the ModuleNotFoundError: No module named 'data-wizard' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'djangoproject_wizard'
ModuleNotFoundError: No module named 'djangoproject_wizard'  Hi...: No module named 'djangoproject_wizard' How to remove the ModuleNotFoundError: No module named 'djangoproject_wizard' error? Thanks   Hi
ModuleNotFoundError: No module named 'Flask-Wizard'
ModuleNotFoundError: No module named 'Flask-Wizard'  Hi, My Python... 'Flask-Wizard' How to remove the ModuleNotFoundError: No module named 'Flask-Wizard' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pdf-wizard'
ModuleNotFoundError: No module named 'pdf-wizard'  Hi, My Python... 'pdf-wizard' How to remove the ModuleNotFoundError: No module named 'pdf-wizard' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'xud-wizard'
ModuleNotFoundError: No module named 'xud-wizard'  Hi, My Python... 'xud-wizard' How to remove the ModuleNotFoundError: No module named 'xud-wizard' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'django-wizard'
ModuleNotFoundError: No module named 'django-wizard'  Hi, My... 'django-wizard' How to remove the ModuleNotFoundError: No module named 'django-wizard' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Flask-Wizard'
ModuleNotFoundError: No module named 'Flask-Wizard'  Hi, My Python... 'Flask-Wizard' How to remove the ModuleNotFoundError: No module named 'Flask-Wizard' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'kinto-wizard'
ModuleNotFoundError: No module named 'kinto-wizard'  Hi, My Python... 'kinto-wizard' How to remove the ModuleNotFoundError: No module named 'kinto-wizard' error? Thanks   Hi, In your python
Abstract and Interface
Abstract and Interface  What is interface? When time is most suitable for using interface? Why we use interface instead of abstract? What is the differences between abstract and interface?   An interface defines a set
Abstract class and abstract method
Some key points about abstract methods are as following An abstract modifier identifies abstract classes and methods An abstract methods cannot be private because it defined in the other class. An abstract methods cannot
variables and methods declared in abstract class is abstract or not
variables and methods declared in abstract class is abstract or not  variables and methods declared in abstract class is abstract
Spring Controller
Spring Controller  How to handle form request coming on the Spring Controller ?   Hi Please write the controller as for handling form... the @Controller annotation before the class declaration
code for abstract class
code for abstract class  code for abstract class
An Abstract class may or may not have abstract method.
Description: An Abstract is also known as Abstract Base Class. Abstract Class... declaration is done in its derived class not in the abstract class. Abstract itself... Description: In this example you are going to see that there is abstract class
Abstract class,Abstract methods and classes
Abstract methods and classes     ... so many times the word abstract. In java programming language the word abstract is used with methods and classes.  Abstract MethodADS_TO_REPLACE_1
Method wizard
Method wizard      ... a wizard to create new methods in a class through a guided dialog. You can select... is inspired by the wizard in VisualAge which was no longer provided in Eclipse/WSAD
What is an abstract class?
What is an abstract class?  What is an abstract class
Java abstract class
Java abstract class  Can an abstract class be final
what is the meaning of abstract?
what is the meaning of abstract?  what is the meaning of abstract
What is an abstract method?
What is an abstract method?   Hi, What is an abstract method? thanks
Why Abstract Class?
Why Abstract Class?  What is the use of Abstract Class if it has Zero Abstract methods
Why Abstract Class?
Why Abstract Class?  What is the use of Abstract Class if it has Zero Abstract methods
Java Abstract Class
Java Abstract Class       An abstract class is a class that is declared by using the abstract keyword. It may or may not have abstract methods. Abstract classes cannot be instantiated
Version of maven>maven-wizard-plugin dependency
List of Version of maven>maven-wizard-plugin dependency
Version of com.networkedassets>webapp-installation-wizard dependency
List of Version of com.networkedassets>webapp-installation-wizard dependency
ModuleNotFoundError: No module named 'btc-simple-wizard'
ModuleNotFoundError: No module named 'btc-simple-wizard'  Hi, My... named 'btc-simple-wizard' How to remove the ModuleNotFoundError: No module named 'btc-simple-wizard' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-time-wizard'
ModuleNotFoundError: No module named 'django-time-wizard'  Hi, My... named 'django-time-wizard' How to remove the ModuleNotFoundError: No module named 'django-time-wizard' error? Thanks   Hi, In your

Ads