Home Answers Viewqa Spring abstract wizard form controller

 
 


mazeed
abstract wizard form controller
6 Answer(s)      a year and 10 months ago
Posted in : Spring

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 Pages:
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
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
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
Simple Form Controller Example
Example of using Simple Form Controller Page 2 In this page we... it at Example of using Simple Form Controller Step 7: Now we... the wrong data entry in the user.jsp form fields by the user. The code
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
controller
; import com.dao.*; /** * Servlet implementation class Controller */ public class Controller extends HttpServlet { private static final long serialVersionUID...#HttpServlet() */ public Controller() { super(); // TODO Auto
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 Annotation Example in Spring 3
@Controller Annotation Example in Spring 3: In this section we will see how we can create annoted controller class in Spring 3. You can @Controller annotation in the Java class to make it controller. In this tutorial we are creating
Understanding Struts Controller
Understanding Struts Controller       In this section I will describe you the Controller.... It is the Controller part of the Struts Framework. ActionServlet is configured
Why Controller in j2ee - Servlet Interview Questions
Why Controller in j2ee  Hi, Why controller(servlet) used in j2ee web application.what happens if no controller. Thank u in advance  Hi Friend, In MVC framework,the role of controller is very important.It centralizes
An Abstract class may or may not have abstract method.
of abstract method baseMethod1() baseMethod2() method called form BaseAbstractClass...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
Abstract class or methods example-1
;printAnimal() method called form  * BuzzwordAnimal 
AbstractWizardFormCOntroller Example
AbstractWizardFormController class that handle wizard form. In this tutorial, we will used... the navigation between pages and validate the user input data form a single page... this controller. Step 1: Now we will create a index.jsp inside the WebContent folder
AbstractWizardFormCOntroller Example
the controller by set the bean properties with urlMapping like: <...;/bean> After that we have set bean for this controller and set...; The pages property has a list of pages to participate in the wizard type
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
tabbar controller
tabbar controller  how change the tabbar controller and how we maintain the view controller of second tabbar controller
Filter/Controller
Filter/Controller  what is the difference b/w org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter and org.apache.struts2.dispatcher.FilterDispatcher. which of the above is really used as controller and which
Spring MVC Controller hierarchy
extends the abstract controller provided by the framework and writes the business... in the Controller.  Spring MVC provides many abstract controllers, which.... The main components involved are DispatcherServlet, Controller and Views
abstract method
abstract method  Can we have abstract class with no abstract methods
abstract class
abstract class  Can there be an abstract class with no abstract methods
Abstract class
Abstract class  what is an Abstract class
Abstract class
Abstract class  Can an abstract class be final
abstract method
abstract method  is final method is in abstract class
Pass message controller to viiew with the help of Model in Spring 3
Pass message from Controller to View with help of Model in Spring 3.0... from controller to the view layer. For example, if the class or view validator not include in the controller class in the spring 3.0 application and you want
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
Simple Form Controlle Example
Simple Form Controlle Example      ... provides SimpleFromController for control a form data in the web application. If you want to handle form in spring then you need to use SimpleFormController
Form Handling in Spring Framework
Form Handling in Spring Framework  I have created spring project.I created the form. When I entered the values to the form, the values should be printe in another web page. I created pojo and respective controller. When I run
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
front controller - JSP-Servlet
front controller  How to implement front controller in a web application
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
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
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
@Controller annotation for defining new controller
In this section, you will learn about @Controller annotation for defining new controllers
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
previous view controller
controller in UINavigationController?   Generally, UINavigationController... to go back to the previous view controller. See the example given below.. UINavigationController But in case if you have more then one root view controller
Iphone Tab Bar Controller
Iphone Tab Bar Controller  Hi, I am very new in mobile application programming. So, how can i create iphone tab bar controller apps. Please suggest me any online help, so that i will enhance my technical skill in mobile web
JQuery as validation controller
JQuery as validation controller  I would love to use JQuery as validation controller but i don't know how i use.Could u help me?   Here is a link that will provide you an example of validating email using jquery
why servlet as controller - Struts
why servlet as controller   Hi Friends, Main reasons for using servlet as a controller in struts. why not jsp . Thanks Prakash  Hi... to generate the proper user response. So Servlet is used as controller. Thanks
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
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 Method An abstract method one
code for abstract class
code for abstract class  code for abstract class
clearing text field in spring form
clearing text field in spring form  hi, I have spring form in that i... submitted form with errors the answers text field value should be clear, for this i am using controller at back end and one jsp as front end at backend i am able
form
form   Can I prevent a form from being submitted again
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.