From ee8de8e7e5c3b983b9cf2a8aa269a4d0e2c77b00 Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Fri, 29 Sep 2023 13:34:12 -0500 Subject: [PATCH] *Screams into the void* --- .../main/java/beans/EmployeeController.java | 28 +++++++++++++++++-- .../src/main/java/bl/Company.java | 15 +++++++++- .../src/main/java/bl/EmployeeInterface.java | 1 + .../src/main/webapp/index.xhtml | 25 +++++++++-------- .../src/main/webapp/resources/css/1.css | 16 +++++++++++ 5 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/webapp/resources/css/1.css diff --git a/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/beans/EmployeeController.java b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/beans/EmployeeController.java index 5c2e78d..010c402 100644 --- a/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/beans/EmployeeController.java +++ b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/beans/EmployeeController.java @@ -25,6 +25,18 @@ public class EmployeeController implements Serializable { private String employeeLast; private String employeeTitle; + private boolean validateInsertion; + + /** + * Get the value of validateInsertion + * + * @return the value of validateInsertion + */ + public boolean isValidateInsertion() + { + return validateInsertion; + } + private EmployeeInterface company; public EmployeeController() @@ -105,6 +117,7 @@ public class EmployeeController implements Serializable { this.employeeFirst = employeeFirst; } public void insert() { + this.validateInsertion = true; boolean b = company.insertEmployee(new Employee(this.employeeFirst, this.getEmployeeLast(), this.employeeTitle, "1.png") ); @@ -121,8 +134,19 @@ public class EmployeeController implements Serializable { FacesContext.getCurrentInstance().addMessage(null, facesMsg); } } - public void remove() { - + public void delete() { + this.validateInsertion = false; + boolean de = false; + FacesMessage facesMsg = null; + for (int i = 0; i < company.getEmployees().size(); ++i) { + if (company.getEmployees().get(i).getEmployeeLast().toLowerCase().equals(this.getEmployeeLast().toLowerCase())) { + Employee employeeToDelete = company.getEmployees().get(i); + company.getDeletedEmployees().add(employeeToDelete); + company.removeEmployee(employeeToDelete); + facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, + "Employee Successfully Deleted", null); + } + } } } diff --git a/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/bl/Company.java b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/bl/Company.java index c3c3390..9f46d68 100644 --- a/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/bl/Company.java +++ b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/bl/Company.java @@ -13,6 +13,17 @@ import java.util.List; */ public class Company implements EmployeeInterface { private List employeeList; +private List deletedEmployeeList; + + public List getDeletedEmployeeList() + { + return deletedEmployeeList; + } + + public void setDeletedEmployeeList(List deletedEmployeeList) + { + this.deletedEmployeeList = deletedEmployeeList; + } public Company(List employeeList) { @@ -20,15 +31,17 @@ private List employeeList; } public Company() { employeeList = new ArrayList(); + deletedEmployeeList = new ArrayList(); } @Override public boolean insertEmployee(Employee e){return employeeList.add( e ); } @Override - public boolean removeEmployee(Employee e){throw new UnsupportedOperationException("Not supported yet."); } + public boolean removeEmployee(Employee e){return employeeList.remove(e); } @Override public List getEmployees(){return employeeList;} + public List getDeletedEmployees(){return deletedEmployeeList;} } diff --git a/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/bl/EmployeeInterface.java b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/bl/EmployeeInterface.java index 5b3a1cd..7ea79fa 100644 --- a/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/bl/EmployeeInterface.java +++ b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/bl/EmployeeInterface.java @@ -14,4 +14,5 @@ public interface EmployeeInterface { boolean insertEmployee(Employee e); boolean removeEmployee(Employee e); List getEmployees(); + List getDeletedEmployees(); } diff --git a/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/webapp/index.xhtml b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/webapp/index.xhtml index dfbfaa5..6d9eddd 100644 --- a/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/webapp/index.xhtml +++ b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/webapp/index.xhtml @@ -6,6 +6,7 @@ Validating Data + @@ -48,20 +49,20 @@ + value="#{employeeController.employeeFirst}" disabled="#{employeeController.validateInsertion}"> - + - + @@ -75,8 +76,8 @@ - -

Delete Information

+ +

Delete Employee Information


@@ -84,8 +85,8 @@ + value="#{employeeController.company.getDeletedEmployees()}" + rendered="#{employeeController.company.getDeletedEmployees().size() > 0}"> Deleted Employees @@ -104,7 +105,7 @@ - + @@ -114,13 +115,13 @@ - +
- +
diff --git a/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/webapp/resources/css/1.css b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/webapp/resources/css/1.css new file mode 100644 index 0000000..d9ac305 --- /dev/null +++ b/Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/webapp/resources/css/1.css @@ -0,0 +1,16 @@ +/* +Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license +Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/CascadeStyleSheet.css to edit this template +*/ +/* + Created on : Sep 29, 2023, 9:44:03 AM + Author : caleb +*/ + +td { + vertical-align: top; + padding-top: 10px; + padding-bottom: 20px; + padding-left: 30px; + padding-right: 40px; +} \ No newline at end of file