*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 employeeLast;
|
||||||
private String employeeTitle;
|
private String employeeTitle;
|
||||||
|
|
||||||
|
private boolean validateInsertion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of validateInsertion
|
||||||
|
*
|
||||||
|
* @return the value of validateInsertion
|
||||||
|
*/
|
||||||
|
public boolean isValidateInsertion()
|
||||||
|
{
|
||||||
|
return validateInsertion;
|
||||||
|
}
|
||||||
|
|
||||||
private EmployeeInterface company;
|
private EmployeeInterface company;
|
||||||
|
|
||||||
public EmployeeController()
|
public EmployeeController()
|
||||||
@ -105,6 +117,7 @@ public class EmployeeController implements Serializable {
|
|||||||
this.employeeFirst = employeeFirst;
|
this.employeeFirst = employeeFirst;
|
||||||
}
|
}
|
||||||
public void insert() {
|
public void insert() {
|
||||||
|
this.validateInsertion = true;
|
||||||
boolean b = company.insertEmployee(new Employee(this.employeeFirst,
|
boolean b = company.insertEmployee(new Employee(this.employeeFirst,
|
||||||
this.getEmployeeLast(), this.employeeTitle, "1.png")
|
this.getEmployeeLast(), this.employeeTitle, "1.png")
|
||||||
);
|
);
|
||||||
@ -121,8 +134,19 @@ public class EmployeeController implements Serializable {
|
|||||||
FacesContext.getCurrentInstance().addMessage(null, facesMsg);
|
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 {
|
public class Company implements EmployeeInterface {
|
||||||
private List<Employee> employeeList;
|
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)
|
public Company(List<Employee> employeeList)
|
||||||
{
|
{
|
||||||
@ -20,15 +31,17 @@ private List<Employee> employeeList;
|
|||||||
}
|
}
|
||||||
public Company() {
|
public Company() {
|
||||||
employeeList = new ArrayList<Employee>();
|
employeeList = new ArrayList<Employee>();
|
||||||
|
deletedEmployeeList = new ArrayList<Employee>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean insertEmployee(Employee e){return employeeList.add( e ); }
|
public boolean insertEmployee(Employee e){return employeeList.add( e ); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeEmployee(Employee e){throw new UnsupportedOperationException("Not supported yet."); }
|
public boolean removeEmployee(Employee e){return employeeList.remove(e); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Employee> getEmployees(){return employeeList;}
|
public List<Employee> getEmployees(){return employeeList;}
|
||||||
|
public List<Employee> getDeletedEmployees(){return deletedEmployeeList;}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,4 +14,5 @@ public interface EmployeeInterface {
|
|||||||
boolean insertEmployee(Employee e);
|
boolean insertEmployee(Employee e);
|
||||||
boolean removeEmployee(Employee e);
|
boolean removeEmployee(Employee e);
|
||||||
List<Employee> getEmployees();
|
List<Employee> getEmployees();
|
||||||
|
List<Employee> getDeletedEmployees();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<h:head>
|
<h:head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
<title>Validating Data</title>
|
<title>Validating Data</title>
|
||||||
|
<h:outputStylesheet name="css/1.css"/>
|
||||||
</h:head>
|
</h:head>
|
||||||
<h:body>
|
<h:body>
|
||||||
<h:form id="employeeForm">
|
<h:form id="employeeForm">
|
||||||
@ -48,20 +49,20 @@
|
|||||||
|
|
||||||
<h:outputLabel for="employeeFirst" value="First:" />
|
<h:outputLabel for="employeeFirst" value="First:" />
|
||||||
<h:inputText id="employeeFirst"
|
<h:inputText id="employeeFirst"
|
||||||
value="#{employeeController.employeeFirst}">
|
value="#{employeeController.employeeFirst}" disabled="#{employeeController.validateInsertion}">
|
||||||
<f:validateLength minimum="3" maximum="30"/>
|
<f:validateLength minimum="3" maximum="30"/>
|
||||||
</h:inputText>
|
</h:inputText>
|
||||||
<h:message for="employeeFirst" errorStyle="color:red"/>
|
<h:message for="employeeFirst" errorStyle="color:red"/>
|
||||||
|
|
||||||
<h:outputLabel for="employeeLast" value="Last: " />
|
<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"/>
|
<f:validateLength minimum="3" maximum="30"/>
|
||||||
</h:inputText>
|
</h:inputText>
|
||||||
<h:message for="employeeLast" errorStyle="color:red"/>
|
<h:message for="employeeLast" errorStyle="color:red"/>
|
||||||
|
|
||||||
<h:outputLabel for="employeeTitle" value="Title (Must be a Java Position): " />
|
<h:outputLabel for="employeeTitle" value="Title (Must be a Java Position): " />
|
||||||
<h:inputText id="employeeTitle" value="#{employeeController.employeeTitle}">
|
<h:inputText id="employeeTitle" value="#{employeeController.employeeTitle}">
|
||||||
<f:validator validatorId="employeeTitleValidate" />
|
<f:validator validatorId="employeeTitleValidate" disabled="#{employeeController.validateInsertion}"/>
|
||||||
</h:inputText>
|
</h:inputText>
|
||||||
<h:message for="employeeTitle" errorStyle="color:red"/>
|
<h:message for="employeeTitle" errorStyle="color:red"/>
|
||||||
|
|
||||||
@ -75,8 +76,8 @@
|
|||||||
|
|
||||||
</h:column>
|
</h:column>
|
||||||
|
|
||||||
<h:column style="vertical-align: top;">
|
<h:column>
|
||||||
<h1>Delete Information</h1>
|
<h1>Delete Employee Information</h1>
|
||||||
<br/>
|
<br/>
|
||||||
<h:messages globalOnly="true" errorStyle="color: red"
|
<h:messages globalOnly="true" errorStyle="color: red"
|
||||||
infoStyle="color: green"/>
|
infoStyle="color: green"/>
|
||||||
@ -84,8 +85,8 @@
|
|||||||
<h:dataTable id="DeleteTable"
|
<h:dataTable id="DeleteTable"
|
||||||
var="emp"
|
var="emp"
|
||||||
border="1"
|
border="1"
|
||||||
value=""
|
value="#{employeeController.company.getDeletedEmployees()}"
|
||||||
rendered="">
|
rendered="#{employeeController.company.getDeletedEmployees().size() > 0}">
|
||||||
|
|
||||||
<f:facet name="header">
|
<f:facet name="header">
|
||||||
Deleted Employees
|
Deleted Employees
|
||||||
@ -104,7 +105,7 @@
|
|||||||
|
|
||||||
<h:outputLabel for="employeeLastToDelete" value="Last: " />
|
<h:outputLabel for="employeeLastToDelete" value="Last: " />
|
||||||
<h:inputText id="employeeLastToDelete" value="#{employeeController.employeeLast}">
|
<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:inputText>
|
||||||
<h:message for="employeeLastToDelete" errorStyle="color:red"/>
|
<h:message for="employeeLastToDelete" errorStyle="color:red"/>
|
||||||
|
|
||||||
@ -114,13 +115,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h:commandButton id="delete"
|
||||||
|
action="#{employeeController.delete}"
|
||||||
|
value="Delete Employee"/>
|
||||||
</h:column>
|
</h:column>
|
||||||
|
|
||||||
</h:panelGrid>
|
</h:panelGrid>
|
||||||
<h:commandButton id="delete"
|
|
||||||
action="#{employeeController.delete}"
|
|
||||||
value="Delete Employee"/>
|
|
||||||
|
|
||||||
</h:form>
|
</h:form>
|
||||||
</h:body>
|
</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…
x
Reference in New Issue
Block a user