Sleepy WebDev
modified: .gitignore new file: Semester 2/LabJuneauValidateUserInput/Printed HTMLs/Company.html new file: Semester 2/LabJuneauValidateUserInput/Printed HTMLs/Employee.html new file: Semester 2/LabJuneauValidateUserInput/Printed HTMLs/EmployeeController.html new file: Semester 2/LabJuneauValidateUserInput/Printed HTMLs/EmployeeInterface.html new file: Semester 2/LabJuneauValidateUserInput/Printed HTMLs/EmployeeTitleValidate.html new file: Semester 2/LabJuneauValidateUserInput/Printed HTMLs/index.html new file: Semester 2/LabJuneauValidateUserInput/nb-configuration.xml new file: Semester 2/LabJuneauValidateUserInput/pom.xml new file: Semester 2/LabJuneauValidateUserInput/src/main/java/com/pap/exam/labjuneauvalidateuserinput/JakartaRestConfiguration.java new file: Semester 2/LabJuneauValidateUserInput/src/main/java/com/pap/exam/labjuneauvalidateuserinput/resources/JakartaEE9Resource.java new file: Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/beans/EmployeeController.java new file: Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/bl/Company.java new file: Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/bl/Employee.java new file: Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/bl/EmployeeInterface.java new file: Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/validators/EmployeeTitleValidate.java new file: Semester 2/LabJuneauValidateUserInput/src/main/resources/META-INF/persistence.xml new file: Semester 2/LabJuneauValidateUserInput/src/main/webapp/WEB-INF/beans.xml new file: Semester 2/LabJuneauValidateUserInput/src/main/webapp/WEB-INF/glassfish-web.xml new file: Semester 2/LabJuneauValidateUserInput/src/main/webapp/WEB-INF/web.xml new file: Semester 2/LabJuneauValidateUserInput/src/main/webapp/index.xhtml new file: Semester 2/LabJuneauValidateUserInput/src/main/webapp/resources/css/1.css new file: Semester 2/LabJuneauValidateUserInput/src/main/webapp/resources/images/1.png modified: Semester 2/LabJuneauValidateUserInput_CalebFontenot/src/main/java/bl/Company.java deleted: Semester 2/ZIPs/LabJuneauValidateUserInput_CalebFontenot.zip
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.pap.exam.labjuneauvalidateuserinput;
|
||||
|
||||
import jakarta.ws.rs.ApplicationPath;
|
||||
import jakarta.ws.rs.core.Application;
|
||||
|
||||
/**
|
||||
* Configures Jakarta RESTful Web Services for the application.
|
||||
* @author Juneau
|
||||
*/
|
||||
@ApplicationPath("resources")
|
||||
public class JakartaRestConfiguration extends Application {
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.pap.exam.labjuneauvalidateuserinput.resources;
|
||||
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
@Path("jakartaee9")
|
||||
public class JakartaEE9Resource {
|
||||
|
||||
@GET
|
||||
public Response ping(){
|
||||
return Response
|
||||
.ok("ping Jakarta EE")
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package edu.slcc.asdv.beans;
|
||||
|
||||
import edu.slcc.asdv.bl.Company;
|
||||
import edu.slcc.asdv.bl.Employee;
|
||||
import edu.slcc.asdv.bl.EmployeeInterface;
|
||||
import jakarta.enterprise.context.SessionScoped;
|
||||
import jakarta.faces.application.FacesMessage;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.inject.Named;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Named(value = "employeeController")
|
||||
@SessionScoped
|
||||
public class EmployeeController implements Serializable
|
||||
{
|
||||
|
||||
private String employeeFirst;
|
||||
private String employeeLast;
|
||||
private String employeeTitle;
|
||||
|
||||
private EmployeeInterface company;//placeholder
|
||||
|
||||
public EmployeeController() { company = new Company(); }
|
||||
|
||||
public EmployeeInterface getCompany(){ return this.company ;}
|
||||
|
||||
public String getEmployeeFirst(){return employeeFirst;}
|
||||
public void setEmployeeFirst(String employeeFirst){ this.employeeFirst = employeeFirst; }
|
||||
public String getEmployeeLast(){return employeeLast;}
|
||||
public void setEmployeeLast(String employeeLast){ this.employeeLast = employeeLast; }
|
||||
public String getEmployeeTitle(){return employeeTitle;}
|
||||
public void setEmployeeTitle(String employeeTitle){ this.employeeTitle = employeeTitle;}
|
||||
|
||||
public void delete(Employee e) {
|
||||
System.out.println(e);
|
||||
company.removeEmployee(e);
|
||||
};
|
||||
|
||||
public void insert()
|
||||
{
|
||||
boolean b = company.insertEmployee(
|
||||
new Employee(
|
||||
this.employeeFirst, //from textbox
|
||||
this.getEmployeeLast(), //from textbox
|
||||
this.employeeTitle, "1.png"));
|
||||
FacesMessage facesMsg = null;
|
||||
if (b)
|
||||
{
|
||||
facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO,
|
||||
"Employee Successfully Added", null);
|
||||
this.employeeFirst = "";//reset text boxes too
|
||||
this.employeeLast = "";
|
||||
this.employeeTitle = "";
|
||||
}
|
||||
else
|
||||
facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
|
||||
"Employee Not Added", null);
|
||||
FacesContext.getCurrentInstance().addMessage(null, facesMsg);
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package edu.slcc.asdv.bl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ASDV1
|
||||
*/
|
||||
public class Company implements EmployeeInterface
|
||||
{
|
||||
private List<Employee> employeeList;
|
||||
public Company(){employeeList = new ArrayList<Employee>(); }
|
||||
@Override
|
||||
public boolean insertEmployee(Employee e){return employeeList.add( e ); }
|
||||
|
||||
@Override
|
||||
public boolean removeEmployee(Employee e){return employeeList.remove(e);}
|
||||
|
||||
@Override
|
||||
public List<Employee> getEmployees(){return employeeList;}
|
||||
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package edu.slcc.asdv.bl;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Employee implements Serializable
|
||||
{
|
||||
|
||||
private String employeeFirst;
|
||||
private String employeeLast;
|
||||
private String employeeTitle;
|
||||
private String photo;
|
||||
|
||||
|
||||
|
||||
public Employee(String first,
|
||||
String last, String title,
|
||||
String photo)
|
||||
{
|
||||
employeeFirst = first;
|
||||
employeeLast = last;
|
||||
employeeTitle = title;
|
||||
this.photo = photo;
|
||||
}
|
||||
|
||||
public String getEmployeeFirst() { return employeeFirst; }
|
||||
|
||||
public void setEmployeeFirst(String employeeFirst){ this.employeeFirst = employeeFirst;}
|
||||
|
||||
public String getEmployeeLast(){return employeeLast;}
|
||||
|
||||
public void setEmployeeLast(String employeeLast){this.employeeLast = employeeLast;}
|
||||
|
||||
public String getEmployeeTitle(){return employeeTitle; }
|
||||
|
||||
public void setEmployeeTitle(String employeeTitle){ this.employeeTitle = employeeTitle; }
|
||||
|
||||
public String getPhoto(){return photo;}
|
||||
|
||||
public void setPhoto(String photo){this.photo = photo;}
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
|
||||
package edu.slcc.asdv.bl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ASDV1
|
||||
*/
|
||||
public interface EmployeeInterface
|
||||
{
|
||||
/**Inserts a new employee in thr list
|
||||
*
|
||||
* @param e the employee to be inserted.
|
||||
* @return true if inserted successfully, false otherwise.
|
||||
*/
|
||||
boolean insertEmployee(Employee e);
|
||||
|
||||
/** Removes an employee from the list.
|
||||
*
|
||||
* @param e the employee to be removed
|
||||
* @return true if the employee was successfully removed, false otherwise.
|
||||
*/
|
||||
boolean removeEmployee(Employee e);
|
||||
|
||||
/** Gets all employees in the list.
|
||||
*
|
||||
* @return list of employees.
|
||||
*/
|
||||
List<Employee> getEmployees();
|
||||
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package edu.slcc.asdv.validators;
|
||||
|
||||
import jakarta.faces.application.FacesMessage;
|
||||
import jakarta.faces.component.UIComponent;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.validator.FacesValidator;
|
||||
import jakarta.faces.validator.Validator;
|
||||
import jakarta.faces.validator.ValidatorException;
|
||||
|
||||
@FacesValidator("employeeTitleValidate")
|
||||
public class EmployeeTitleValidate implements Validator
|
||||
{
|
||||
|
||||
@Override
|
||||
public void validate(FacesContext fc, UIComponent uic, Object t)
|
||||
throws ValidatorException
|
||||
{
|
||||
checkTitle(t);
|
||||
}
|
||||
|
||||
private void checkTitle(Object value)
|
||||
{
|
||||
String title = value.toString();
|
||||
title = title.toLowerCase();
|
||||
if (!title.contains("java"))
|
||||
{
|
||||
String messageText = "Title does not include the word Java";
|
||||
String messageTextLong = "Title does not include the word Java. "
|
||||
+ "Please type java";
|
||||
throw new ValidatorException(
|
||||
new FacesMessage(FacesMessage.SEVERITY_ERROR,
|
||||
messageText, messageTextLong));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
|
||||
<!-- Define Persistence Unit -->
|
||||
<persistence-unit name="my_persistence_unit">
|
||||
|
||||
</persistence-unit>
|
||||
</persistence>
|
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd"
|
||||
bean-discovery-mode="all">
|
||||
</beans>
|
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
|
||||
<!--
|
||||
Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program and the accompanying materials are made available under the
|
||||
terms of the Eclipse Public License v. 2.0, which is available at
|
||||
http://www.eclipse.org/legal/epl-2.0.
|
||||
|
||||
This Source Code may also be made available under the following Secondary
|
||||
Licenses when the conditions for such availability set forth in the
|
||||
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
|
||||
version 2 with the GNU Classpath Exception, which is available at
|
||||
https://www.gnu.org/software/classpath/license.html.
|
||||
|
||||
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
||||
-->
|
||||
<glassfish-web-app error-url="">
|
||||
<class-loader delegate="true"/>
|
||||
<jsp-config>
|
||||
<property name="keepgenerated" value="true">
|
||||
<description>Keep a copy of the generated servlet class' java code.</description>
|
||||
</property>
|
||||
</jsp-config>
|
||||
</glassfish-web-app>
|
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
|
||||
version="5.0">
|
||||
<context-param>
|
||||
<param-name>jakarta.faces.PROJECT_STAGE</param-name>
|
||||
<param-value>Development</param-value>
|
||||
</context-param>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Faces Servlet</servlet-name>
|
||||
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
|
||||
<servlet-name>Faces Servlet</servlet-name>
|
||||
<url-pattern>/faces/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
</session-config>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>faces/index.xhtml</welcome-file>
|
||||
</welcome-file-list>
|
||||
</web-app>
|
@@ -0,0 +1,92 @@
|
||||
<?xml version='1.0' encoding='UTF-8' ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
<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">
|
||||
<h:panelGrid id="outer" columns="2"
|
||||
>
|
||||
<h:column >
|
||||
<h1>Java Developer Employee Information</h1>
|
||||
<br/>
|
||||
<h:messages globalOnly="true" errorStyle="color: red"
|
||||
infoStyle="color: green"/>
|
||||
<br/>
|
||||
<h:dataTable id="empTable"
|
||||
var="emp"
|
||||
border="1"
|
||||
value="#{employeeController.company.getEmployees()}"
|
||||
rendered="#{employeeController.company.getEmployees().size() > 0}">
|
||||
|
||||
<f:facet name="header">
|
||||
Current Employees
|
||||
</f:facet>
|
||||
|
||||
<h:column id="empNameCol">
|
||||
<f:facet name="header">Employee</f:facet>
|
||||
<h:outputText id="empName"
|
||||
value="#{emp.getEmployeeFirst()} #{emp.employeeLast}"/>
|
||||
</h:column>
|
||||
|
||||
<h:column id="titleCol">
|
||||
<f:facet name="header">Title</f:facet>
|
||||
<h:outputText id="title" value="#{emp.employeeTitle}"/>
|
||||
</h:column>
|
||||
|
||||
<h:column id="imageCol">
|
||||
<f:facet name="header">Photo</f:facet>
|
||||
<h:graphicImage library="images" name="#{emp.photo}"/>
|
||||
</h:column>
|
||||
<h:column>
|
||||
<f:facet name="header">Delete</f:facet>
|
||||
<h:commandLink value="delete" immediate="true"
|
||||
action="#{employeeController.delete(emp)}"/>
|
||||
</h:column>
|
||||
</h:dataTable>
|
||||
<p> Please use the form below to insert employee information. </p>
|
||||
<h:panelGrid columns="3">
|
||||
|
||||
<h:outputLabel for="employeeFirst" value="First:" />
|
||||
<h:inputText id="employeeFirst"
|
||||
value="#{employeeController.employeeFirst}">
|
||||
<f:validateLength disabled=""
|
||||
|
||||
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}">
|
||||
<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" />
|
||||
</h:inputText>
|
||||
<h:message for="employeeTitle" errorStyle="color:red"/>
|
||||
|
||||
</h:panelGrid>
|
||||
|
||||
|
||||
<h:commandButton id="employeeInsert"
|
||||
action="#{employeeController.insert}"
|
||||
value="Insert Employee"/>
|
||||
|
||||
|
||||
</h:column>
|
||||
|
||||
|
||||
</h:panelGrid>
|
||||
</h:form>
|
||||
</h:body>
|
||||
</html>
|
||||
|
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
td {
|
||||
|
||||
vertical-align: top;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 432 B |
Reference in New Issue
Block a user