Ajax Smajax
This commit is contained in:
@@ -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>
|
42
Semester 2/Exams/FinalExamProblem1_CalebFontenot/pom.xml
Normal file
42
Semester 2/Exams/FinalExamProblem1_CalebFontenot/pom.xml
Normal file
@@ -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>
|
53
Semester 2/Exams/FinalExamProblem2_CalebFontenot/pom.xml
Normal file
53
Semester 2/Exams/FinalExamProblem2_CalebFontenot/pom.xml
Normal file
@@ -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>
|
42
Semester 2/Exams/FinalExamProblem3_CalebFontenot/pom.xml
Normal file
42
Semester 2/Exams/FinalExamProblem3_CalebFontenot/pom.xml
Normal file
@@ -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>
|
42
Semester 2/Exams/FinalExamProblem4_CalebFontenot/pom.xml
Normal file
42
Semester 2/Exams/FinalExamProblem4_CalebFontenot/pom.xml
Normal file
@@ -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>
|
Reference in New Issue
Block a user