Ajax Smajax

master
Caleb Fontenot 2024-01-23 13:22:06 +07:00
parent 1896014238
commit 4a115a4b42
180 changed files with 4784 additions and 0 deletions

10
.gitignore vendored

@ -74,3 +74,13 @@
/Semester 2/Assignments/EventsLabValueChangeListener_CalebFontenot/target/
/Semester 2/Assignments/EventsLabValueChangeListener/target/
/Semester 2/Assignments/Supplier_Parts_Calendar_Primefaces/target/
/Semester 2/Assignments/AjaxLab_CalebFontenot/target/
/Semester 2/Assignments/Review_JSF/target/
/Semester 2/Exams/FinalExamProblem1_CalebFontenot/target/
/Semester 2/Exams/FinalExamProblem3_CalebFontenot/target/
/Semester 2/Exams/FinalExamProblem2_CalebFontenot/target/
/Semester 2/Exams/FinalExamProblem4_CalebFontenot/target/
/Semester 3/Examples/ajax-examples/Ajax1_Echo/target/
/Semester 3/Examples/ajax-examples/Ajax2/target/
/Semester 2/Exams/Ajax3-Tags-Testing/target/
/Semester 2/Exams/Ajax4Listener/target/

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project"/>
<Scope Scope="All Faces Configurations"/>
</Scene>

@ -0,0 +1,18 @@
<?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-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
</properties>
</project-shared-configuration>

@ -0,0 +1,42 @@
<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>edu.slcc.asdv.caleb</groupId>
<artifactId>AjaxLab_CalebFontenot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>AjaxLab_CalebFontenot-1.0-SNAPSHOT</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakartaee>10.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.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,68 @@
/*
* 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.inject.Named;
import jakarta.enterprise.context.SessionScoped;
import java.io.Serializable;
/**
*
* @author caleb
*/
@Named(value="user")
@SessionScoped
public class UserBean implements Serializable{
private String name;
private String password;
/**
* Get the value of password
*
* @return the value of password
*/
public String getPassword()
{
return password;
}
/**
* Set the value of password
*
* @param password new value of password
*/
public void setPassword(String password)
{
this.password = password;
}
/**
* Get the value of name
*
* @return the value of name
*/
public String getName()
{
return name;
}
/**
* Set the value of name
*
* @param name new value of name
*/
public void setName(String name)
{
this.name = name;
}
/** Creates a new instance of UserBean */
public UserBean() {
}
}

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

@ -0,0 +1,20 @@
package edu.slcc.asdv.caleb.ajaxlab_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();
}
}

@ -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,9 @@
# Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
# Click nbfs://nbhost/SystemFileSystem/Templates/Other/properties.properties to edit this template
loginWindowTitle=Ajax Echo
loginHeading=Please Log-In
namePrompt=Name:
passwordPrompt=Password:
loginButtonText=Log-In
greeting=Welcome

@ -0,0 +1,7 @@
<?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="annotated"
version="4.0">
</beans>

@ -0,0 +1,32 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<faces-config version="4.0"
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-facesconfig_4_0.xsd">
<application>
<resource-bundle>
<base-name>messages.messages</base-name>
<var>msgs</var>
</resource-bundle>
</application>
</faces-config>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!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">
<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,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="6.0" 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">
<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,27 @@
<?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://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>#{msgs.loginWindowTitle}</title>
</h:head>
<h:body style="background:skyblue">
<h:form>
<h3>#{msgs.loginHeading}</h3>
<h:panelGrid columns="2">
#{msgs.namePrompt}
<h:inputText id="inputName" value="#{user.name}">
<f:ajax event="keyup" execute="@this" renderer="echo"/>
</h:inputText>
#{msgs.passwordPrompt}
<h:inputSecret id = "inputPassword" value="#{user.password}" size="8"/>
<h:commandButton value="#{msgs.loginButtonText}" action="welcome"/>
</h:panelGrid>
<br/>
<p>
<h:outputText id="id_echo" value="#{user.name}"/>
</p>
</h:form>
</h:body>
</html>

@ -0,0 +1,12 @@
<?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://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>#{msgs.loginWindowTitle}</title>
</h:head>
<h:body style="background: skyblue">
<h3>#{msgs.greeting} #{user.name}</h3>
</h:body>
</html>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project"/>
<Scope Scope="All Faces Configurations"/>
</Scene>

@ -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>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
<netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>

@ -0,0 +1,83 @@
<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>asdv</groupId>
<artifactId>Review_JSF</artifactId>
<version>1</version>
<packaging>war</packaging>
<name>Review_JSF-1</name>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<jakartaee>10.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>13.0.2</version>
<classifier>jakarta</classifier>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</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,53 @@
/*
* 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 _01_ajax;
import jakarta.inject.Named;
import jakarta.enterprise.context.RequestScoped;
/**
*
* @author asdv5
*/
@Named(value = "ajaxBean")
@RequestScoped
public class AjaxBean
{
private String inputText1;
private String inputText2;
private String outputText1;
public String getOutputText1() {
return inputText1 + ", " + inputText2;
}
public String getInputText1() {
return inputText1;
}
public void setInputText1(String inputText1) {
this.inputText1 = inputText1;
}
public String getInputText2() {
return inputText2;
}
public void setInputText2(String inputText2) {
this.inputText2 = inputText2;
}
/**
* Creates a new instance of AjaxBean
*/
public AjaxBean()
{
}
}

@ -0,0 +1,29 @@
/*
* 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 _02_injection;
import java.util.ArrayList;
import java.util.Arrays;
/**
*
* @author caleb
*/
public class ForInjection {
private ArrayList<String> list =
new ArrayList(Arrays.asList(new String[] {"John", "Mary"}));
public ArrayList<String> getList()
{
return list;
}
public void setList(ArrayList<String> list)
{
this.list = list;
}
}

@ -0,0 +1,37 @@
/*
* 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 _02_injection;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
/**
*
* @author caleb
*/
@Named(value="injectionBean")
@RequestScoped
public class InjectionBean {
@Inject
ForInjection fi;
/** Creates a new instance of InjectionBean */
public InjectionBean() {
}
public ForInjection getFi()
{
return fi;
}
public void setFi(ForInjection fi)
{
this.fi = fi;
}
}

@ -0,0 +1,20 @@
/*
* 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 _03_DAO_implementation_and_usage;
import java.sql.SQLException;
import java.util.List;
/**
*
* @author caleb
*/
public interface Dao<T> {
List<T> listAll() throws SQLException;
int insert(T t);
int delete(T t);
int update(T t);
int count();
}

@ -0,0 +1,31 @@
/*
* 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 _03_DAO_implementation_and_usage;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Named;
/**
*
* @author caleb
*/
@Named(value="daoBean")
@RequestScoped
public class DaoBean {
private Dao dao;
public DaoBean()
{
dao = new DaoObjectManipulator();
}
public Dao getDao()
{
return dao;
}
}

@ -0,0 +1,43 @@
/*
* 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 _03_DAO_implementation_and_usage;
import java.io.Serializable;
/**
*
* @author caleb
*/
public class DaoObject implements Serializable {
public DaoObject(int key1, String data1)
{
}
private int key1;
private String data1;
public String getData()
{
return data1;
}
public void setData(String data)
{
this.data1 = data;
}
public int getKey()
{
return key1;
}
public void setKey(int key)
{
this.key1 = key;
}
}

@ -0,0 +1,103 @@
/*
* 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 _03_DAO_implementation_and_usage;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class DaoObjectManipulator implements Dao<DaoObject>, Serializable
{
@Override
public List<DaoObject> listAll()
throws SQLException
{
// test exception code
//if ( true)
// throw new SQLException();
List<DaoObject> tableDao = new ArrayList<DaoObject>();
String databaseName = "dao_test";
String userName = "java";
String password = "8VCS49HT2xjsEZvC";
String URL2 = "com.mysql.jdbc.Driver";
Connection con = new UtilitiesDatabase().connection(
databaseName, userName, password, URL2);
PreparedStatement ps = null;
try
{
if (con == null)
{
throw new RuntimeException("cannot connect to database");
}
String table = "";
ResultSet rs = null;
String sqlStr = "SELECT * FROM dao";
//prepare statement
ps = con.prepareStatement(sqlStr);
//execute
rs = ps.executeQuery();
int row = 0;
while (rs.next())
{
int key = rs.getInt(1);
String data = rs.getString(2);
DaoObject dao = new DaoObject(key, data);
tableDao.add(dao);
row++;
}
}
catch (SQLException ex)
{
ex.printStackTrace();
}
finally
{
try
{
new UtilitiesDatabase().closeDatabaseConnection(con);
// close the resources
if (ps != null)
{
ps.close();
}
}
catch (SQLException sqle)
{
System.out.println(sqle);
sqle.printStackTrace();
throw sqle;
}
}
return tableDao;
}
@Override
public int insert(DaoObject t)
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
@Override
public int delete(DaoObject t)
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
@Override
public int update(DaoObject t)
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
@Override
public int count()
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
}

@ -0,0 +1,96 @@
/*
* 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 _03_DAO_implementation_and_usage;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
*
* @author asdv5
*/
public class UtilitiesDatabase
{
public Connection connection(
String databaseName,
String userName,
String password,
String URL2
) //throws InstantiationException, IllegalAccessException
{
/*
String databaseName = "suppliers_parts_23";
String userName = "root";
String password = "root";
String URL2 = "com.mysql.jdbc.Driver";
Connection con = null;
*/
Connection con;
try
{// Load Sun's jdbc driver
Class.forName(URL2).newInstance();
System.out.println("JDBC Driver loaded!");
}
catch (Exception e) // driver not found
{
System.err.println("Unable to load database driver");
System.err.println("Details : " + e);
return null;
}
String ip = "localhost"; //internet connection
String url = "jdbc:mysql://" + ip + ":3306/" + databaseName + "?allowPublicKeyRetrieval=true&useSSL=false";
try
{
con = DriverManager.getConnection(url, userName, password);
con.setReadOnly(false);
}
catch (Exception e)
{
System.err.println(e.toString());
return null;
}
System.out.println("connection successfull");
return con;
}
public void closeDatabaseConnection( Connection con)
{
try
{
if (con != null)
{
con.close();
}
}
catch (SQLException e)
{
System.out.println(e);
e.printStackTrace();
}
}
public static java.sql.Date stringDateToSqlDate(String sDate)
{
java.util.Date date = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try
{
date = sdf.parse(sDate);
}
catch (ParseException e)
{
e.printStackTrace();
}
return new java.sql.Date( date.getTime() );
}
}

@ -0,0 +1,103 @@
/*
* 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 _03_DAO_implementation_and_usage;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
*
* @author asdv5
*/
public class UtilitiesDatabase
{
public Connection connection(
String databaseName,
String userName,
String password,
String URL2
) //throws InstantiationException, IllegalAccessException
{
/*
String databaseName = "suppliers_parts_23";
String userName = "root";
String password = "root";
String URL2 = "com.mysql.jdbc.Driver";
Connection con = null;
*/
Connection con;
try
{// Load Sun's jdbc driver
Class.forName(URL2).newInstance();
System.out.println("JDBC Driver loaded!");
}
catch (Exception e) // driver not found
{
System.err.println("Unable to load database driver");
System.err.println("Details : " + e);
return null;
}
String ip = "localhost"; //internet connection
String url = "jdbc:mysql://" + ip + ":3306/" + databaseName + "?allowPublicKeyRetrieval=true&useSSL=false";
try
{
con = DriverManager.getConnection(url, userName, password);
con.setReadOnly(false);
}
catch (Exception e)
{
System.err.println(e.toString());
return null;
}
System.out.println("connection successfull");
return con;
}
public void closeDatabaseConnection( Connection con)
{
try
{
if (con != null)
{
con.close();
}
}
catch (SQLException e)
{
System.out.println(e);
e.printStackTrace();
}
}
public static java.sql.Date stringDateToSqlDate(String sDate)
{
java.util.Date date = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try
{
date = sdf.parse(sDate);
}
catch (ParseException e)
{
e.printStackTrace();
}
return new java.sql.Date( date.getTime() );
}
public static java.util.Date stringDateToJavaUtilitiesDate(String sDate)
{
java.sql.Date sqldate = stringDateToSqlDate(sDate);
return new java.util.Date(sqldate.getTime() );
}
}

@ -0,0 +1,20 @@
package asdv.review_jsf.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();
}
}

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

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!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">
<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,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="6.0" 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">
<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,109 @@
<?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"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form id="id_form1">
<h3>1 AJAX tag embedded</h3>
<h:inputText value="#{ajaxBean.inputText1}"/>
<br/>
<h:inputText value="#{ajaxBean.inputText2}">
<f:ajax event="keyup" execute="@this" render="id_form1:id_1 id_form1:id_2"/>
</h:inputText>
<br/>
<h:outputLabel id="id_1" value="#{ajaxBean.outputText1}"></h:outputLabel>
<br/>
<h:outputLabel id="id_2" value="#{ajaxBean.outputText1}"></h:outputLabel>
</h:form>
<h:form>
<h3>2 Class injection</h3>
<p:dataTable var="x" value="#{injectionBean.fi.getList()}">
<p:column>
#{x.toString()}
</p:column>
</p:dataTable>
</h:form>
<h:form>
<h3>3 DAO</h3>
#{daoBean.dao.listAll()}
</h:form>
<h:form>
<h:commandLink value="4 Custom Conversions" action="index"/>
</h:form>
<h:form>
<h:commandLink value="5 Custom Validations" action="index"/>
</h:form>
<h:form>
<h:commandLink value="6 DataTable - Primefaces pagination and its value-variable" action="index"/>
</h:form>
<h:form>
<h:commandLink value="7 DataTable - passing a parameter value to the bean" action="index"/>
</h:form>
<h:form>
<h:commandLink value="8 Action Listeners" action="index"/>
</h:form>
<h:form>
<h:commandLink value="9 Value Change Listeners" action="index"/>
</h:form>
<h:form>
<h:commandLink value="10 Dynamic select-one, select many" action="index"/>
</h:form>
<h:form>
<h:commandLink value="11 navigation via navigation rules" action="index"/>
</h:form>
<h:form>
<h:commandLink value="12 Messages JSF via FacesContex" action="index"/>
</h:form>
<h:form>
<h:commandLink value="13 Messsages Primefaces p:growl via FacesContex " action="index"/>
</h:form>
<h:form>
<h:commandLink value="14 catch exception in CDI bean - record exception in server and display p:grow message " action="index"/>
</h:form>
<h:form>
<h:commandLink value="15 handle_exception_before_rendering " action="index"/>
</h:form>
<h:form>
<h:commandLink value="16 calling javascipt methods form JSF" action="index"/>
</h:form>
<h:form>
<h:commandLink value="17 using CSS files in JSF" action="index"/>
</h:form>
<h:form>
<h:commandLink value="18 rendered attibute in connection to CDI Bean" action="index"/>
</h:form>
<h:form>
<h:commandLink value="19 EL -- arraylists, sets, maps" action="index"/>
</h:form>
<h:form>
<h:commandLink value="20 EL -- functions" action="index"/>
</h:form>
</h: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>
<netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
<org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
</properties>
</project-shared-configuration>

@ -0,0 +1,42 @@
<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>edu.slcc.asdv.caleb</groupId>
<artifactId>FinalExamProblem1_CalebFontenot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>FinalExamProblem1_CalebFontenot-1.0-SNAPSHOT</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakartaee>10.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>10.0.0</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,45 @@
package classes;
/*
* 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
*/
import jakarta.enterprise.context.SessionScoped;
import jakarta.inject.Named;
import java.io.Serializable;
/**
*
* @author caleb
*/
@Named(value = "pageNavigator")
@SessionScoped
public class PageNavigator implements Serializable {
/**
* Creates a new instance of PageNavigator
*/
public PageNavigator()
{
}
private String message;
public String getMessage()
{
return message;
}
public void setMessage(String message)
{
this.message = message;
}
public String determine()
{
int rand = (int) (Math.random() * 4) + 1;
String returnValue = "";
returnValue = "result" + rand + ".xhtml";
return returnValue;
}
}

@ -0,0 +1,39 @@
/*
* 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 classes;
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("textLengthValidator")
public class TextLengthValidator implements Validator {
/**
*
* @param context
* @param component
* @param value
* @throws ValidatorException
*/
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
{
String inputText = (String) value;
if (inputText.length() < 5) {
FacesMessage message = new FacesMessage("Input must be at least 5 characters long!");
throw new ValidatorException(message);
}
}
}

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

@ -0,0 +1,20 @@
package edu.slcc.asdv.caleb.finalexamproblem1_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();
}
}

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

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!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">
<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,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="5.0" 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">
<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>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>

@ -0,0 +1,21 @@
<?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="jakarta.faces.html"
xmlns:f="jakarta.faces.core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body style="text-align: center;">
<h:form>
<h1>JSF Navigation via Command Button</h1>
<p>
<br/><br/>
Your message: <h:inputText value="#{pageNavigator.message}">
<f:validator validatorId="textLengthValidator"/>
</h:inputText>
</p>
<h:commandButton value="Navigate to a random page between 1 and 4" action="#{pageNavigator.determine()}"/>
</h:form>
</h:body>
</html>

@ -0,0 +1,14 @@
<?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="jakarta.faces.html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body style="text-align: center;">
<h1>Result Page 1</h1>
<br/><br/>
<h3>Your message: #{pageNavigator.message}</h3>
</h:body>
</html>

@ -0,0 +1,14 @@
<?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="jakarta.faces.html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body style="text-align: center;">
<h1>Result Page 2</h1>
<br/><br/>
<h3>Your message: #{pageNavigator.message}</h3>
</h:body>
</html>

@ -0,0 +1,14 @@
<?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="jakarta.faces.html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body style="text-align: center;">
<h1>Result Page 3</h1>
<br/><br/>
<h3>Your message: #{pageNavigator.message}</h3>
</h:body>
</html>

@ -0,0 +1,14 @@
<?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="jakarta.faces.html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body style="text-align: center;">
<h1>Result Page 4</h1>
<br/><br/>
<h3>Your message: #{pageNavigator.message}</h3>
</h:body>
</html>

@ -0,0 +1,20 @@
<?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>
<netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>

@ -0,0 +1,53 @@
<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>edu.slcc.asdv.caleb</groupId>
<artifactId>FinalExamProblem2_CalebFontenot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>FinalExamProblem2_CalebFontenot-1.0-SNAPSHOT</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakartaee>10.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>13.0.2</version>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,75 @@
/*
* 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.inject.Named;
import jakarta.enterprise.context.SessionScoped;
import jakarta.faces.application.FacesMessage;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.primefaces.PrimeFaces;
import pojo.DatabaseManipulator;
import pojo.Passenger;
/**
*
* @author caleb
*/
@Named(value="passengerBean")
@SessionScoped
public class PassengerBean implements Serializable {
DatabaseManipulator dm = new DatabaseManipulator();
private Passenger selectedPassenger;
/**
* Get the value of selectedPassenger
*
* @return the value of selectedPassenger
*/
public Passenger getSelectedPassenger()
{
return selectedPassenger;
}
/**
* Set the value of selectedPassenger
*
* @param selectedPassenger new value of selectedPassenger
*/
public void setSelectedPassenger(Passenger selectedPassenger)
{
this.selectedPassenger = selectedPassenger;
}
public List<Passenger> getPassengers() {
List<Passenger> data = null;
try {
data = dm.listAll();
} catch (SQLException ex) {
Logger.getLogger(PassengerBean.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Fetched data from database!");
System.out.println(data);
return data;
}
/** Creates a new instance of PassengerBean */
public PassengerBean() {
}
public void showMessage() {
String messageContent = "You selected the " + selectedPassenger.getBirthday().toString() + "birthday.";
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Info", messageContent);
PrimeFaces.current().dialog().showMessageDynamic(message);
}
}

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

@ -0,0 +1,20 @@
package edu.slcc.asdv.caleb.finalexamproblem2_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();
}
}

@ -0,0 +1,85 @@
/*
* 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 pojo;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import pojo.Passenger;
/**
*
* @author caleb
*/
public class DatabaseManipulator {
public List<Passenger> listAll()
throws SQLException
{
// test exception code
//if ( true)
// throw new SQLException();
List<Passenger> passengerTable = new ArrayList<Passenger>();
String databaseName = "travel";
String userName = "java";
String password = "8VCS49HT2xjsEZvC";
String URL2 = "com.mysql.jdbc.Driver";
Connection con = new UtilitiesDatabase().connection(
databaseName, userName, password, URL2);
PreparedStatement ps = null;
try
{
if (con == null)
{
throw new RuntimeException("cannot connect to database");
}
String table = "";
ResultSet rs = null;
String sqlStr = "SELECT * FROM passenger";
//prepare statement
ps = con.prepareStatement(sqlStr);
//execute
rs = ps.executeQuery();
int row = 0;
while (rs.next())
{
int pid = rs.getInt(1);
String pname = rs.getString(2);
Date bdate = bdate = rs.getDate(3);
Passenger passenger = new Passenger(pid, pname, bdate);
passengerTable.add(passenger);
row++;
}
}
catch (Exception ex)
{
ex.printStackTrace();
throw ex;
}
finally
{
try
{
new UtilitiesDatabase().closeDatabaseConnection(con);
// close the resources
if (ps != null)
{
ps.close();
}
}
catch (SQLException sqle)
{
System.out.println(sqle);
sqle.printStackTrace();
throw sqle;
}
}
return passengerTable;
}
}

@ -0,0 +1,74 @@
/*
* 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 pojo;
import java.sql.Date;
/**
*
* @author caleb
*/
public class Passenger {
private int pid;
private String pname;
private Date birthday;
public Passenger(int pid, String pname, Date birthday)
{
this.pid = pid;
this.pname = pname;
this.birthday = birthday;
}
/**
* Get the value of birthday
*
* @return the value of birthday
*/
public Date getBirthday()
{
return birthday;
}
/**
* Set the value of birthday
*
* @param birthday new value of birthday
*/
public void setBirthday(Date birthday)
{
this.birthday = birthday;
}
public String getPname()
{
return pname;
}
public void setPname(String pname)
{
this.pname = pname;
}
public int getPid()
{
return pid;
}
public void setPid(int pid)
{
this.pid = pid;
}
@Override
public String toString()
{
return birthday.toString();
}
}

@ -0,0 +1,109 @@
/*
* 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 pojo;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
*
* @author asdv5
*/
public class UtilitiesDatabase
{
public static Connection connection(
String databaseName,
String userName,
String password,
String URL2
) //throws InstantiationException, IllegalAccessException
{
/*
String databaseName = "suppliers_parts_23";
String userName = "root";
String password = "root";
String URL2 = "com.mysql.jdbc.Driver";
Connection con = null;
*/
Connection con;
try
{// Load Sun's jdbc driver
Class.forName(URL2).newInstance();
System.out.println("JDBC Driver loaded!");
}
catch (Exception e) // driver not found
{
System.err.println("Unable to load database driver");
System.err.println("Details : " + e);
return null;
}
String ip = "localhost"; //internet connection
String url = "jdbc:mysql://" + ip + ":3306/" + databaseName + "?allowPublicKeyRetrieval=true&useSSL=false";
try
{
con = DriverManager.getConnection(url, userName, password);
con.setReadOnly(false);
}
catch (Exception e)
{
System.err.println(e.toString());
return null;
}
System.out.println("connection successful!");
return con;
}
public void closeDatabaseConnection( Connection con)
{
try
{
if (con != null)
{
con.close();
}
}
catch (SQLException e)
{
System.out.println(e);
e.printStackTrace();
}
}
public static java.sql.Date stringDateToSqlDate(String sDate)
{
java.util.Date date = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try
{
date = sdf.parse(sDate);
}
catch (ParseException e)
{
e.printStackTrace();
}
return new java.sql.Date( date.getTime() );
}
public static java.util.Date stringDateToJavaUtilitiesDate(String sDate)
{
java.sql.Date sqldate = stringDateToSqlDate(sDate);
return new java.util.Date(sqldate.getTime() );
}
public static void main(String[] args)
{
connection("travel", "java", "8VCS49HT2xjsEZvC", "com.mysql.jdbc.Driver");
}
}

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

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!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">
<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,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="5.0" 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">
<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>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>

@ -0,0 +1,40 @@
<?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="jakarta.faces.html"
xmlns:f="jakarta.faces.core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<p:growl id="messages" showDetail="true" />
<h:dataTable value="#{passengerBean.getPassengers()}" var="currentValue" border="1">
<f:facet name="header">
pid
</f:facet>
<f:facet name="header">
pname
</f:facet>
<f:facet name="header">
birthday
</f:facet>
<h:column>
#{currentValue.pid}
</h:column>
<h:column>
#{currentValue.pname}
</h:column>
<h:column>
#{currentValue.birthday}
</h:column>
</h:dataTable>
<h:selectOneMenu id="select-birthday" value="#{passengerBean.selectedPassenger}">
<f:selectItems value="#{passengerBean.getPassengers()}" />
</h:selectOneMenu>
<p:commandButton value="Show Birthday info" action="#{passengerBean.showMessage}" update="messages" />
</h:form>
</h:body>
</html>

@ -0,0 +1,20 @@
<?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>
<netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>

@ -0,0 +1,42 @@
<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>edu.slcc.asdv.caleb</groupId>
<artifactId>FinalExamProblem3_CalebFontenot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>FinalExamProblem3_CalebFontenot-1.0-SNAPSHOT</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakartaee>10.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.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</build>
</project>

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

@ -0,0 +1,20 @@
package edu.slcc.asdv.caleb.finalexamproblem3_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();
}
}

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

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!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">
<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,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="5.0" 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">
<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>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Start Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

@ -0,0 +1,20 @@
<?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>
<netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>

@ -0,0 +1,42 @@
<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>edu.slcc.asdv.caleb</groupId>
<artifactId>FinalExamProblem4_CalebFontenot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>FinalExamProblem4_CalebFontenot-1.0-SNAPSHOT</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakartaee>10.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.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,50 @@
/*
* 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.inject.Named;
import jakarta.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author caleb
*/
@Named(value="primeArrayController")
@SessionScoped
public class PrimeArrayController implements Serializable {
ArrayList<String> validPrimes = new ArrayList<>();
private String primeToAdd;
public String getPrimeToAdd()
{
return primeToAdd;
}
public void setPrimeToAdd(String primeToAdd)
{
this.primeToAdd = primeToAdd;
validPrimes.add(primeToAdd);
}
public ArrayList<String> getValidPrimes()
{
return validPrimes;
}
public void setValidPrimes(ArrayList<String> validPrimes)
{
this.validPrimes = validPrimes;
}
/** Creates a new instance of PrimeArrayController */
public PrimeArrayController() {
}
}

@ -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 beans;
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;
import java.math.BigInteger;
/**
*
* @author caleb
*/
@FacesValidator("primeNumberValidator")
public class PrimeNumberValidator implements Validator {
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
{
BigInteger bigInt = new BigInteger((String) value);
if (!bigInt.isProbablePrime(100)) {
FacesMessage message = new FacesMessage("That is not a valid prime number.");
throw new ValidatorException(message);
}
}
}

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

@ -0,0 +1,20 @@
package edu.slcc.asdv.caleb.finalexamproblem4_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();
}
}

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

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!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">
<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,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="5.0" 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">
<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>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>

@ -0,0 +1,32 @@
<?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="jakarta.faces.html"
xmlns:f="jakarta.faces.core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<h1>Type in prime numbers only</h1>
<br/>
<h:dataTable value="#{primeArrayController.validPrimes}" var="currentValue" rendered="#{primeArrayController.validPrimes.size() > 0}" border="1">
<f:facet name="header">
Valid Primes
</f:facet>
<h:column>
#{currentValue}
</h:column>
</h:dataTable>
<br/>
<p>
Please type a number to insert into the data table.
<br/><br/>
Test if a number is prime:
<h:inputText value="#{primeArrayController.primeToAdd}">
<f:validator validatorId="primeNumberValidator"/>
</h:inputText>
</p>
</h:form>
</h:body>
</html>

Binary file not shown.

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project"/>
<Scope Scope="All Faces Configurations"/>
</Scene>

@ -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>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
<netbeans.hint.jdkPlatform>JDK_15__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>asdv</groupId>
<artifactId>Ajax1</artifactId>
<version>1</version>
<packaging>war</packaging>
<name>Ajax1-Echo</name>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<jakartaee>10.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.8.1</version>
<configuration>
<source>11</source>
<target>11</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 asdv.ajax1;
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 asdv.ajax1.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();
}
}

@ -0,0 +1,36 @@
package beans;
import java.io.Serializable;
import jakarta.inject.Named;
import jakarta.enterprise.context.SessionScoped;
@Named("user")
@SessionScoped
public class UserBean implements Serializable
{
private String name = "";
private String password;
public String getName()
{
return name;
}
public void setName(String newValue)
{
System.out.println(newValue);
name = newValue;
}
public String getPassword()
{
return password;
}
public void setPassword(String newValue)
{
password = newValue;
}
}

@ -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 @@
loginWindowTitle=Ajax Echo
loginHeading=Please Log In
namePrompt=Name:
passwordPrompt=Password:
loginButtonText=Log In
greeting=Welcome

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

@ -0,0 +1,36 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<faces-config version="4.0"
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-facesconfig_4_0.xsd">
<application>
<resource-bundle>
<base-name>messages.messages</base-name>
<var>msgs</var>
</resource-bundle>
</application>
</faces-config>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!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">
<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,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="6.0" 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">
<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>

Some files were not shown because too many files have changed in this diff Show More