summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.classpath12
-rw-r--r--.metadata/WebContent/WEB-INF/faces-config.pageflow51
-rw-r--r--.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--.settings/org.eclipse.jpt.core.prefs3
-rw-r--r--.settings/org.eclipse.jpt.entitygen.jcatalog.jcatalogbin0 -> 1597 bytes
-rw-r--r--.settings/org.eclipse.jst.common.project.facet.core.prefs4
-rw-r--r--.settings/org.eclipse.wst.common.project.facet.core.prefs.xml12
-rw-r--r--.settings/org.eclipse.wst.common.project.facet.core.xml8
-rw-r--r--.settings/org.eclipse.wst.ws.service.policy.prefs2
-rw-r--r--WebContent/WEB-INF/faces-config.xml211
-rw-r--r--WebContent/WEB-INF/lib/mysql-connector-java-5.1.37-bin.jarbin0 -> 985603 bytes
-rw-r--r--WebContent/WEB-INF/web.xml8
-rw-r--r--src/META-INF/persistence.xml13
-rw-r--r--src/beans/CategoryManager.java8
-rw-r--r--src/beans/ContactManager.java5
-rw-r--r--src/beans/ProductManager.java8
-rw-r--r--src/beans/UserManager.java148
-rw-r--r--src/jpa/Category.java125
-rw-r--r--src/jpa/Product.java94
-rw-r--r--src/jpa/User.java17
20 files changed, 291 insertions, 445 deletions
diff --git a/.classpath b/.classpath
index fa0a137..0168508 100644
--- a/.classpath
+++ b/.classpath
@@ -1,8 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="oracle.eclipse.tools.glassfish.lib.system">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.web"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-8-openjdk">
+ <attributes>
+ <attribute name="owner.project.facets" value="java"/>
+ </attributes>
+ </classpathentry>
<classpathentry kind="output" path="build/classes"/>
</classpath>
diff --git a/.metadata/WebContent/WEB-INF/faces-config.pageflow b/.metadata/WebContent/WEB-INF/faces-config.pageflow
new file mode 100644
index 0000000..96f5427
--- /dev/null
+++ b/.metadata/WebContent/WEB-INF/faces-config.pageflow
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pageflow:Pageflow xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pageflow="http://www.sybase.com/suade/pageflow" id="pf14482039175930" configfile="/JCatalog/WebContent/WEB-INF/faces-config.xml">
+ <nodes xsi:type="pageflow:PFPage" name="pages/home.xhtml" x="338" y="199" id="pf14482039422861" referenceLink="//@navigationRule.3/@navigationCase.2/@toViewId|" outlinks="pf14482039422862 pf14482039422863 pf14482039422864" inlinks="pf14482039422865" path="/pages/home.xhtml"/>
+ <nodes xsi:type="pageflow:PFPage" name="pages/contact.xhtml" x="986" y="625" id="pf14482039422866" referenceLink="//@navigationRule.6/@navigationCase.1/@toViewId|" outlinks="pf14482039422867 pf14482039422868 pf14482039422869" inlinks="pf14482039422862 pf144820394228610 pf144820394228611 pf144820394228612 pf14482039422867 pf144820394228613 pf144820394228614" path="/pages/contact.xhtml"/>
+ <nodes xsi:type="pageflow:PFPage" name="pages/login.xhtml" x="770" y="423" id="pf144820394228615" referenceLink="//@navigationRule.6/@navigationCase.3/@toViewId|" outlinks="pf144820394228610 pf144820394228616 pf144820394228617 pf144820394228618 pf144820394228619" inlinks="pf14482039422863 pf144820394228616 pf144820394228618 pf144820394228620 pf14482039422869 pf144820394228621 pf144820394228622" path="/pages/login.xhtml"/>
+ <nodes xsi:type="pageflow:PFPage" name="pages/categories.xhtml" x="554" y="646" id="pf144820394228623" referenceLink="//@navigationRule.6/@navigationCase.2/@toViewId|" outlinks="pf144820394228611 pf144820394228620 pf144820394228624 pf144820394228625" inlinks="pf14482039422864 pf144820394228617 pf144820394228624 pf144820394228626 pf14482039422868 pf144820394228627 pf144820394228628" path="/pages/categories.xhtml"/>
+ <nodes xsi:type="pageflow:PFPage" name="pages/greeting.xhtml" x="122" y="401" id="pf144820394228629" referenceLink="//@navigationRule.3/@fromViewId|" outlinks="pf144820394228612 pf144820394228626 pf14482039422865" inlinks="pf144820394228619" path="/pages/greeting.xhtml"/>
+ <nodes xsi:type="pageflow:PFPage" name="pages/products.xhtml" x="338" y="646" id="pf144820394228630" referenceLink="//@navigationRule.6/@navigationCase.0/@toViewId|" outlinks="pf144820394228613 pf144820394228627 pf144820394228621" inlinks="pf144820394228625 pf144820394228631" path="/pages/products.xhtml"/>
+ <nodes xsi:type="pageflow:PFPage" name="pages/product.xhtml" x="122" y="848" id="pf144820394228632" referenceLink="//@navigationRule.6/@fromViewId|" outlinks="pf144820394228631 pf144820394228614 pf144820394228628 pf144820394228622" path="/pages/product.xhtml"/>
+ <links id="pf14482039422862" target="pf14482039422866" source="pf14482039422861" outcome="contact"/>
+ <links id="pf14482039422863" target="pf144820394228615" source="pf14482039422861" outcome="login"/>
+ <links id="pf14482039422864" target="pf144820394228623" source="pf14482039422861" outcome="categories"/>
+ <links id="pf144820394228610" target="pf14482039422866" source="pf144820394228615" outcome="contact"/>
+ <links id="pf144820394228617" target="pf144820394228623" source="pf144820394228615" outcome="categories"/>
+ <links id="pf144820394228619" target="pf144820394228629" source="pf144820394228615" outcome="success"/>
+ <links id="pf144820394228611" target="pf14482039422866" source="pf144820394228623" outcome="contact"/>
+ <links id="pf144820394228620" target="pf144820394228615" source="pf144820394228623" outcome="login"/>
+ <links id="pf144820394228625" target="pf144820394228630" source="pf144820394228623" outcome="select"/>
+ <links id="pf144820394228612" target="pf14482039422866" source="pf144820394228629" outcome="contact"/>
+ <links id="pf144820394228626" target="pf144820394228623" source="pf144820394228629" outcome="categories"/>
+ <links id="pf14482039422865" target="pf14482039422861" source="pf144820394228629" outcome="home"/>
+ <links id="pf14482039422868" target="pf144820394228623" source="pf14482039422866" outcome="categories"/>
+ <links id="pf14482039422869" target="pf144820394228615" source="pf14482039422866" outcome="login"/>
+ <links id="pf144820394228613" target="pf14482039422866" source="pf144820394228630" outcome="contact"/>
+ <links id="pf144820394228627" target="pf144820394228623" source="pf144820394228630" outcome="categories"/>
+ <links id="pf144820394228621" target="pf144820394228615" source="pf144820394228630" outcome="login"/>
+ <links id="pf144820394228631" target="pf144820394228630" source="pf144820394228632" outcome="products"/>
+ <links id="pf144820394228614" target="pf14482039422866" source="pf144820394228632" outcome="contact"/>
+ <links id="pf144820394228628" target="pf144820394228623" source="pf144820394228632" outcome="categories"/>
+ <links id="pf144820394228622" target="pf144820394228615" source="pf144820394228632" outcome="login"/>
+ <links id="pf144820394228616" target="pf144820394228615" source="pf144820394228615" outcome="login">
+ <bendPoints d1Height="-36" d2Height="-36"/>
+ <bendPoints d1Width="-64" d1Height="-36" d2Width="-64" d2Height="-36"/>
+ <bendPoints d1Width="-64" d2Width="-64"/>
+ </links>
+ <links id="pf144820394228618" target="pf144820394228615" source="pf144820394228615" outcome="failure">
+ <bendPoints d1Height="-66" d2Height="-66"/>
+ <bendPoints d1Width="-94" d1Height="-66" d2Width="-94" d2Height="-66"/>
+ <bendPoints d1Width="-94" d2Width="-94"/>
+ </links>
+ <links id="pf144820394228624" target="pf144820394228623" source="pf144820394228623" outcome="categories">
+ <bendPoints d1Height="-36" d2Height="-36"/>
+ <bendPoints d1Width="-64" d1Height="-36" d2Width="-64" d2Height="-36"/>
+ <bendPoints d1Width="-64" d2Width="-64"/>
+ </links>
+ <links id="pf14482039422867" target="pf14482039422866" source="pf14482039422866" outcome="contact">
+ <bendPoints d1Height="-36" d2Height="-36"/>
+ <bendPoints d1Width="-64" d1Height="-36" d2Width="-64" d2Height="-36"/>
+ <bendPoints d1Width="-64" d2Width="-64"/>
+ </links>
+</pageflow:Pageflow>
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index d04de3a..f42de36 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,7 @@
-#Mon Jun 25 14:38:55 CEST 2007
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/.settings/org.eclipse.jpt.core.prefs b/.settings/org.eclipse.jpt.core.prefs
new file mode 100644
index 0000000..bc24399
--- /dev/null
+++ b/.settings/org.eclipse.jpt.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jpt.core.platform=eclipselink2_5
+org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=true
diff --git a/.settings/org.eclipse.jpt.entitygen.jcatalog.jcatalog b/.settings/org.eclipse.jpt.entitygen.jcatalog.jcatalog
new file mode 100644
index 0000000..3c33b98
--- /dev/null
+++ b/.settings/org.eclipse.jpt.entitygen.jcatalog.jcatalog
Binary files differ
diff --git a/.settings/org.eclipse.jst.common.project.facet.core.prefs b/.settings/org.eclipse.jst.common.project.facet.core.prefs
deleted file mode 100644
index faee126..0000000
--- a/.settings/org.eclipse.jst.common.project.facet.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-#Tue Dec 05 14:34:55 CET 2006
-classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER/owners=jst.java\:5.0
-classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v5.5/owners=jst.web\:2.4
-eclipse.preferences.version=1
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
new file mode 100644
index 0000000..32f0f3a
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
@@ -0,0 +1,12 @@
+<root>
+ <facet id="jpt.jpa">
+ <node name="libprov">
+ <attribute name="provider-id" value="GlassFish-4-SystemLibrary-JPA"/>
+ </node>
+ </facet>
+ <facet id="jst.jsf">
+ <node name="libprov">
+ <attribute name="provider-id" value="GlassFish-4-SystemLibrary-JSF"/>
+ </node>
+ </facet>
+</root>
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
index 2a3c4eb..9d885a4 100644
--- a/.settings/org.eclipse.wst.common.project.facet.core.xml
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
- <runtime name="Apache Tomcat v5.5"/>
+ <runtime name="GlassFish 4"/>
<fixed facet="jst.java"/>
<fixed facet="jst.web"/>
- <installed facet="jst.web" version="2.4"/>
- <installed facet="jst.java" version="5.0"/>
+ <installed facet="jst.java" version="1.7"/>
+ <installed facet="jpt.jpa" version="2.1"/>
+ <installed facet="jst.web" version="3.1"/>
+ <installed facet="jst.jsf" version="2.2"/>
</faceted-project>
diff --git a/.settings/org.eclipse.wst.ws.service.policy.prefs b/.settings/org.eclipse.wst.ws.service.policy.prefs
new file mode 100644
index 0000000..9cfcabe
--- /dev/null
+++ b/.settings/org.eclipse.wst.ws.service.policy.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.wst.ws.service.policy.projectEnabled=false
diff --git a/WebContent/WEB-INF/faces-config.xml b/WebContent/WEB-INF/faces-config.xml
deleted file mode 100644
index 06265ca..0000000
--- a/WebContent/WEB-INF/faces-config.xml
+++ /dev/null
@@ -1,211 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE faces-config PUBLIC
- "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
-
-<faces-config>
-
-<managed-bean>
- <managed-bean-name>UserManager</managed-bean-name>
- <managed-bean-class>beans.UserManager</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
-</managed-bean>
-
-<managed-bean>
- <managed-bean-name>CategoryManager</managed-bean-name>
- <managed-bean-class>beans.CategoryManager</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
-</managed-bean>
-
-<managed-bean>
- <managed-bean-name>ContactManager</managed-bean-name>
- <managed-bean-class>beans.ContactManager</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
-</managed-bean>
-
-<managed-bean>
- <managed-bean-name>ProductManager</managed-bean-name>
- <managed-bean-class>beans.ProductManager</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
-</managed-bean>
-
-<navigation-rule>
-
- <from-view-id>/pages/home.xhtml</from-view-id>
-
- <navigation-case>
- <from-outcome>contact</from-outcome>
- <to-view-id>/pages/contact.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>login</from-outcome>
- <to-view-id>/pages/login.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>categories</from-outcome>
- <to-view-id>/pages/categories.xhtml</to-view-id>
- </navigation-case>
-
-</navigation-rule>
-
-<navigation-rule>
-
- <from-view-id>/pages/login.xhtml</from-view-id>
-
- <navigation-case>
- <from-outcome>contact</from-outcome>
- <to-view-id>/pages/contact.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>login</from-outcome>
- <to-view-id>/pages/login.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>categories</from-outcome>
- <to-view-id>/pages/categories.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>failure</from-outcome>
- <to-view-id>/pages/login.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>success</from-outcome>
- <to-view-id>/pages/greeting.xhtml</to-view-id>
- </navigation-case>
-
-</navigation-rule>
-
-
-<navigation-rule>
-
- <from-view-id>/pages/categories.xhtml</from-view-id>
-
- <navigation-case>
- <from-outcome>contact</from-outcome>
- <to-view-id>/pages/contact.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>login</from-outcome>
- <to-view-id>/pages/login.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>categories</from-outcome>
- <to-view-id>/pages/categories.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>select</from-outcome>
- <to-view-id>/pages/products.xhtml</to-view-id>
- </navigation-case>
-
-</navigation-rule>
-
-<navigation-rule>
-
- <from-view-id>/pages/greeting.xhtml</from-view-id>
-
- <navigation-case>
- <from-outcome>contact</from-outcome>
- <to-view-id>/pages/contact.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>categories</from-outcome>
- <to-view-id>/pages/categories.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>home</from-outcome>
- <to-view-id>/pages/home.xhtml</to-view-id>
- </navigation-case>
-
-</navigation-rule>
-
-<navigation-rule>
-
- <from-view-id>/pages/contact.xhtml</from-view-id>
-
- <navigation-case>
- <from-outcome>contact</from-outcome>
- <to-view-id>/pages/contact.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>categories</from-outcome>
- <to-view-id>/pages/categories.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>login</from-outcome>
- <to-view-id>/pages/login.xhtml</to-view-id>
- </navigation-case>
-
-</navigation-rule>
-
-<navigation-rule>
-
- <from-view-id>/pages/products.xhtml</from-view-id>
-
- <navigation-case>
- <from-outcome>contact</from-outcome>
- <to-view-id>/pages/contact.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>categories</from-outcome>
- <to-view-id>/pages/categories.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>login</from-outcome>
- <to-view-id>/pages/login.xhtml</to-view-id>
- </navigation-case>
-
-</navigation-rule>
-
-<navigation-rule>
-
- <from-view-id>/pages/product.xhtml</from-view-id>
-
- <navigation-case>
- <from-outcome>products</from-outcome>
- <to-view-id>/pages/products.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>contact</from-outcome>
- <to-view-id>/pages/contact.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>categories</from-outcome>
- <to-view-id>/pages/categories.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-outcome>login</from-outcome>
- <to-view-id>/pages/login.xhtml</to-view-id>
- </navigation-case>
-
-</navigation-rule>
-
-<application>
-
- <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
-
- <locale-config>
- <default-locale>de_DE</default-locale>
- </locale-config> </application>
-
-<factory/>
-<lifecycle/>
-
-</faces-config> \ No newline at end of file
diff --git a/WebContent/WEB-INF/lib/mysql-connector-java-5.1.37-bin.jar b/WebContent/WEB-INF/lib/mysql-connector-java-5.1.37-bin.jar
new file mode 100644
index 0000000..465af67
--- /dev/null
+++ b/WebContent/WEB-INF/lib/mysql-connector-java-5.1.37-bin.jar
Binary files differ
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml
index ee62240..28e4dc6 100644
--- a/WebContent/WEB-INF/web.xml
+++ b/WebContent/WEB-INF/web.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<description>Facelets JCatalog Application</description>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
- <param-name>facelets.REFRESH_PERIOD</param-name>
+ <param-name>facelets.FACELETS_REFRESH_PERIOD</param-name>
<param-value>2</param-value>
</context-param>
<context-param>
@@ -21,10 +21,6 @@
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
- <context-param>
- <param-name>com.sun.faces.verifyObjects</param-name>
- <param-value>true</param-value>
- </context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
diff --git a/src/META-INF/persistence.xml b/src/META-INF/persistence.xml
index 039a45e..fef05c4 100644
--- a/src/META-INF/persistence.xml
+++ b/src/META-INF/persistence.xml
@@ -1,15 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="catalog">
-<class>jpa.User</class>
-<class>jpa.Category</class>
-<class>jpa.Product</class>
+<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
- <property name="toplink.logging.level" value="INFO"/>
- <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
- <property name="toplink.jdbc.url" value="jdbc:mysql://localhost/catalog"/>
- <property name="toplink.jdbc.user" value="root"/>
- <property name="toplink.jdbc.password" value="masterkey"/>
+ <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
+ <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/jcatalog"/>
+ <property name="javax.persistence.jdbc.user" value="root"/>
</properties>
</persistence-unit>
</persistence>
diff --git a/src/beans/CategoryManager.java b/src/beans/CategoryManager.java
index 7b96d2f..fc3d438 100644
--- a/src/beans/CategoryManager.java
+++ b/src/beans/CategoryManager.java
@@ -13,6 +13,8 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Map;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
@@ -21,6 +23,8 @@ import javax.persistence.Persistence;
import jpa.Category;
+@ManagedBean(name = "CategoryManager")
+@SessionScoped
public class CategoryManager
{
private Category current;
@@ -48,7 +52,7 @@ public class CategoryManager
FacesContext facesContext = FacesContext.getCurrentInstance();
Map params = facesContext.getExternalContext().getRequestParameterMap();
Integer selectedId = Integer.valueOf((String) params.get("selectedId"));
-// System.out.println(selectedId);
+ // System.out.println(selectedId);
EntityManagerFactory factory = Persistence
.createEntityManagerFactory("catalog");
@@ -59,7 +63,7 @@ public class CategoryManager
try
{
current = manager.find(Category.class, selectedId);
-// System.out.println(current.getName());
+ // System.out.println(current.getName());
tx.commit();
}
catch (Exception ex)
diff --git a/src/beans/ContactManager.java b/src/beans/ContactManager.java
index 43c96e0..4625848 100644
--- a/src/beans/ContactManager.java
+++ b/src/beans/ContactManager.java
@@ -9,6 +9,11 @@
*/
package beans;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+@ManagedBean(name = "ContactManager")
+@SessionScoped
public class ContactManager
{
// nothing implemented yet
diff --git a/src/beans/ProductManager.java b/src/beans/ProductManager.java
index cc0dcaa..d499e3c 100644
--- a/src/beans/ProductManager.java
+++ b/src/beans/ProductManager.java
@@ -12,6 +12,8 @@ package beans;
import java.io.IOException;
import java.util.Map;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
@@ -20,10 +22,12 @@ import javax.persistence.Persistence;
import jpa.Product;
+@ManagedBean(name = "ProductManager")
+@SessionScoped
public class ProductManager
{
private Product current;
-
+
public Product getCurrent()
{
return current;
@@ -34,7 +38,7 @@ public class ProductManager
FacesContext facesContext = FacesContext.getCurrentInstance();
Map params = facesContext.getExternalContext().getRequestParameterMap();
String selectedId = (String) params.get("selectedId");
-// System.out.println(selectedId);
+ // System.out.println(selectedId);
EntityManagerFactory factory = Persistence
.createEntityManagerFactory("catalog");
diff --git a/src/beans/UserManager.java b/src/beans/UserManager.java
index 9e08543..190926b 100644
--- a/src/beans/UserManager.java
+++ b/src/beans/UserManager.java
@@ -9,8 +9,12 @@
*/
package beans;
+import static util.DigestUtils.md5;
+
import java.util.List;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
@@ -18,83 +22,99 @@ import javax.persistence.Persistence;
import javax.persistence.Query;
import jpa.User;
-import static util.DigestUtils.md5;
-public class UserManager {
- private User current;
+@ManagedBean(name = "UserManager")
+@SessionScoped
+public class UserManager
+{
+ private User current;
- private boolean loggedIn;
+ private boolean loggedIn;
- public UserManager() {
- current = new User();
- }
+ public UserManager()
+ {
+ current = new User();
+ }
- public String login() {
- String outcome = "failure";
- if (current.getUsername() != null && current.getUsername().length() > 0
- && current.getPassword() != null
- && current.getPassword().length() > 0) {
- EntityManagerFactory factory = Persistence
- .createEntityManagerFactory("catalog");
- EntityManager manager = factory.createEntityManager();
- Query query = manager
- .createQuery("SELECT u FROM User u where u.username = :username and u.password = :password");
- query.setParameter("username", current.getUsername());
- query.setParameter("password", md5(current.getPassword()));
- List results = query.getResultList();
+ public String login()
+ {
+ String outcome = "failure";
+ if (current.getUsername() != null && current.getUsername().length() > 0
+ && current.getPassword() != null
+ && current.getPassword().length() > 0)
+ {
+ EntityManagerFactory factory = Persistence
+ .createEntityManagerFactory("catalog");
+ EntityManager manager = factory.createEntityManager();
+ Query query = manager.createQuery(
+ "SELECT u FROM User u where u.username = :username and u.password = :password");
+ query.setParameter("username", current.getUsername());
+ query.setParameter("password", md5(current.getPassword()));
+ List results = query.getResultList();
- if (!results.isEmpty()) {
- loggedIn = true;
- current = (User) results.get(0);
- outcome = "success";
- }
- }
- // System.out.println(outcome);
- return outcome;
- }
+ if (!results.isEmpty())
+ {
+ loggedIn = true;
+ current = (User) results.get(0);
+ outcome = "success";
+ }
+ }
+ // System.out.println(outcome);
+ return outcome;
+ }
- public String logout() {
- loggedIn = false;
- current = new User();
- return "home";
- }
+ public String logout()
+ {
+ loggedIn = false;
+ current = new User();
+ return "home";
+ }
- public void setUsername(String username) {
- current.setUsername(username);
- }
+ public void setUsername(String username)
+ {
+ current.setUsername(username);
+ }
- public String getUsername() {
- return current.getUsername();
- }
+ public String getUsername()
+ {
+ return current.getUsername();
+ }
- public void setPassword(String password) {
- current.setPassword(password);
- }
+ public void setPassword(String password)
+ {
+ current.setPassword(password);
+ }
- public String getPassword() {
- return current.getPassword();
- }
+ public String getPassword()
+ {
+ return current.getPassword();
+ }
- public boolean isLoggedIn() {
- return loggedIn;
- }
+ public boolean isLoggedIn()
+ {
+ return loggedIn;
+ }
- public User getCurrent() {
- EntityManagerFactory factory = Persistence
- .createEntityManagerFactory("catalog");
- EntityManager manager = factory.createEntityManager();
+ public User getCurrent()
+ {
+ EntityManagerFactory factory = Persistence
+ .createEntityManagerFactory("catalog");
+ EntityManager manager = factory.createEntityManager();
- EntityTransaction tx = manager.getTransaction();
- tx.begin();
- try {
- current = manager.find(User.class, getUsername());
+ EntityTransaction tx = manager.getTransaction();
+ tx.begin();
+ try
+ {
+ current = manager.find(User.class, getUsername());
- tx.commit();
- } catch (Exception ex) {
- ex.printStackTrace(System.err);
- tx.rollback();
- }
+ tx.commit();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace(System.err);
+ tx.rollback();
+ }
- return current;
- }
+ return current;
+ }
}
diff --git a/src/jpa/Category.java b/src/jpa/Category.java
index c29c1f7..195b6e8 100644
--- a/src/jpa/Category.java
+++ b/src/jpa/Category.java
@@ -1,103 +1,64 @@
package jpa;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
+import javax.persistence.*;
import java.util.Set;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToMany;
+/**
+ * The persistent class for the category database table.
+ *
+ */
@Entity
-public class Category implements Serializable
-{
- @Id
- private int id;
+@Table(name="category")
+@NamedQuery(name="Category.findAll", query="SELECT c FROM Category c")
+public class Category implements Serializable {
+ private static final long serialVersionUID = 1L;
- private String name;
+ @Id
+ private int id;
- private String description;
+ private String description;
- @ManyToMany(mappedBy = "categoryCollection")
- private Set<Product> productCollection;
+ private String name;
- private static final long serialVersionUID = 1L;
+ //bi-directional many-to-many association to Product
+ @ManyToMany(mappedBy="categories")
+ private Set<Product> products;
- public Category()
- {
- super();
- }
+ public Category() {
+ }
- public int getId()
- {
- return this.id;
- }
+ public int getId() {
+ return this.id;
+ }
- public void setId(int id)
- {
- this.id = id;
- }
+ public void setId(int id) {
+ this.id = id;
+ }
- public String getName()
- {
- return this.name;
- }
+ public String getDescription() {
+ return this.description;
+ }
- public void setName(String name)
- {
- this.name = name;
- }
+ public void setDescription(String description) {
+ this.description = description;
+ }
- public String getDescription()
- {
- return this.description;
- }
+ public String getName() {
+ return this.name;
+ }
- public void setDescription(String description)
- {
- this.description = description;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * The method <code>getProductCollection()</code> returns a
- * Collection object that is incompatible with JSF.
- *
- * @return collection of product objects.
- */
- public Collection<Product> getProducts()
- {
- Collection<Product> c = new ArrayList<Product>();
-
- for (Iterator iter = getProductCollection().iterator(); iter.hasNext();)
- {
- Product product = (Product) iter.next();
- c.add(product);
-// System.out.println(product.getName());
- }
-
- return c;
- }
+ public Set<Product> getProducts() {
+ return this.products;
+ }
- public Set<Product> getProductCollection()
- {
- return this.productCollection;
- }
+ public void setProducts(Set<Product> products) {
+ this.products = products;
+ }
- public void setProductCollection(Set<Product> productCollection)
- {
- this.productCollection = productCollection;
- }
-
- public void addProduct(Product product)
- {
- Set<Product> products = getProductCollection();
- if (!products.contains(product))
- {
- products.add(product);
- product.addCategory(this);
- }
- }
-
-}
+} \ No newline at end of file
diff --git a/src/jpa/Product.java b/src/jpa/Product.java
index dc0b3f8..baf29ca 100644
--- a/src/jpa/Product.java
+++ b/src/jpa/Product.java
@@ -1,51 +1,56 @@
package jpa;
import java.io.Serializable;
+import javax.persistence.*;
import java.math.BigDecimal;
-import java.util.Collection;
import java.util.Set;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
+/**
+ * The persistent class for the product database table.
+ *
+ */
@Entity
+@Table(name="product")
+@NamedQuery(name="Product.findAll", query="SELECT p FROM Product p")
public class Product implements Serializable {
+ private static final long serialVersionUID = 1L;
+
@Id
- @GeneratedValue(strategy=GenerationType.SEQUENCE)
- private String id;
+ private int id;
+ @Lob
private String description;
- private BigDecimal price;
+ private BigDecimal height;
private String name;
- private BigDecimal width;
+ private BigDecimal price;
- private BigDecimal height;
+ private BigDecimal width;
+ //bi-directional many-to-many association to Category
@ManyToMany
@JoinTable(
- joinColumns=@JoinColumn(name="product_id"),
- inverseJoinColumns=@JoinColumn(name="category_id"))
- private Set<Category> categoryCollection;
-
- private static final long serialVersionUID = 1L;
+ name="product_category"
+ , joinColumns={
+ @JoinColumn(name="product_id")
+ }
+ , inverseJoinColumns={
+ @JoinColumn(name="category_id")
+ }
+ )
+ private Set<Category> categories;
public Product() {
- super();
}
- public String getId() {
+ public int getId() {
return this.id;
}
- public void setId(String id) {
+ public void setId(int id) {
this.id = id;
}
@@ -57,12 +62,12 @@ public class Product implements Serializable {
this.description = description;
}
- public BigDecimal getPrice() {
- return this.price;
+ public BigDecimal getHeight() {
+ return this.height;
}
- public void setPrice(BigDecimal price) {
- this.price = price;
+ public void setHeight(BigDecimal height) {
+ this.height = height;
}
public String getName() {
@@ -73,41 +78,28 @@ public class Product implements Serializable {
this.name = name;
}
- public BigDecimal getWidth() {
- return this.width;
+ public BigDecimal getPrice() {
+ return this.price;
}
- public void setWidth(BigDecimal width) {
- this.width = width;
+ public void setPrice(BigDecimal price) {
+ this.price = price;
}
- public BigDecimal getHeight() {
- return this.height;
+ public BigDecimal getWidth() {
+ return this.width;
}
- public void setHeight(BigDecimal height) {
- this.height = height;
+ public void setWidth(BigDecimal width) {
+ this.width = width;
}
- public Collection getCategories() {
- return this.getCategoryCollection();
- }
-
- public Set<Category> getCategoryCollection() {
- return this.categoryCollection;
+ public Set<Category> getCategories() {
+ return this.categories;
}
- public void setCategoryCollection(Set<Category> categoryCollection) {
- this.categoryCollection = categoryCollection;
+ public void setCategories(Set<Category> categories) {
+ this.categories = categories;
}
- public void addCategory(Category category)
- {
- Set<Category> categories = getCategoryCollection();
- if (!categories.contains(category))
- {
- categories.add(category);
- category.addProduct(this);
- }
- }
-}
+} \ No newline at end of file
diff --git a/src/jpa/User.java b/src/jpa/User.java
index 32d2af8..d96d27e 100644
--- a/src/jpa/User.java
+++ b/src/jpa/User.java
@@ -1,20 +1,25 @@
package jpa;
import java.io.Serializable;
-import javax.persistence.Entity;
-import javax.persistence.Id;
+import javax.persistence.*;
+
+/**
+ * The persistent class for the user database table.
+ *
+ */
@Entity
+@Table(name="user")
+@NamedQuery(name="User.findAll", query="SELECT u FROM User u")
public class User implements Serializable {
+ private static final long serialVersionUID = 1L;
+
@Id
private String username;
private String password;
- private static final long serialVersionUID = 1L;
-
public User() {
- super();
}
public String getUsername() {
@@ -33,4 +38,4 @@ public class User implements Serializable {
this.password = password;
}
-}
+} \ No newline at end of file