Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training Big Data and Hadoop Training Java Training  
 

abstract wizard form controller

Ads

 
 

Share on Google+Share on Google+

mazeed
abstract wizard form controller
6 Answer(s)      6 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....

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


Ads









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
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
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
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
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  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
tabbar controller
tabbar controller  how change the tabbar controller and how we maintain the view controller of second tabbar controller
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
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
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
Version of com.networkedassets>webapp-installation-wizard dependency
List of Version of com.networkedassets>webapp-installation-wizard dependency
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
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
form
form   Can I prevent a form from being submitted again
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
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
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
Version of com.jolira>wicket-guicy-wizard-parent dependency
List of Version of com.jolira>wicket-guicy-wizard-parent dependency
code for abstract class
code for abstract class  code for abstract class