This commit is contained in:
2023-09-27 13:31:02 -05:00
parent 99634aba7e
commit a7c5929537
307 changed files with 23548 additions and 0 deletions

View File

@@ -0,0 +1,128 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package beans;
import bl.Company;
import bl.Employee;
import 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;
/**
*
* @author caleb
*/
@Named(value = "employeeController")
@SessionScoped
public class EmployeeController implements Serializable {
private String employeeFirst;
private String employeeLast;
private String employeeTitle;
private EmployeeInterface company;
public EmployeeController()
{
company = new Company();
}
public EmployeeInterface getCompany()
{
return company;
}
public void setCompany(EmployeeInterface company)
{
this.company = company;
}
/**
* Get the value of employeeLast
*
* @return the value of employeeLast
*/
public String getEmployeeLast()
{
return employeeLast;
}
/**
* Set the value of employeeLast
*
* @param employeeLast new value of employeeLast
*/
public void setEmployeeLast(String employeeLast)
{
this.employeeLast = employeeLast;
}
/**
* Get the value of employeeTitle
*
* @return the value of employeeTitle
*/
public String getEmployeeTitle()
{
return employeeTitle;
}
/**
* Set the value of employeeTitle
*
* @param employeeTitle new value of employeeTitle
*/
public void setEmployeeTitle(String employeeTitle)
{
this.employeeTitle = employeeTitle;
}
/**
* Get the value of employeeFirst
*
* @return the value of employeeFirst
*/
public String getEmployeeFirst()
{
return employeeFirst;
}
/**
* Set the value of employeeFirst
*
* @param employeeFirst new value of employeeFirst
*/
public void setEmployeeFirst(String employeeFirst)
{
this.employeeFirst = employeeFirst;
}
public void insert() {
boolean b = company.insertEmployee(new Employee(this.employeeFirst,
this.getEmployeeLast(), this.employeeTitle, "1.png")
);
FacesMessage facesMsg = null;
if (b) {
facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO,
"Employee Successfully Added", null);
this.employeeFirst = "";
this.employeeLast = "";
this.employeeTitle = "";
}
else {
facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Employee Not Added", null);
FacesContext.getCurrentInstance().addMessage(null, facesMsg);
}
}
public void remove() {
}
}

View File

@@ -0,0 +1,74 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
*/
package beans;
import jakarta.enterprise.context.SessionScoped;
import jakarta.faces.application.FacesMessage;
import jakarta.faces.context.FacesContext;
import jakarta.inject.Named;
import java.util.Date;
/**
*
* @author caleb
*/
@Named(value = "messageController")
@SessionScoped
public class MessageController implements java.io.Serializable {
int hitCounter = 0;
private String javaText;
/**
* Creates a new instance of MessageController
*/
public MessageController()
{
javaText = null;
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Managed Bean Initialized", null);
FacesContext.getCurrentInstance().addMessage(null, facesMsg);
}
public void newMessage()
{
String hitMessage = null;
hitCounter++;
if (hitCounter > 1) {
hitMessage = hitCounter + " times";
} else {
hitMessage = hitCounter + " time";
}
Date currDate = new Date();
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"You've pressed that button " + hitMessage + "! The current date and time: "
+ currDate, null);
FacesContext.getCurrentInstance().addMessage(null, facesMsg);
if (getJavaText().equalsIgnoreCase("java")) {
FacesMessage javaTextMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Good Job, that is the correct text!", null);
FacesContext.getCurrentInstance().addMessage("componentForm:javaText", javaTextMsg);
} else {
FacesMessage javaTextMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Sorry, that is NOT the correct text!", null);
FacesContext.getCurrentInstance().addMessage("componentForm:javaText", javaTextMsg);
}
}
/**
* @return the javaText
*/
public String getJavaText()
{
return javaText;
}
/**
* @param javaText the javaText to set
*/
public void setJavaText(String javaText)
{
this.javaText = javaText;
}
}

View File

@@ -0,0 +1,34 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package bl;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author caleb
*/
public class Company implements EmployeeInterface {
private List<Employee> employeeList;
public Company(List<Employee> employeeList)
{
this.employeeList = employeeList;
}
public Company() {
employeeList = 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."); }
@Override
public List<Employee> getEmployees(){return employeeList;}
}

View File

@@ -0,0 +1,110 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package bl;
/**
*
* @author caleb
*/
public class Employee {
private String employeeFirst;
private String employeeLast;
private String employeeTitle;
private String photo;
public Employee(String employeeFirst, String employeeLast, String employeeTitle, String photo)
{
this.employeeFirst = employeeFirst;
this.employeeLast = employeeLast;
this.employeeTitle = employeeTitle;
this.photo = photo;
}
/**
* Get the value of photo
*
* @return the value of photo
*/
public String getPhoto()
{
return photo;
}
/**
* Set the value of photo
*
* @param photo new value of photo
*/
public void setPhoto(String photo)
{
this.photo = photo;
}
/**
* Get the value of employeeTitle
*
* @return the value of employeeTitle
*/
public String getEmployeeTitle()
{
return employeeTitle;
}
/**
* Set the value of employeeTitle
*
* @param employeeTitle new value of employeeTitle
*/
public void setEmployeeTitle(String employeeTitle)
{
this.employeeTitle = employeeTitle;
}
/**
* Get the value of employeeLast
*
* @return the value of employeeLast
*/
public String getEmployeeLast()
{
return employeeLast;
}
/**
* Set the value of employeeLast
*
* @param employeeLast new value of employeeLast
*/
public void setEmployeeLast(String employeeLast)
{
this.employeeLast = employeeLast;
}
/**
* Get the value of employeeFirst
*
* @return the value of employeeFirst
*/
public String getEmployeeFirst()
{
return employeeFirst;
}
/**
* Set the value of employeeFirst
*
* @param employeeFirst new value of employeeFirst
*/
public void setEmployeeFirst(String employeeFirst)
{
this.employeeFirst = employeeFirst;
}
}

View File

@@ -0,0 +1,17 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package bl;
import java.util.List;
/**
*
* @author caleb
*/
public interface EmployeeInterface {
boolean insertEmployee(Employee e);
boolean removeEmployee(Employee e);
List<Employee> getEmployees();
}

View File

@@ -0,0 +1,13 @@
package edu.slcc.asdv.caleb.labjuneauvalidateuserinput_calebfontenot;
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 {
}

View File

@@ -0,0 +1,20 @@
package edu.slcc.asdv.caleb.labjuneauvalidateuserinput_calebfontenot.resources;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;
/**
*
* @author
*/
@Path("jakartaee10")
public class JakartaEE10Resource {
@GET
public Response ping(){
return Response
.ok("ping Jakarta EE")
.build();
}
}

View File

@@ -0,0 +1,40 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
*/
package 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;
/**
*
* @author caleb
*/
@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().toLowerCase();
if (!title.contains("java")) {
String messageText = "Title does not include the word Java!";
String messageTextLong = "The title does not include the word Java." +
" Please type the word Java.";
throw new ValidatorException(
new FacesMessage(FacesMessage.SEVERITY_ERROR,
messageText, messageTextLong));
}
}
}

View File

@@ -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>

View File

@@ -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_4_0.xsd"
bean-discovery-mode="all">
</beans>

View File

@@ -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>

View File

@@ -0,0 +1,11 @@
<?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_6_0.xsd"
version="6.0">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>

View File

@@ -0,0 +1,128 @@
<?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:head>
<h:body>
<h:form id="employeeForm">
<h:panelGrid id="outer" columns="2">
<h:column style="vertical-align: top;">
<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: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 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:column style="vertical-align: top;">
<h1>Delete Information</h1>
<br/>
<h:messages globalOnly="true" errorStyle="color: red"
infoStyle="color: green"/>
<br/>
<h:dataTable id="DeleteTable"
var="emp"
border="1"
value=""
rendered="">
<f:facet name="header">
Deleted Employees
</f:facet>
<h:column id="empDeletedName">
<f:facet name="header">Name</f:facet>
<h:outputText id="empNameDelete"
value=""/>
</h:column>
</h:dataTable>
<p> Please use the form below to insert employee information. </p>
<h:panelGrid columns="3">
<h:outputLabel for="employeeLastToDelete" value="Last: " />
<h:inputText id="employeeLastToDelete" value="#{employeeController.employeeLast}">
<f:validateLength minimum="3" maximum="30"/>
</h:inputText>
<h:message for="employeeLastToDelete" errorStyle="color:red"/>
</h:panelGrid>
</h:column>
</h:panelGrid>
<h:commandButton id="delete"
action="#{employeeController.delete}"
value="Delete Employee"/>
</h:form>
</h:body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB