Advertisement
hsianghui

IS3106 Lab4 Exercise 2.2 (CustomerManagedBean.java)

Sep 14th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. package managedbean;
  2.  
  3. import entity.Customer;
  4. import java.util.Date;
  5. import java.util.List;
  6. import javax.annotation.PostConstruct;
  7. import javax.ejb.EJB;
  8. import javax.faces.bean.ManagedBean;
  9. import javax.faces.bean.RequestScoped;
  10. import javax.faces.event.ActionEvent;
  11. import session.CustomerSessionLocal;
  12.  
  13.  
  14. @ManagedBean
  15. @RequestScoped
  16. public class CustomerManagedBean {
  17.     @EJB
  18.     CustomerSessionLocal customerSessionLocal;
  19.    
  20.     private String name;
  21.     private byte gender;
  22.     private Date dob;
  23.     private List<Customer> customers;
  24.    
  25.     public CustomerManagedBean() {
  26.     }
  27.    
  28.     @PostConstruct
  29.     public void init(){
  30.         setCustomers(customerSessionLocal.searchCustomers(""));
  31.     } //end init
  32.    
  33.     public void addCustomer(ActionEvent evt){
  34.         Customer c = new Customer();
  35.         c.setName(name);
  36.         c.setGender(gender);
  37.         c.setDob(dob);
  38.         c.setCreated(new Date());
  39.  
  40.         customerSessionLocal.createCustomer(c);
  41.     } //end addCustomer
  42.  
  43.     /**
  44.      * @return the name
  45.      */
  46.     public String getName() {
  47.         return name;
  48.     }
  49.  
  50.     /**
  51.      * @param name the name to set
  52.      */
  53.     public void setName(String name) {
  54.         this.name = name;
  55.     }
  56.  
  57.     /**
  58.      * @return the gender
  59.      */
  60.     public byte getGender() {
  61.         return gender;
  62.     }
  63.  
  64.     /**
  65.      * @param gender the gender to set
  66.      */
  67.     public void setGender(byte gender) {
  68.         this.gender = gender;
  69.     }
  70.  
  71.     /**
  72.      * @return the dob
  73.      */
  74.     public Date getDob() {
  75.         return dob;
  76.     }
  77.  
  78.     /**
  79.      * @param dob the dob to set
  80.      */
  81.     public void setDob(Date dob) {
  82.         this.dob = dob;
  83.     }
  84.  
  85.     /**
  86.      * @return the customers
  87.      */
  88.     public List<Customer> getCustomers() {
  89.         return customers;
  90.     }
  91.  
  92.     /**
  93.      * @param customers the customers to set
  94.      */
  95.     public void setCustomers(List<Customer> customers) {
  96.         this.customers = customers;
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement