Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@arthurportas
Created May 8, 2017 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurportas/0a2e6bfc8f834144a14cbc47f025d4dd to your computer and use it in GitHub Desktop.
Save arthurportas/0a2e6bfc8f834144a14cbc47f025d4dd to your computer and use it in GitHub Desktop.
Backing Bean for Employee
package com.arthurportas.presentation.backingbeans;
import com.arthurportas.entities.Employee;
import com.arthurportas.services.EmployeeService;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import java.io.Serializable;
/**
* Created by arthurportas on 29/04/2017.
*/
@ManagedBean
@RequestScoped
public class EmployeeBean implements Serializable {
private String firstName;
private String lastName;
private Employee employee;
private String value;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String save() {
Employee employee = new Employee();
employee.setFirstName(this.firstName);
employee.setLastName(this.lastName);
this.employee = getEmployeeService().create(employee);
return "new-employee-result.xhtml";
}
public String search() {
this.employee = getEmployeeService().findbyName(this.value);
return "search-employee-result.xhtml";
}
private EmployeeService getEmployeeService() {
return new EmployeeService();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment