*Screams into the void*
This commit is contained in:
parent
a7c5929537
commit
ee8de8e7e5
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,17 @@ import java.util.List;
|
||||
*/
|
||||
public class Company implements EmployeeInterface {
|
||||
private List<Employee> employeeList;
|
||||
private List<Employee> deletedEmployeeList;
|
||||
|
||||
public List<Employee> getDeletedEmployeeList()
|
||||
{
|
||||
return deletedEmployeeList;
|
||||
}
|
||||
|
||||
public void setDeletedEmployeeList(List<Employee> deletedEmployeeList)
|
||||
{
|
||||
this.deletedEmployeeList = deletedEmployeeList;
|
||||
}
|
||||
|
||||
public Company(List<Employee> employeeList)
|
||||
{
|
||||
@ -20,15 +31,17 @@ private List<Employee> employeeList;
|
||||
}
|
||||
public Company() {
|
||||
employeeList = new ArrayList<Employee>();
|
||||
deletedEmployeeList = new ArrayList<Employee>();
|
||||
}
|
||||
|
||||
@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<Employee> getEmployees(){return employeeList;}
|
||||
public List<Employee> getDeletedEmployees(){return deletedEmployeeList;}
|
||||
|
||||
}
|
||||
|
@ -14,4 +14,5 @@ public interface EmployeeInterface {
|
||||
boolean insertEmployee(Employee e);
|
||||
boolean removeEmployee(Employee e);
|
||||
List<Employee> getEmployees();
|
||||
List<Employee> getDeletedEmployees();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
<h:head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<title>Validating Data</title>
|
||||
<h:outputStylesheet name="css/1.css"/>
|
||||
</h:head>
|
||||
<h:body>
|
||||
<h:form id="employeeForm">
|
||||
@ -48,20 +49,20 @@
|
||||
|
||||
<h:outputLabel for="employeeFirst" value="First:" />
|
||||
<h:inputText id="employeeFirst"
|
||||
value="#{employeeController.employeeFirst}">
|
||||
value="#{employeeController.employeeFirst}" disabled="#{employeeController.validateInsertion}">
|
||||
<f:validateLength minimum="3" maximum="30"/>
|
||||
</h:inputText>
|
||||
<h:message for="employeeFirst" errorStyle="color:red"/>
|
||||
|
||||
<h:outputLabel for="employeeLast" value="Last: " />
|
||||
<h:inputText id="employeeLast" value="#{employeeController.employeeLast}">
|
||||
<h:inputText id="employeeLast" value="#{employeeController.employeeLast}" disabled="#{employeeController.validateInsertion}">
|
||||
<f:validateLength minimum="3" maximum="30"/>
|
||||
</h:inputText>
|
||||
<h:message for="employeeLast" errorStyle="color:red"/>
|
||||
|
||||
<h:outputLabel for="employeeTitle" value="Title (Must be a Java Position): " />
|
||||
<h:inputText id="employeeTitle" value="#{employeeController.employeeTitle}">
|
||||
<f:validator validatorId="employeeTitleValidate" />
|
||||
<f:validator validatorId="employeeTitleValidate" disabled="#{employeeController.validateInsertion}"/>
|
||||
</h:inputText>
|
||||
<h:message for="employeeTitle" errorStyle="color:red"/>
|
||||
|
||||
@ -75,8 +76,8 @@
|
||||
|
||||
</h:column>
|
||||
|
||||
<h:column style="vertical-align: top;">
|
||||
<h1>Delete Information</h1>
|
||||
<h:column>
|
||||
<h1>Delete Employee Information</h1>
|
||||
<br/>
|
||||
<h:messages globalOnly="true" errorStyle="color: red"
|
||||
infoStyle="color: green"/>
|
||||
@ -84,8 +85,8 @@
|
||||
<h:dataTable id="DeleteTable"
|
||||
var="emp"
|
||||
border="1"
|
||||
value=""
|
||||
rendered="">
|
||||
value="#{employeeController.company.getDeletedEmployees()}"
|
||||
rendered="#{employeeController.company.getDeletedEmployees().size() > 0}">
|
||||
|
||||
<f:facet name="header">
|
||||
Deleted Employees
|
||||
@ -104,7 +105,7 @@
|
||||
|
||||
<h:outputLabel for="employeeLastToDelete" value="Last: " />
|
||||
<h:inputText id="employeeLastToDelete" value="#{employeeController.employeeLast}">
|
||||
<f:validateLength minimum="3" maximum="30"/>
|
||||
<f:validateLength minimum="3" maximum="30" disabled="#{!employeeController.validateInsertion}"/>
|
||||
</h:inputText>
|
||||
<h:message for="employeeLastToDelete" errorStyle="color:red"/>
|
||||
|
||||
@ -114,13 +115,13 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h:commandButton id="delete"
|
||||
action="#{employeeController.delete}"
|
||||
value="Delete Employee"/>
|
||||
</h:column>
|
||||
|
||||
</h:panelGrid>
|
||||
<h:commandButton id="delete"
|
||||
action="#{employeeController.delete}"
|
||||
value="Delete Employee"/>
|
||||
|
||||
|
||||
</h:form>
|
||||
</h:body>
|
||||
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user