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
master
Caleb Fontenot 2023-10-02 13:29:00 +07:00
parent 229f114b3f
commit 778965c800
25 changed files with 938 additions and 1 deletions

1
.gitignore vendored

@ -50,3 +50,4 @@
/Semester 2/LabJuneauValidateUserInput_CalebFontenot/target/
/Semester 2/Assignments/lab_EL5_CalebFontenot/target/
/Semester 2/Assignments/labEL2_CalebFontenot/target/
/Semester 2/LabJuneauValidateUserInput/target/

@ -0,0 +1,48 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Company.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
table {color: #888888; background-color: #313335; font-family: monospace}
.ST1 {color: #9876aa}
.ST2 {color: #ffc66d}
.whitespace {color: #505050}
.comment {color: #808080}
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-WebDev/Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/bl/Company.java</td></tr></table>
<pre>
<span class="literal">package</span> edu.slcc.asdv.bl;
<span class="literal">import</span> java.util.ArrayList;
<span class="literal">import</span> java.util.List;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">ASDV1</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> Company <span class="literal">implements</span> EmployeeInterface
{
<span class="literal">private</span> List&lt;Employee&gt; <span class="ST1">employeeList</span>;
<span class="literal">public</span> Company(){<span class="ST1">employeeList</span> = <span class="literal">new</span> ArrayList&lt;Employee&gt;(); }
@Override
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST2">insertEmployee</span>(Employee e){<span class="literal">return</span> <span class="ST1">employeeList</span>.add( e ); }
@Override
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST2">removeEmployee</span>(Employee e){<span class="literal">return</span> <span class="ST1">employeeList</span>.remove(e);}
@Override
<span class="literal">public</span> List&lt;Employee&gt; <span class="ST2">getEmployees</span>(){<span class="literal">return</span> <span class="ST1">employeeList</span>;}
}
</pre></body>
</html>

@ -0,0 +1,64 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Employee.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
table {color: #888888; background-color: #313335; font-family: monospace}
.ST0 {color: #9876aa}
.ST1 {color: #ffc66d}
.whitespace {color: #505050}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-WebDev/Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/bl/Employee.java</td></tr></table>
<pre>
<span class="literal">package</span> edu.slcc.asdv.bl;
<span class="literal">import</span> java.io.Serializable;
<span class="literal">public</span> <span class="literal">class</span> Employee <span class="literal">implements</span> Serializable
{
<span class="literal">private</span> String <span class="ST0">employeeFirst</span>;
<span class="literal">private</span> String <span class="ST0">employeeLast</span>;
<span class="literal">private</span> String <span class="ST0">employeeTitle</span>;
<span class="literal">private</span> String <span class="ST0">photo</span>;
<span class="literal">public</span> Employee(String first,
String last, String title,
String photo)
{
<span class="ST0">employeeFirst</span> = first;
<span class="ST0">employeeLast</span> = last;
<span class="ST0">employeeTitle</span> = title;
<span class="literal">this</span>.<span class="ST0">photo</span> = photo;
}
<span class="literal">public</span> String <span class="ST1">getEmployeeFirst</span>() { <span class="literal">return</span> <span class="ST0">employeeFirst</span>; }
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">setEmployeeFirst</span>(String employeeFirst){ <span class="literal">this</span>.<span class="ST0">employeeFirst</span> = employeeFirst;}
<span class="literal">public</span> String <span class="ST1">getEmployeeLast</span>(){<span class="literal">return</span> <span class="ST0">employeeLast</span>;}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">setEmployeeLast</span>(String employeeLast){<span class="literal">this</span>.<span class="ST0">employeeLast</span> = employeeLast;}
<span class="literal">public</span> String <span class="ST1">getEmployeeTitle</span>(){<span class="literal">return</span> <span class="ST0">employeeTitle</span>; }
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">setEmployeeTitle</span>(String employeeTitle){ <span class="literal">this</span>.<span class="ST0">employeeTitle</span> = employeeTitle; }
<span class="literal">public</span> String <span class="ST1">getPhoto</span>(){<span class="literal">return</span> <span class="ST0">photo</span>;}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">setPhoto</span>(String photo){<span class="literal">this</span>.<span class="ST0">photo</span> = photo;}
}
</pre></body>
</html>

@ -0,0 +1,88 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>EmployeeController.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
table {color: #888888; background-color: #313335; font-family: monospace}
.ST0 {color: #9876aa}
.ST1 {color: #ffc66d}
.string {color: #6a8759}
.whitespace {color: #505050}
.comment {color: #808080}
.ST2 {color: #9876aa; font-family: monospace; font-style: italic}
.literal {color: #cc7832}
.ST3 {font-family: monospace; font-style: italic}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-WebDev/Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/beans/EmployeeController.java</td></tr></table>
<pre>
<span class="literal">package</span> edu.slcc.asdv.beans;
<span class="literal">import</span> edu.slcc.asdv.bl.Company;
<span class="literal">import</span> edu.slcc.asdv.bl.Employee;
<span class="literal">import</span> edu.slcc.asdv.bl.EmployeeInterface;
<span class="literal">import</span> jakarta.enterprise.context.SessionScoped;
<span class="literal">import</span> jakarta.faces.application.FacesMessage;
<span class="literal">import</span> jakarta.faces.context.FacesContext;
<span class="literal">import</span> jakarta.inject.Named;
<span class="literal">import</span> java.io.Serializable;
@Named(value = <span class="string">&quot;</span><span class="string">employeeController</span><span class="string">&quot;</span>)
@SessionScoped
<span class="literal">public</span> <span class="literal">class</span> EmployeeController <span class="literal">implements</span> Serializable
{
<span class="literal">private</span> String <span class="ST0">employeeFirst</span>;
<span class="literal">private</span> String <span class="ST0">employeeLast</span>;
<span class="literal">private</span> String <span class="ST0">employeeTitle</span>;
<span class="literal">private</span> EmployeeInterface <span class="ST0">company</span>;<span class="comment">//placeholder</span>
<span class="literal">public</span> EmployeeController() { <span class="ST0">company</span> = <span class="literal">new</span> Company(); }
<span class="literal">public</span> EmployeeInterface <span class="ST1">getCompany</span>(){ <span class="literal">return</span> <span class="literal">this</span>.<span class="ST0">company</span> ;}
<span class="literal">public</span> String <span class="ST1">getEmployeeFirst</span>(){<span class="literal">return</span> <span class="ST0">employeeFirst</span>;}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">setEmployeeFirst</span>(String employeeFirst){ <span class="literal">this</span>.<span class="ST0">employeeFirst</span> = employeeFirst; }
<span class="literal">public</span> String <span class="ST1">getEmployeeLast</span>(){<span class="literal">return</span> <span class="ST0">employeeLast</span>;}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">setEmployeeLast</span>(String employeeLast){ <span class="literal">this</span>.<span class="ST0">employeeLast</span> = employeeLast; }
<span class="literal">public</span> String <span class="ST1">getEmployeeTitle</span>(){<span class="literal">return</span> <span class="ST0">employeeTitle</span>;}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">setEmployeeTitle</span>(String employeeTitle){ <span class="literal">this</span>.<span class="ST0">employeeTitle</span> = employeeTitle;}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">delete</span>(Employee e) {
System.<span class="ST2">out</span>.println(e);
<span class="ST0">company</span>.removeEmployee(e);
};
<span class="literal">public</span> <span class="literal">void</span> <span class="ST1">insert</span>()
{
<span class="literal">boolean</span> b = <span class="ST0">company</span>.insertEmployee(
<span class="literal">new</span> Employee(
<span class="literal">t</span><span class="literal">his</span>.<span class="ST0">employeeFirst</span>, <span class="comment">//from textbox</span>
<span class="literal">t</span><span class="literal">his</span>.getEmployeeLast(), <span class="comment">//from textbox</span>
<span class="literal">t</span><span class="literal">his</span>.<span class="ST0">employeeTitle</span>, <span class="string">&quot;</span><span class="string">1.png</span><span class="string">&quot;</span>));
FacesMessage facesMsg = <span class="literal">null</span>;
<span class="literal">if</span> (b)
{
facesMsg = <span class="literal">new</span> FacesMessage(FacesMessage.<span class="ST2">SEVERITY_INFO</span>,
<span class="string">&quot;</span><span class="string">Employee Successfully Added</span><span class="string">&quot;</span>, <span class="literal">n</span><span class="literal">ull</span>);
<span class="literal">this</span>.<span class="ST0">employeeFirst</span> = <span class="string">&quot;&quot;</span>;<span class="comment">//reset text boxes too</span>
<span class="literal">this</span>.<span class="ST0">employeeLast</span> = <span class="string">&quot;&quot;</span>;
<span class="literal">this</span>.<span class="ST0">employeeTitle</span> = <span class="string">&quot;&quot;</span>;
}
<span class="literal">else</span>
facesMsg = <span class="literal">new</span> FacesMessage(FacesMessage.<span class="ST2">SEVERITY_ERROR</span>,
<span class="string">&quot;</span><span class="string">Employee Not Added</span><span class="string">&quot;</span>, <span class="literal">n</span><span class="literal">ull</span>);
FacesContext.<span class="ST3">getCurrentInstance</span>().addMessage(<span class="literal">n</span><span class="literal">ull</span>, facesMsg);
}
}
</pre></body>
</html>

@ -0,0 +1,58 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>EmployeeInterface.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
table {color: #888888; background-color: #313335; font-family: monospace}
.ST3 {color: #ffc66d}
.whitespace {color: #505050}
.comment {color: #808080}
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
.ST2 {color: #8a653b}
.literal {color: #cc7832}
.ST1 {font-family: monospace; font-weight: bold}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-WebDev/Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/bl/EmployeeInterface.java</td></tr></table>
<pre>
<span class="literal">package</span> edu.slcc.asdv.bl;
<span class="literal">import</span> java.util.List;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">ASDV1</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">interface</span> <span class="ST1">EmployeeInterface</span>
{
<span class="comment">/**</span><span class="comment">Inserts</span> <span class="comment">a</span> <span class="comment">new</span> <span class="comment">employee</span> <span class="comment">in</span> <span class="comment">thr</span> <span class="comment">list</span>
<span class="comment"> * </span>
<span class="comment"> * </span><span class="ST0">@param</span> <span class="ST2">e</span> <span class="comment">the</span> <span class="comment">employee</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">inserted</span><span class="comment">.</span>
<span class="comment"> * </span><span class="ST0">@return</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">inserted</span> <span class="comment">successfully</span><span class="comment">, </span><span class="comment">false</span> <span class="comment">otherwise</span><span class="comment">.</span>
<span class="comment">*/</span>
<span class="literal">boolean</span> <span class="ST3">insertEmployee</span>(Employee e);
<span class="comment">/**</span> <span class="comment">Removes</span> <span class="comment">an</span> <span class="comment">employee</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">list</span><span class="comment">.</span>
<span class="comment"> * </span>
<span class="comment"> * </span><span class="ST0">@param</span> <span class="ST2">e</span> <span class="comment">the</span> <span class="comment">employee</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">removed</span>
<span class="comment"> * </span><span class="ST0">@return</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">the</span> <span class="comment">employee</span> <span class="comment">was</span> <span class="comment">successfully</span> <span class="comment">removed</span><span class="comment">, </span><span class="comment">false</span> <span class="comment">otherwise</span><span class="comment">.</span>
<span class="comment">*/</span>
<span class="literal">boolean</span> <span class="ST3">removeEmployee</span>(Employee e);
<span class="comment">/**</span> <span class="comment">Gets</span> <span class="comment">all</span> <span class="comment">employees</span> <span class="comment">in</span> <span class="comment">the</span> <span class="comment">list</span><span class="comment">.</span>
<span class="comment"> * </span>
<span class="comment"> * </span><span class="ST0">@return</span> <span class="comment">list</span> <span class="comment">of</span> <span class="comment">employees</span><span class="comment">.</span>
<span class="comment">*/</span>
List&lt;Employee&gt; <span class="ST3">getEmployees</span>();
}
</pre></body>
</html>

@ -0,0 +1,58 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>EmployeeTitleValidate.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
table {color: #888888; background-color: #313335; font-family: monospace}
.string {color: #6a8759}
.whitespace {color: #505050}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-WebDev/Semester 2/LabJuneauValidateUserInput/src/main/java/edu/slcc/asdv/validators/EmployeeTitleValidate.java</td></tr></table>
<pre>
<span class="literal">package</span> edu.slcc.asdv.validators;
<span class="literal">import</span> jakarta.faces.application.FacesMessage;
<span class="literal">import</span> jakarta.faces.component.UIComponent;
<span class="literal">import</span> jakarta.faces.context.FacesContext;
<span class="literal">import</span> jakarta.faces.validator.FacesValidator;
<span class="literal">import</span> jakarta.faces.validator.Validator;
<span class="literal">import</span> jakarta.faces.validator.ValidatorException;
@FacesValidator(<span class="string">&quot;</span><span class="string">employeeTitleValidate</span><span class="string">&quot;</span>)
<span class="literal">public</span> <span class="literal">class</span> EmployeeTitleValidate <span class="literal">implements</span> Validator
{
@Override
<span class="literal">public</span> <span class="literal">void</span> validate(FacesContext fc, UIComponent uic, Object t)
<span class="literal">throws</span> ValidatorException
{
checkTitle(t);
}
<span class="literal">private</span> <span class="literal">void</span> checkTitle(Object value)
{
String title = value.toString();
title = title.toLowerCase();
<span class="literal">if</span> (!title.contains(<span class="string">&quot;</span><span class="string">java</span><span class="string">&quot;</span>))
{
String messageText = <span class="string">&quot;</span><span class="string">Title does not include the word Java</span><span class="string">&quot;</span>;
String messageTextLong = <span class="string">&quot;</span><span class="string">Title does not include the word Java. </span><span class="string">&quot;</span>
+ <span class="string">&quot;</span><span class="string">Please type java</span><span class="string">&quot;</span>;
<span class="literal">throw</span> <span class="literal">new</span> ValidatorException(
<span class="literal">new</span> FacesMessage(FacesMessage.SEVERITY_ERROR,
messageText, messageTextLong));
}
}
}
</pre></body>
</html>

@ -0,0 +1,122 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>index.xhtml</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
table {color: #888888; background-color: #313335; font-family: monospace}
.ST3 {color: #e8bf6a}
.ST6 {color: #e8bf6a; font-family: monospace; font-weight: bold}
.ST1 {color: #505050}
.ST4 {color: #bababa}
.ST2 {color: #287bde}
.ST7 {color: #505050; background-color: #232525}
.ST0 {color: #628fb5}
.ST5 {color: #a5c261}
.ST8 {color: #6897bb; background-color: #232525}
.expression-language {background-color: #232525}
.highlight-caret-row {background-color: #323232}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-WebDev/Semester 2/LabJuneauValidateUserInput/src/main/webapp/index.xhtml</td></tr></table>
<pre>
<span class="highlight-caret-row">&lt;?xml version=&#39;1.0&#39; encoding=&#39;UTF-8&#39; ?&gt;</span>
<span class="ST0">&lt;!DOCTYPE</span> <span class="ST0">html</span> <span class="ST0">PUBLIC</span> <span class="ST0">&quot;-//W3C//DTD</span> <span class="ST0">XHTML</span> <span class="ST0">1.0</span> <span class="ST0">Transitional//EN&quot;</span> <span class="ST0">&quot;</span><span class="ST2">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</span><span class="ST0">&quot;</span><span class="ST0">&gt;</span>
<span class="ST3">&lt;</span><span class="ST3">html</span> <span class="ST4">xmlns</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="ST2">http://www.w3.org/1999/xhtml</span><span class="ST5">&quot;</span>
<span class="ST4">xmlns:h</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="ST2">http://xmlns.jcp.org/jsf/html</span><span class="ST5">&quot;</span>
<span class="ST4">xmlns:f</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="ST2">http://xmlns.jcp.org/jsf/core</span><span class="ST5">&quot;</span><span class="ST3">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:head</span><span class="ST6">&gt;</span>
<span class="ST3">&lt;</span><span class="ST3">meta</span> <span class="ST4">http-equiv</span><span class="ST4">=</span><span class="ST5">&quot;Content-Type&quot;</span> <span class="ST4">content</span><span class="ST4">=</span><span class="ST5">&quot;text/html; charset=UTF-8&quot;</span><span class="ST3">/&gt;</span>
<span class="ST3">&lt;</span><span class="ST3">title</span><span class="ST3">&gt;</span>Validating Data<span class="ST3">&lt;/</span><span class="ST3">title</span><span class="ST3">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:outputStylesheet</span> <span class="ST4">name</span><span class="ST4">=</span><span class="ST5">&quot;css/1.css&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:head</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:body</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:form</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;employeeForm&quot;</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:panelGrid</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;outer&quot;</span> <span class="ST4">columns</span><span class="ST4">=</span><span class="ST5">&quot;2&quot;</span>
<span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:column</span> <span class="ST6">&gt;</span>
<span class="ST3">&lt;</span><span class="ST3">h1</span><span class="ST3">&gt;</span>Java Developer Employee Information<span class="ST3">&lt;/</span><span class="ST3">h1</span><span class="ST3">&gt;</span>
<span class="ST3">&lt;</span><span class="ST3">br</span><span class="ST3">/&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:messages</span> <span class="ST4">globalOnly</span><span class="ST4">=</span><span class="ST5">&quot;true&quot;</span> <span class="ST4">errorStyle</span><span class="ST4">=</span><span class="ST5">&quot;color: red&quot;</span>
<span class="ST4">infoStyle</span><span class="ST4">=</span><span class="ST5">&quot;color: green&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST3">&lt;</span><span class="ST3">br</span><span class="ST3">/&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:dataTable</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;empTable&quot;</span>
<span class="ST4">var</span><span class="ST4">=</span><span class="ST5">&quot;emp&quot;</span>
<span class="ST4">border</span><span class="ST4">=</span><span class="ST5">&quot;1&quot;</span>
<span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">employeeController</span><span class="expression-language">.</span><span class="expression-language">company</span><span class="expression-language">.</span><span class="expression-language">getEmployees</span><span class="expression-language">(</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST5">&quot;</span>
<span class="ST4">rendered</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">employeeController</span><span class="expression-language">.</span><span class="expression-language">company</span><span class="expression-language">.</span><span class="expression-language">getEmployees</span><span class="expression-language">(</span><span class="expression-language">)</span><span class="expression-language">.</span><span class="expression-language">size</span><span class="expression-language">(</span><span class="expression-language">)</span> <span class="expression-language">&gt;</span> <span class="ST8">0</span><span class="expression-language">}</span><span class="ST5">&quot;</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">f:facet</span> <span class="ST4">name</span><span class="ST4">=</span><span class="ST5">&quot;header&quot;</span><span class="ST6">&gt;</span>
Current Employees
<span class="ST6">&lt;/</span><span class="ST6">f:facet</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:column</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;empNameCol&quot;</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">f:facet</span> <span class="ST4">name</span><span class="ST4">=</span><span class="ST5">&quot;header&quot;</span><span class="ST6">&gt;</span>Employee<span class="ST6">&lt;/</span><span class="ST6">f:facet</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:outputText</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;empName&quot;</span>
<span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">emp</span><span class="expression-language">.</span><span class="expression-language">getEmployeeFirst</span><span class="expression-language">(</span><span class="expression-language">)</span><span class="expression-language">}</span> <span class="expression-language">#{</span><span class="expression-language">emp</span><span class="expression-language">.</span><span class="expression-language">employeeLast</span><span class="expression-language">}</span><span class="ST5">&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:column</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:column</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;titleCol&quot;</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">f:facet</span> <span class="ST4">name</span><span class="ST4">=</span><span class="ST5">&quot;header&quot;</span><span class="ST6">&gt;</span>Title<span class="ST6">&lt;/</span><span class="ST6">f:facet</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:outputText</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;title&quot;</span> <span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">emp</span><span class="expression-language">.</span><span class="expression-language">employeeTitle</span><span class="expression-language">}</span><span class="ST5">&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:column</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:column</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;imageCol&quot;</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">f:facet</span> <span class="ST4">name</span><span class="ST4">=</span><span class="ST5">&quot;header&quot;</span><span class="ST6">&gt;</span>Photo<span class="ST6">&lt;/</span><span class="ST6">f:facet</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:graphicImage</span> <span class="ST4">library</span><span class="ST4">=</span><span class="ST5">&quot;images&quot;</span> <span class="ST4">name</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">emp</span><span class="expression-language">.</span><span class="expression-language">photo</span><span class="expression-language">}</span><span class="ST5">&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:column</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:column</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">f:facet</span> <span class="ST4">name</span><span class="ST4">=</span><span class="ST5">&quot;header&quot;</span><span class="ST6">&gt;</span>Delete<span class="ST6">&lt;/</span><span class="ST6">f:facet</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:commandLink</span> <span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;delete&quot;</span> <span class="ST4">immediate</span><span class="ST4">=</span><span class="ST5">&quot;true&quot;</span>
<span class="ST4">action</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">employeeController</span><span class="expression-language">.</span><span class="expression-language">delete</span><span class="expression-language">(</span><span class="expression-language">emp</span><span class="expression-language">)</span><span class="expression-language">}</span><span class="ST5">&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:column</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:dataTable</span><span class="ST6">&gt;</span>
<span class="ST3">&lt;</span><span class="ST3">p</span><span class="ST3">&gt;</span> Please use the form below to insert employee information. <span class="ST3">&lt;/</span><span class="ST3">p</span><span class="ST3">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:panelGrid</span> <span class="ST4">columns</span><span class="ST4">=</span><span class="ST5">&quot;3&quot;</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:outputLabel</span> <span class="ST4">for</span><span class="ST4">=</span><span class="ST5">&quot;employeeFirst&quot;</span> <span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;First:&quot;</span> <span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:inputText</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;employeeFirst&quot;</span>
<span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">employeeController</span><span class="expression-language">.</span><span class="expression-language">employeeFirst</span><span class="expression-language">}</span><span class="ST5">&quot;</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">f:validateLength</span> <span class="ST4">disabled</span><span class="ST4">=</span><span class="ST5">&quot;&quot;</span>
<span class="ST4">minimum</span><span class="ST4">=</span><span class="ST5">&quot;3&quot;</span> <span class="ST4">maximum</span><span class="ST4">=</span><span class="ST5">&quot;30&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:inputText</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:message</span> <span class="ST4">for</span><span class="ST4">=</span><span class="ST5">&quot;employeeFirst&quot;</span> <span class="ST4">errorStyle</span><span class="ST4">=</span><span class="ST5">&quot;color:red&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:outputLabel</span> <span class="ST4">for</span><span class="ST4">=</span><span class="ST5">&quot;employeeLast&quot;</span> <span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;Last: &quot;</span> <span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:inputText</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;employeeLast&quot;</span> <span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">employeeController</span><span class="expression-language">.</span><span class="expression-language">employeeLast</span><span class="expression-language">}</span><span class="ST5">&quot;</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">f:validateLength</span> <span class="ST4">minimum</span><span class="ST4">=</span><span class="ST5">&quot;3&quot;</span> <span class="ST4">maximum</span><span class="ST4">=</span><span class="ST5">&quot;30&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:inputText</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:message</span> <span class="ST4">for</span><span class="ST4">=</span><span class="ST5">&quot;employeeLast&quot;</span> <span class="ST4">errorStyle</span><span class="ST4">=</span><span class="ST5">&quot;color:red&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:outputLabel</span> <span class="ST4">for</span><span class="ST4">=</span><span class="ST5">&quot;employeeTitle&quot;</span> <span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;Title (Must be a Java Position): &quot;</span> <span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:inputText</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;employeeTitle&quot;</span> <span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">employeeController</span><span class="expression-language">.</span><span class="expression-language">employeeTitle</span><span class="expression-language">}</span><span class="ST5">&quot;</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">f:validator</span> <span class="ST4">validatorId</span><span class="ST4">=</span><span class="ST5">&quot;employeeTitleValidate&quot;</span> <span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:inputText</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:message</span> <span class="ST4">for</span><span class="ST4">=</span><span class="ST5">&quot;employeeTitle&quot;</span> <span class="ST4">errorStyle</span><span class="ST4">=</span><span class="ST5">&quot;color:red&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:panelGrid</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;</span><span class="ST6">h:commandButton</span> <span class="ST4">id</span><span class="ST4">=</span><span class="ST5">&quot;employeeInsert&quot;</span>
<span class="ST4">action</span><span class="ST4">=</span><span class="ST5">&quot;</span><span class="expression-language">#{</span><span class="expression-language">employeeController</span><span class="expression-language">.</span><span class="expression-language">insert</span><span class="expression-language">}</span><span class="ST5">&quot;</span>
<span class="ST4">value</span><span class="ST4">=</span><span class="ST5">&quot;Insert Employee&quot;</span><span class="ST3">/</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:column</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:panelGrid</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:form</span><span class="ST6">&gt;</span>
<span class="ST6">&lt;/</span><span class="ST6">h:body</span><span class="ST6">&gt;</span>
<span class="ST3">&lt;/</span><span class="ST3">html</span><span class="ST3">&gt;</span>
</pre></body>
</html>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
<org-netbeans-modules-projectapi.jsf_2e_language>JSP</org-netbeans-modules-projectapi.jsf_2e_language>
<netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>

@ -0,0 +1,77 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pap.exam</groupId>
<artifactId>LabJuneauValidateUserInput</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>LabJuneauValidateUserInput-1.0</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<jakartaee>9.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

@ -38,7 +38,12 @@ public Company() {
public boolean insertEmployee(Employee e){return employeeList.add( e ); }
@Override
public boolean removeEmployee(Employee e){return employeeList.remove(e); }
public boolean removeEmployee(Employee e){
boolean b = employeeList.remove(e);
System.out.println(b);
return b;
}
@Override
public List<Employee> getEmployees(){return employeeList;}