Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Spring abstract wizard form controller

Have Programming Question? Ask it here!
 
 
 


mazeed
abstract wizard form controller
6 Answer(s)      3 years and a month 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....


Advertisement
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... 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
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
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
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
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
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
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 method
abstract method  is final method is in abstract class
Abstract class
Abstract class  what is an Abstract class
Abstract class
Abstract class  Can an abstract class be final
Abstract and Interface
Abstract and Interface  what is the difference between Abstract and Interface accurateatly
abstract method
abstract method  Can a concrete class have an abstract method
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
front controller - JSP-Servlet
front controller  How to implement front controller in a web application
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
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
@Controller annotation for defining new controller
In this section, you will learn about @Controller annotation for defining new controllers
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
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
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
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
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
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
form
form   Can I prevent a form from being submitted again
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
what is the meaning of abstract?
what is the meaning of abstract?  what is the meaning of abstract
Java abstract class
Java abstract class  Can an abstract class be final
What is an abstract method?
What is an abstract method?   Hi, What is an abstract method? thanks
What is an abstract class?
What is an abstract class?  What is an abstract class
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
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
@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
Interface vs abstract class
Interface vs abstract class  Hai, Is there any possible to defining abstract methods in Interface
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
abstract method in php - PHP
abstract method in php  How do i implement the abstract method in php? Which is the best way
Abstract programs - Java Beginners
Abstract programs  give me the Abstract Methods programms and defind the Abstract Method and Abstract Class  Hi friend, This code will help you. abstract class A{ public abstract abs_value
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
 

 

 

DMCA.com