-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployeeBean.java
More file actions
121 lines (104 loc) · 2.8 KB
/
EmployeeBean.java
File metadata and controls
121 lines (104 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.javaee7.jsf;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import org.javaee7.entity.Employee;
import org.javaee7.jpa.session.EmployeeSession;
/**
*
* @author Juneau
*/
@ManagedBean(name = "employeeBean")
@SessionScoped
public class EmployeeBean implements Serializable {
@EJB
EmployeeSession employeeSession;
private Employee employee;
private String firstName;
private String lastName;
private String status;
/**
* Creates a new instance of EmployeeBean
*/
public EmployeeBean() {
}
public List activeEmployeeCount(){
return employeeSession.obtainActiveEmployeeCount();
}
/**
* Calls stored procedure to insert record into EMPLOYEE table
*/
public String createEmployee(){
boolean result = false;
result = employeeSession.createEmp(employee.getFirst(), employee.getLast(), employee.getStatus());
if (result){
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_INFO, "Employee Successfully Created",
"Employee Successfully Created"));
} else {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_ERROR, "Employee Not created, see server log for details.",
"Employee not created, see server log for details."));
}
return null;
}
/**
* @return the employee
*/
public Employee getEmployee() {
if (employee == null){
employee = new Employee();
}
return employee;
}
/**
* @param employee the employee to set
*/
public void setEmployee(Employee employee) {
this.employee = employee;
}
/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}
/**
* @param firstName the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @return the lastName
*/
public String getLastName() {
return lastName;
}
/**
* @param lastName the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(String status) {
this.status = status;
}
}