Package com.mkyong

Source Code of com.mkyong.CustomerBean

package com.mkyong;

import java.io.Serializable;
import java.util.List;

import com.mkyong.customer.bo.CustomerBo;
import com.mkyong.customer.model.Customer;

public class CustomerBean implements Serializable{
  //DI via Spring
  CustomerBo customerBo;
 
  public String name;
  public String address;
 
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getAddress() {
    return address;
  }

  public void setAddress(String address) {
    this.address = address;
  }

  public void setCustomerBo(CustomerBo customerBo) {
    this.customerBo = customerBo;
  }
  //get all customer data from database
  public List<Customer> getCustomerList(){
    return customerBo.findAllCustomer();
  }
 
  //add a new customer data into database
  public String addCustomer(){
   
    Customer cust = new Customer();
    cust.setName(getName());
    cust.setAddress(getAddress());
   
    customerBo.addCustomer(cust);
   
    clearForm();
   
    return "";
  }
 
  //clear form values
  private void clearForm(){
    setName("");
    setAddress("");
  }
 
}
TOP

Related Classes of com.mkyong.CustomerBean

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.