Add CT5106 Software Engineering II
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="target/generated-sources/annotations">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="ignore_optional_problems" value="true"/>
|
||||
<attribute name="m2e-apt" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="ignore_optional_problems" value="true"/>
|
||||
<attribute name="m2e-apt" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>assignment5</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1699287495979</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.apt.aptEnabled=false
|
@ -0,0 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=17
|
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="jpa" name="JPA">
|
||||
<configuration>
|
||||
<setting name="validation-enabled" value="true" />
|
||||
<datasource-mapping />
|
||||
<naming-strategy-map />
|
||||
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
</module>
|
@ -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,22 @@
|
||||
<?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>9.1-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
|
||||
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv610ee9</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
|
||||
<org-netbeans-modules-projectapi.jsf_2e_language>JSP</org-netbeans-modules-projectapi.jsf_2e_language>
|
||||
<org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
|
||||
<netbeans.hint.jdkPlatform>JDK_17</netbeans.hint.jdkPlatform>
|
||||
</properties>
|
||||
</project-shared-configuration>
|
@ -0,0 +1,91 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.mycompany</groupId>
|
||||
<artifactId>assignment5</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>assignment5</name>
|
||||
|
||||
<properties>
|
||||
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<jakartaee>10.0.0</jakartaee>
|
||||
<primefaces.version>13.0.2</primefaces.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>jakarta.platform</groupId>
|
||||
<artifactId>jakarta.jakartaee-api</artifactId>
|
||||
<version>${jakartaee}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jakarta.platform</groupId>
|
||||
<artifactId>jakarta.jakartaee-web-api</artifactId>
|
||||
<version>${jakartaee}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.primefaces</groupId>
|
||||
<artifactId>primefaces</artifactId>
|
||||
<version>${primefaces.version}</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>17</source>
|
||||
<target>17</target>
|
||||
<compilerArguments>
|
||||
<endorseddirs>${endorsed.dir}</endorseddirs>
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.3.2</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,90 @@
|
||||
/*
|
||||
* 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 data.Todo;
|
||||
import services.TodoFacade;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.ejb.EJB;
|
||||
import jakarta.enterprise.context.RequestScoped;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.inject.Named;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrew
|
||||
*/
|
||||
@Named("todoBean")
|
||||
@RequestScoped
|
||||
public class TodoBean {
|
||||
@EJB
|
||||
private TodoFacade todoFacade;
|
||||
private String category;
|
||||
private String description;
|
||||
private int priority;
|
||||
private long id;
|
||||
private Todo todo;
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
// get todoId
|
||||
String todoIdParam = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("todoId");
|
||||
|
||||
// if the todoId exists
|
||||
if (todoIdParam != null) {
|
||||
// parse out id, and get a reference to the Todo object that id pertains to
|
||||
id = Long.parseLong(todoIdParam);
|
||||
todo = todoFacade.find(id);
|
||||
|
||||
// if that todo exists, get fields
|
||||
if (todo != null) {
|
||||
category = todo.getCategory();
|
||||
description = todo.getDescription();
|
||||
priority = todo.getPriority();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getters and sestters
|
||||
public long getId() { return id; }
|
||||
public void setId(long id) { this.id = id; }
|
||||
|
||||
public String getCategory() { return category; }
|
||||
public void setCategory(String category) { this.category = category; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
|
||||
public int getPriority() { return priority; }
|
||||
public void setPriority(int priority) { this.priority = priority; }
|
||||
|
||||
|
||||
// method to add a new todo item
|
||||
public String add() {
|
||||
Todo newTodo = new Todo();
|
||||
newTodo.setCategory(category);
|
||||
newTodo.setDescription(description);
|
||||
newTodo.setPriority(priority);
|
||||
|
||||
todoFacade.create(newTodo);
|
||||
return "success";
|
||||
}
|
||||
|
||||
// method to update a todo item
|
||||
public String update() {
|
||||
todo.setCategory(category);
|
||||
todo.setDescription(description);
|
||||
todo.setPriority(priority);
|
||||
|
||||
todoFacade.edit(todo);
|
||||
return "success";
|
||||
}
|
||||
|
||||
// method to delete a todo item
|
||||
public String delete() {
|
||||
todoFacade.remove(todo);
|
||||
return "success";
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 data.Todo;
|
||||
import services.TodoFacade;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.ejb.EJB;
|
||||
import jakarta.enterprise.context.RequestScoped;
|
||||
import jakarta.inject.Named;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Named("todoListBean")
|
||||
@RequestScoped
|
||||
public class TodoList implements Serializable {
|
||||
// inner class to represent table layout
|
||||
static public class ColumnModel implements Serializable {
|
||||
private String header;
|
||||
private String property;
|
||||
|
||||
// columnmodel constructor
|
||||
public ColumnModel(String header, String property) {
|
||||
this.header = header;
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
// getters and setters
|
||||
public String getHeader() { return header; }
|
||||
public void setHeader(String header) { this.header = header; }
|
||||
|
||||
public String getProperty() { return property; }
|
||||
public void setProperty(String property) { this.property = property; }
|
||||
}
|
||||
|
||||
@EJB
|
||||
private TodoFacade todoFacade;
|
||||
private List<Todo> todoList;
|
||||
private List<ColumnModel> columns;
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
columns = new ArrayList<>();
|
||||
columns.add(new ColumnModel("Category", "category"));
|
||||
columns.add(new ColumnModel("Description", "description"));
|
||||
columns.add(new ColumnModel("Priority", "priority"));
|
||||
|
||||
todoList = todoFacade.findAll();
|
||||
}
|
||||
|
||||
|
||||
public List<Todo> getTodoList() { return todoList; }
|
||||
public void setTodoList(List<Todo> todoList) { this.todoList = todoList; }
|
||||
|
||||
public List<ColumnModel> getColumnModel() { return columns; }
|
||||
public void setColumnModel(List<ColumnModel> columns) { this.columns = columns; }
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.mycompany.assignment5;
|
||||
|
||||
import jakarta.ws.rs.ApplicationPath;
|
||||
import jakarta.ws.rs.core.Application;
|
||||
|
||||
/**
|
||||
* Configures JAX-RS for the application.
|
||||
* @author Juneau
|
||||
*/
|
||||
@ApplicationPath("resources")
|
||||
public class JAXRSConfiguration extends Application {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.mycompany.assignment5.resources;
|
||||
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
@Path("javaee8")
|
||||
public class JavaEE8Resource {
|
||||
|
||||
@GET
|
||||
public Response ping(){
|
||||
return Response
|
||||
.ok("ping")
|
||||
.build();
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 data;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrew
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="todo")
|
||||
public class Todo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Column(name="ID")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
private String category;
|
||||
private String description;
|
||||
private int priority;
|
||||
|
||||
// empty constructor
|
||||
public Todo() {}
|
||||
|
||||
// constructor with all fields
|
||||
public Todo(Long id, String category, String description, int priority) {
|
||||
this.id = id;
|
||||
this.category = category;
|
||||
this.description = description;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
// Getters and setters
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public int getPriority() { return priority; }
|
||||
public void setPriority(int priority) { this.priority = priority; }
|
||||
|
||||
public String getCategory() { return category; }
|
||||
public void setCategory(String category) { this.category= category; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description= description; }
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 services;
|
||||
|
||||
import java.util.List;
|
||||
import jakarta.persistence.EntityManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrew
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class AbstractFacade<T> {
|
||||
|
||||
private Class<T> entityClass;
|
||||
|
||||
public AbstractFacade(Class<T> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
}
|
||||
|
||||
protected abstract EntityManager getEntityManager();
|
||||
|
||||
public void create(T entity) {
|
||||
getEntityManager().persist(entity);
|
||||
getEntityManager().flush();
|
||||
}
|
||||
|
||||
public void edit(T entity) {
|
||||
getEntityManager().merge(entity);
|
||||
}
|
||||
|
||||
public void remove(T entity) {
|
||||
getEntityManager().remove(getEntityManager().merge(entity));
|
||||
}
|
||||
|
||||
public T find(Object id) {
|
||||
return getEntityManager().find(entityClass, id);
|
||||
}
|
||||
|
||||
public List<T> findAll() {
|
||||
jakarta.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
|
||||
cq.select(cq.from(entityClass));
|
||||
return getEntityManager().createQuery(cq).getResultList();
|
||||
}
|
||||
|
||||
public List<T> findRange(int[] range) {
|
||||
jakarta.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
|
||||
cq.select(cq.from(entityClass));
|
||||
jakarta.persistence.Query q = getEntityManager().createQuery(cq);
|
||||
q.setMaxResults(range[1] - range[0] + 1);
|
||||
q.setFirstResult(range[0]);
|
||||
return q.getResultList();
|
||||
}
|
||||
|
||||
public int count() {
|
||||
jakarta.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
|
||||
jakarta.persistence.criteria.Root<T> rt = cq.from(entityClass);
|
||||
cq.select(getEntityManager().getCriteriaBuilder().count(rt));
|
||||
jakarta.persistence.Query q = getEntityManager().createQuery(cq);
|
||||
return ((Long) q.getSingleResult()).intValue();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 services;
|
||||
|
||||
import data.Todo;
|
||||
import jakarta.ejb.Stateless;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrew
|
||||
*/
|
||||
@Stateless
|
||||
public class TodoFacade extends AbstractFacade<Todo> {
|
||||
@PersistenceContext(unitName = "MyPu")
|
||||
private EntityManager em;
|
||||
|
||||
@Override
|
||||
protected EntityManager getEntityManager() {
|
||||
return em;
|
||||
}
|
||||
|
||||
public TodoFacade() {
|
||||
super(Todo.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence version="2.2" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
|
||||
<!-- Define Persistence Unit -->
|
||||
<persistence-unit name="MyPu" transaction-type="JTA">
|
||||
<jta-data-source>jdbc/softeng</jta-data-source>
|
||||
<exclude-unlisted-classes>false</exclude-unlisted-classes>
|
||||
<properties>
|
||||
<property name="jakarta.persistence.schema-generation.database.action" value="create"/>
|
||||
</properties>
|
||||
</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,52 @@
|
||||
<?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="2.3"
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd">
|
||||
|
||||
<!-- routing rules -->
|
||||
<navigation-rule>
|
||||
<from-view-id>/todo.xhtml</from-view-id>
|
||||
<navigation-case>
|
||||
<from-outcome>success</from-outcome>
|
||||
<to-view-id>/index.xhtml</to-view-id>
|
||||
</navigation-case>
|
||||
</navigation-rule>
|
||||
|
||||
<navigation-rule>
|
||||
<from-view-id>/edit.xhtml</from-view-id>
|
||||
<navigation-case>
|
||||
<from-outcome>success</from-outcome>
|
||||
<to-view-id>/index.xhtml</to-view-id>
|
||||
</navigation-case>
|
||||
</navigation-rule>
|
||||
|
||||
<navigation-rule>
|
||||
<from-view-id>/delete.xhtml</from-view-id>
|
||||
<navigation-case>
|
||||
<from-outcome>success</from-outcome>
|
||||
<to-view-id>/index.xhtml</to-view-id>
|
||||
</navigation-case>
|
||||
</navigation-rule>
|
||||
|
||||
</faces-config>
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
|
||||
<!--
|
||||
Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program and the accompanying materials are made available under the
|
||||
terms of the Eclipse Public License v. 2.0, which is available at
|
||||
http://www.eclipse.org/legal/epl-2.0.
|
||||
|
||||
This Source Code may also be made available under the following Secondary
|
||||
Licenses when the conditions for such availability set forth in the
|
||||
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
|
||||
version 2 with the GNU Classpath Exception, which is available at
|
||||
https://www.gnu.org/software/classpath/license.html.
|
||||
|
||||
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
||||
-->
|
||||
<glassfish-web-app error-url="">
|
||||
<class-loader delegate="true"/>
|
||||
<jsp-config>
|
||||
<property name="keepgenerated" value="true">
|
||||
<description>Keep a copy of the generated servlet class' java code.</description>
|
||||
</property>
|
||||
</jsp-config>
|
||||
</glassfish-web-app>
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app version="4.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">
|
||||
<context-param>
|
||||
<param-name>jakarta.faces.PROJECT_STAGE</param-name>
|
||||
<param-value>Development</param-value>
|
||||
</context-param>
|
||||
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
</session-config>
|
||||
|
||||
<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>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>faces/index.xhtml</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
<mime-mapping>
|
||||
<extension>eot</extension>
|
||||
<mime-type>application/vnd.ms-fontobject</mime-type>
|
||||
</mime-mapping>
|
||||
<mime-mapping>
|
||||
<extension>ttf</extension>
|
||||
<mime-type>application/x-font-ttf</mime-type>
|
||||
</mime-mapping>
|
||||
<mime-mapping>
|
||||
<extension>woff</extension>
|
||||
<mime-type>application/x-font-woff</mime-type>
|
||||
</mime-mapping>
|
||||
<mime-mapping>
|
||||
<extension>woff2</extension>
|
||||
<mime-type>application/x-font-woff2</mime-type>
|
||||
</mime-mapping>
|
||||
</web-app>
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- File: delete.xhtml -->
|
||||
<!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:p="http://primefaces.org/ui">
|
||||
<h:head>
|
||||
|
||||
</h:head>
|
||||
<h:body>
|
||||
<h:form>
|
||||
<p:panel header="Delete Todo Item">
|
||||
<p:panelGrid columns="1" layout="grid">
|
||||
<!-- show details of item to be deleted in a non-editable way-->
|
||||
<p:outputLabel for="todo-category" value="Category" />
|
||||
<p:inputText id="todo-category" value='#{todoBean.getCategory()}' readonly="true"/>
|
||||
|
||||
<p:outputLabel for="todo-description" value="Description" />
|
||||
<p:inputText id="todo-description" value='#{todoBean.getDescription()}' readonly="true"/>
|
||||
|
||||
<p:outputLabel for="todo-priority" value="Priority" />
|
||||
<p:inputText id="todo-priority" value='#{todoBean.getPriority()}' readonly="true"/>
|
||||
|
||||
<p:commandButton value="Confirm Delete" action="#{todoBean.delete}" ajax="false"/>
|
||||
</p:panelGrid>
|
||||
<input type="hidden" name="todoId" value='#{param.todoId}'/>
|
||||
</p:panel>
|
||||
</h:form>
|
||||
</h:body>
|
||||
</html>
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- File: edit.xhtml -->
|
||||
<!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:p="http://primefaces.org/ui"
|
||||
xmlns:f="http://java.sun.com/jsf/core">
|
||||
<h:head></h:head>
|
||||
<h:body>
|
||||
<h:form>
|
||||
<p:panel header="Update Todo">
|
||||
<p:panelGrid columns="1">
|
||||
<p:outputLabel for="todo-category" value="Category"/>
|
||||
<p:inputText id="todo-category" value='#{todoBean.category}'/>
|
||||
|
||||
<p:outputLabel for="todo-description" value="Description"/>
|
||||
<p:inputText id="todo-description" value='#{todoBean.description}'/>
|
||||
|
||||
<p:outputLabel value="Priority"/>
|
||||
<p:selectOneRadio id="todo-priority" value='#{todoBean.priority}'>
|
||||
<f:selectItem itemLabel="High" itemValue="1"/>
|
||||
<f:selectItem itemLabel="Medium" itemValue="2"/>
|
||||
<f:selectItem itemLabel="Low" itemValue="3"/>
|
||||
</p:selectOneRadio>
|
||||
|
||||
<p:commandButton value="Update" action="#{todoBean.update}"/>
|
||||
</p:panelGrid>
|
||||
<input type="hidden" name="todoId" value='#{param.todoId}'/>
|
||||
</p:panel>
|
||||
</h:form>
|
||||
</h:body>
|
||||
</html>
|
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- File: result.xhtml -->
|
||||
<!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:f="http://java.sun.com/jsf/core"
|
||||
xmlns:h="http://java.sun.com/jsf/html"
|
||||
xmlns:p="http://primefaces.org/ui">
|
||||
<h:head></h:head>
|
||||
<h:body>
|
||||
<p:link outcome="todo" value="Create new Todo item"/>
|
||||
<p:dataTable value="#{todoListBean.todoList}" var="todo">
|
||||
<p:column headerText="Category">
|
||||
<h:outputText value="#{todo.category}"/>
|
||||
</p:column>
|
||||
|
||||
<p:column headerText="Description">
|
||||
<h:outputText value="#{todo.description}"/>
|
||||
</p:column>
|
||||
|
||||
<p:column headerText="Priority">
|
||||
<h:outputText value="#{todo.priority}"/>
|
||||
</p:column>
|
||||
|
||||
<p:column headerText="Edit">
|
||||
<p:link value="Edit" outcome="edit">
|
||||
<f:param name="todoId" value="#{todo.id}"/>
|
||||
</p:link>
|
||||
</p:column>
|
||||
|
||||
<p:column headerText="Delete">
|
||||
<p:link value="Delete" outcome="delete">
|
||||
<f:param name="todoId" value="#{todo.id}"/>
|
||||
</p:link>
|
||||
</p:column>
|
||||
</p:dataTable>
|
||||
</h:body>
|
||||
</html>
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- File: todo.xhtml -->
|
||||
<!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:p="http://primefaces.org/ui"
|
||||
xmlns:f="http://java.sun.com/jsf/core">
|
||||
<h:head></h:head>
|
||||
<h:body>
|
||||
<h:form>
|
||||
<p:panel header="Create Todo Item">
|
||||
<h:panelGrid columns="1">
|
||||
<p:outputLabel for="todo-category" value="Category"/>
|
||||
<p:inputText id="todo-category" value='#{todoBean.category}'/>
|
||||
|
||||
<p:outputLabel for="todo-description" value="Description"/>
|
||||
<p:inputText id="todo-description" value='#{todoBean.description}'/>
|
||||
|
||||
<p:outputLabel value="Priority"/>
|
||||
<p:selectOneRadio id="todo-priority" value='#{todoBean.priority}'>
|
||||
<f:selectItem itemLabel="High" itemValue="1"/>
|
||||
<f:selectItem itemLabel="Medium" itemValue="2"/>
|
||||
<f:selectItem itemLabel="Low" itemValue="3"/>
|
||||
</p:selectOneRadio>
|
||||
|
||||
<p:commandButton value="Create" action="#{todoBean.add}"/>
|
||||
</h:panelGrid>
|
||||
</p:panel>
|
||||
</h:form>
|
||||
</h:body>
|
||||
</html>
|
Reference in New Issue
Block a user