Creating a command or form-backing object

POJO is short for Plain Old Java Object. It is generally used to represent a bean following the typical JavaBean conventions. Typically, it contains private member variables with getters and setters and a no-argument constructor.

A form-backing Object is used to represent the values entered/shown by/to the user in a form. Model is used to populate data used to render a View—select boxes, option buttons, and so on.

We will create a simple POJO to act as a command object. Important parts of the class are listed as follows:

    public class User { 
private String guid;
private String name;
private String userId;
private String password;
private String password2;
//Constructor
//Getters and Setters
//toString
}

We are going to capture nameuser ID, and password in the form. In the preceding class, we have fields corresponding to each of them, along with a password confirmation field, password2, and a unique identifier field, guid.

The Constructorgetterssetters, and toString methods are not shown for brevity. This class does not have any annotations or Spring-related mappings. Any bean can act as a form-backing object.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset