summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-11-22 15:07:27 +0100
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-11-23 15:57:23 +0100
commitdf8c8d8eaa3fd74b2f6a76341611555ee6d8834d (patch)
tree40e93e3b3674f32d4870486eb9f5870d9fe45b2b
downloadJCatalog-df8c8d8eaa3fd74b2f6a76341611555ee6d8834d.tar.gz
JCatalog-df8c8d8eaa3fd74b2f6a76341611555ee6d8834d.zip
Add initial files
-rw-r--r--.classpath8
-rw-r--r--.gitignore1
-rw-r--r--.project36
-rw-r--r--.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--.settings/org.eclipse.jst.common.project.facet.core.prefs4
-rw-r--r--.settings/org.eclipse.wst.common.component9
-rw-r--r--.settings/org.eclipse.wst.common.project.facet.core.xml8
-rw-r--r--.settings/org.eclipse.wst.validation.prefs6
-rw-r--r--WEB-INF/web.xml1
-rw-r--r--WebContent/META-INF/MANIFEST.MF3
-rw-r--r--WebContent/WEB-INF/faces-config.xml211
-rw-r--r--WebContent/WEB-INF/web.xml47
-rw-r--r--WebContent/index.jsp10
-rw-r--r--WebContent/pages/categories.xhtml54
-rw-r--r--WebContent/pages/category.xhtml23
-rw-r--r--WebContent/pages/contact.xhtml23
-rw-r--r--WebContent/pages/greeting.xhtml22
-rw-r--r--WebContent/pages/home.xhtml28
-rw-r--r--WebContent/pages/login.xhtml41
-rw-r--r--WebContent/pages/product.xhtml44
-rw-r--r--WebContent/pages/products.xhtml62
-rw-r--r--WebContent/stylesheets/form.css16
-rw-r--r--WebContent/stylesheets/navigation.css25
-rw-r--r--WebContent/stylesheets/twocolumn.css53
-rw-r--r--WebContent/templates/common.xhtml60
-rw-r--r--WebContent/templates/loggedin.xhtml60
-rw-r--r--jcatalog.sql127
-rw-r--r--quellen.txt10
-rw-r--r--src/META-INF/persistence.xml15
-rw-r--r--src/beans/CategoryManager.java83
-rw-r--r--src/beans/ContactManager.java15
-rw-r--r--src/beans/ProductManager.java70
-rw-r--r--src/beans/UserManager.java100
-rw-r--r--src/jpa/Category.java103
-rw-r--r--src/jpa/JPATest.java62
-rw-r--r--src/jpa/Product.java113
-rw-r--r--src/jpa/User.java36
-rw-r--r--src/resources.properties2
-rw-r--r--src/util/DigestUtils.java58
40 files changed, 1660 insertions, 0 deletions
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..fa0a137
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,8 @@
+<?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="output" path="build/classes"/>
+</classpath>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d9b4f01
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/build/*
diff --git a/.project b/.project
new file mode 100644
index 0000000..e5f3bc1
--- /dev/null
+++ b/.project
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>JCatalog</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.dali.core.persistenceBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.dali.core.persistenceNature</nature>
+ </natures>
+</projectDescription>
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d04de3a
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#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.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..be0c06f
--- /dev/null
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Mon Jun 25 14:38:55 CEST 2007
+eclipse.preferences.version=1
+internal.default.compliance=default
diff --git a/.settings/org.eclipse.jst.common.project.facet.core.prefs b/.settings/org.eclipse.jst.common.project.facet.core.prefs
new file mode 100644
index 0000000..faee126
--- /dev/null
+++ b/.settings/org.eclipse.jst.common.project.facet.core.prefs
@@ -0,0 +1,4 @@
+#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.component b/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..320180b
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="JCatalog">
+<wb-resource deploy-path="/" source-path="/WebContent"/>
+<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+<property name="context-root" value="JCatalog"/>
+<property name="java-output-path" value="build/classes"/>
+</wb-module>
+</project-modules>
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..2a3c4eb
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <runtime name="Apache Tomcat v5.5"/>
+ <fixed facet="jst.java"/>
+ <fixed facet="jst.web"/>
+ <installed facet="jst.web" version="2.4"/>
+ <installed facet="jst.java" version="5.0"/>
+</faceted-project>
diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 0000000..01f00ff
--- /dev/null
+++ b/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,6 @@
+#Mon Jun 25 14:38:55 CEST 2007
+DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator;
+USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.common.componentcore.internal.ModuleCoreValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.dali.packaging.internal.validator.PackagingValidator;org.eclipse.jst.j2ee.internal.web.validation.UIWarValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;
+USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.common.componentcore.internal.ModuleCoreValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.dali.packaging.internal.validator.PackagingValidator;org.eclipse.jst.j2ee.internal.web.validation.UIWarValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;
+USER_PREFERENCE=overrideGlobalPreferencesfalse
+eclipse.preferences.version=1
diff --git a/WEB-INF/web.xml b/WEB-INF/web.xml
new file mode 100644
index 0000000..12bbf74
--- /dev/null
+++ b/WEB-INF/web.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?>
diff --git a/WebContent/META-INF/MANIFEST.MF b/WebContent/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..254272e
--- /dev/null
+++ b/WebContent/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/WebContent/WEB-INF/faces-config.xml b/WebContent/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..06265ca
--- /dev/null
+++ b/WebContent/WEB-INF/faces-config.xml
@@ -0,0 +1,211 @@
+<?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/web.xml b/WebContent/WEB-INF/web.xml
new file mode 100644
index 0000000..ee62240
--- /dev/null
+++ b/WebContent/WEB-INF/web.xml
@@ -0,0 +1,47 @@
+<?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">
+ <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-value>2</param-value>
+ </context-param>
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>client</param-value>
+ </context-param>
+ <context-param>
+ <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>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <display-name>
+ JCatalog</display-name>
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>default.html</welcome-file>
+ <welcome-file>default.htm</welcome-file>
+ <welcome-file>default.jsp</welcome-file>
+ </welcome-file-list>
+</web-app>
diff --git a/WebContent/index.jsp b/WebContent/index.jsp
new file mode 100644
index 0000000..fa6ee7d
--- /dev/null
+++ b/WebContent/index.jsp
@@ -0,0 +1,10 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head></head>
+ <body>
+ <% response.sendRedirect("pages/home.jsf"); %>
+ <!--
+ &lt;jsp:forward page="pages/home.jsf" /&gt;
+ -->
+ </body>
+</html> \ No newline at end of file
diff --git a/WebContent/pages/categories.xhtml b/WebContent/pages/categories.xhtml
new file mode 100644
index 0000000..4a7532e
--- /dev/null
+++ b/WebContent/pages/categories.xhtml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core">
+
+ <ui:composition template="/templates/common.xhtml">
+
+ <ui:define name="pageTitle">JCatalog Application</ui:define>
+
+ <ui:define name="pageHeader">JCatalog Categories</ui:define>
+
+ <ui:define name="body">
+ <h:form id="categories">
+ <h:dataTable style="border: 1px;" id="categoriestable" value="#{CategoryManager.categories}"
+ var="category">
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Id" />
+ </f:facet>
+ <h:outputText value="#{category.id}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Name" />
+ </f:facet>
+ <h:outputText value="#{category.name}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Description" />
+ </f:facet>
+ <h:outputText value="#{category.description}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="" />
+ </f:facet>
+ <h:commandLink value="View Details ..." immediate="true"
+ actionListener="#{CategoryManager.select}" action="select">
+ <f:param name="selectedId" value="#{category.id}" />
+ </h:commandLink>
+ </h:column>
+ </h:dataTable>
+ </h:form>
+ </ui:define>
+
+ <ui:define name="pageFooter">JCatalog Footer</ui:define>
+
+ </ui:composition>
+
+</html>
diff --git a/WebContent/pages/category.xhtml b/WebContent/pages/category.xhtml
new file mode 100644
index 0000000..b5313a3
--- /dev/null
+++ b/WebContent/pages/category.xhtml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core">
+
+ <ui:composition template="/templates/common.xhtml">
+
+ <ui:define name="pageTitle">JCatalog Application</ui:define>
+
+ <ui:define name="pageHeader">JCatalog Application</ui:define>
+
+ <ui:define name="body">
+ <h2>Welcome to the JCatalog Demo Application <h:outputText id="category" value="#{CategoryManager.current.name}" /></h2>
+ </ui:define>
+
+ <ui:define name="pageFooter">JCatalog Footer</ui:define>
+
+ </ui:composition>
+
+</html>
diff --git a/WebContent/pages/contact.xhtml b/WebContent/pages/contact.xhtml
new file mode 100644
index 0000000..b51f1dd
--- /dev/null
+++ b/WebContent/pages/contact.xhtml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core">
+
+ <ui:composition template="/templates/common.xhtml">
+
+ <ui:define name="pageTitle">JCatalog Application</ui:define>
+
+ <ui:define name="pageHeader">JCatalog Application</ui:define>
+
+ <ui:define name="body">
+ <h2>Contact Page</h2>
+ </ui:define>
+
+ <ui:define name="pageFooter">JCatalog Footer</ui:define>
+
+ </ui:composition>
+
+</html>
diff --git a/WebContent/pages/greeting.xhtml b/WebContent/pages/greeting.xhtml
new file mode 100644
index 0000000..73e1d62
--- /dev/null
+++ b/WebContent/pages/greeting.xhtml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <ui:composition template="/templates/loggedin.xhtml">
+
+ <ui:define name="pageTitle">JCatalog Welcome</ui:define>
+
+ <ui:define name="pageHeader">JCatalog Application</ui:define>
+
+ <ui:define name="body">
+ <h2>Welcome to the JCatalog Demo Application <h:outputText id="username" value="#{UserManager.username}" /></h2>
+ </ui:define>
+
+ <ui:define name="pageFooter">JCatalog Footer</ui:define>
+
+ </ui:composition>
+
+</html>
diff --git a/WebContent/pages/home.xhtml b/WebContent/pages/home.xhtml
new file mode 100644
index 0000000..735c734
--- /dev/null
+++ b/WebContent/pages/home.xhtml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+ </head>
+
+ <ui:composition template="/templates/common.xhtml">
+
+ <ui:define name="pageTitle">JCatalog Application</ui:define>
+
+ <ui:define name="pageHeader">JCatalog Application</ui:define>
+
+ <ui:define name="body">
+ <h2>Welcome to the JCatalog Demo Application</h2>
+ <p>Please make your choice.</p>
+ <p>Bitte eine Option auswählen.</p>
+ </ui:define>
+
+ <ui:define name="pageFooter">JCatalog Footer</ui:define>
+
+ </ui:composition>
+
+</html>
diff --git a/WebContent/pages/login.xhtml b/WebContent/pages/login.xhtml
new file mode 100644
index 0000000..2e94421
--- /dev/null
+++ b/WebContent/pages/login.xhtml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core">
+
+<ui:composition template="/templates/common.xhtml">
+
+ <ui:define name="pageTitle">JCatalog Login</ui:define>
+
+ <ui:define name="pageHeader">Login</ui:define>
+
+ <ui:define name="body">
+ <div style="width: 500px; padding: 5px; margin: 0px auto; float: left;">
+ <h:form id="loginForm">
+ <h:inputHidden id="action" value="login" />
+ <div class="row">
+ <label for="username"><u>U</u>sername:</label>
+ <span class="formw"><h:inputText id="username" value="#{UserManager.username}" accesskey="u" size="40" /></span>
+ </div>
+ <div class="row">
+ <label for="password"><u>P</u>assword:</label>
+ <span class="formw"><h:inputSecret id="password" value="#{UserManager.password}" accesskey="p" size="32" /></span>
+ </div>
+ <div class="row">
+ <span class="formw">
+ <h:commandButton action="#{UserManager.login}" id="submit" value="Submit" type="submit" accesskey="s" />
+ </span>
+ </div>
+ <div class="spacer" />
+ </h:form>
+ </div>
+ </ui:define>
+
+ <ui:define name="pageFooter">JCatalog Footer</ui:define>
+
+</ui:composition>
+
+</html>
diff --git a/WebContent/pages/product.xhtml b/WebContent/pages/product.xhtml
new file mode 100644
index 0000000..06c4a8d
--- /dev/null
+++ b/WebContent/pages/product.xhtml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core">
+
+<ui:composition template="/templates/common.xhtml">
+
+ <ui:define name="pageTitle">JCatalog Application</ui:define>
+
+ <ui:define name="pageHeader">Login</ui:define>
+
+ <ui:define name="body">
+ <div style="width: 500px; padding: 5px; margin: 0px auto; float: left;">
+ <h:form>
+ <div class="row">
+ <label for="name">Name:</label>
+ <span class="formw"><h:inputText id="name" disabled="true" value="#{ProductManager.current.name}" accesskey="n" size="40" /></span>
+ </div>
+ <div class="row">
+ <label for="price">Price:</label>
+ <span class="formw"><h:inputText id="price" disabled="true" value="#{ProductManager.current.price}" accesskey="p" size="40" /></span>
+ </div>
+ <div class="row">
+ <label for="description">Description:</label>
+ <span class="formw"><h:inputTextarea rows="20" cols="40" id="description" disabled="true" value="#{ProductManager.current.description}" accesskey="d" /></span>
+ </div>
+ <div class="row">
+ <span class="formw">
+ <h:commandButton action="products" id="back" value="Back" type="submit" accesskey="b" />
+ </span>
+ </div>
+ <div class="spacer" />
+ </h:form>
+ </div>
+ </ui:define>
+
+ <ui:define name="pageFooter">JCatalog Footer</ui:define>
+
+</ui:composition>
+
+</html>
diff --git a/WebContent/pages/products.xhtml b/WebContent/pages/products.xhtml
new file mode 100644
index 0000000..f833c1d
--- /dev/null
+++ b/WebContent/pages/products.xhtml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core">
+
+ <ui:composition template="/templates/common.xhtml">
+
+ <ui:define name="pageTitle">JCatalog Application</ui:define>
+
+ <ui:define name="pageHeader">List of Products</ui:define>
+
+ <ui:define name="body">
+
+ <h:form id="products">
+
+ <h2>
+ <f:verbatim>List of Products in Category </f:verbatim>
+ <h:outputText value="#{CategoryManager.current.name}" />
+ </h2>
+
+ <h:dataTable style="border: 1px;" id="producttable" value="#{CategoryManager.current.products}"
+ var="product">
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Id" />
+ </f:facet>
+ <h:outputText value="#{product.id}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Name" />
+ </f:facet>
+ <h:outputText value="#{product.name}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Price" />
+ </f:facet>
+ <h:outputText value="#{product.price}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="" />
+ </f:facet>
+ <h:commandLink value="View Details ..." immediate="true"
+ actionListener="#{ProductManager.select}" action="select">
+ <f:param name="selectedId" value="#{product.id}" />
+ </h:commandLink>
+ </h:column>
+ </h:dataTable>
+
+ </h:form>
+ </ui:define>
+
+ <ui:define name="pageFooter">JCatalog Footer</ui:define>
+
+ </ui:composition>
+
+</html>
diff --git a/WebContent/stylesheets/form.css b/WebContent/stylesheets/form.css
new file mode 100644
index 0000000..8667f07
--- /dev/null
+++ b/WebContent/stylesheets/form.css
@@ -0,0 +1,16 @@
+div.row {
+ clear: both;
+ padding-top: 10px;
+}
+
+div.row label {
+ float: left;
+ width: 100px;
+ text-align: right;
+}
+
+div.row span.formw {
+ float: right;
+ width: 335px;
+ text-align: left;
+}
diff --git a/WebContent/stylesheets/navigation.css b/WebContent/stylesheets/navigation.css
new file mode 100644
index 0000000..1ec153b
--- /dev/null
+++ b/WebContent/stylesheets/navigation.css
@@ -0,0 +1,25 @@
+#navcontainer ul
+{
+margin: 0;
+padding: 0;
+list-style-type: none;
+}
+
+#navcontainer li { margin: 0 0 .2em 0; }
+
+#navcontainer a
+{
+display: block;
+color: black;
+background-color: #ddd;
+width: 6em;
+padding: .2em .8em;
+text-decoration: none;
+}
+
+#navcontainer a:hover
+{
+background-color: #bbb;
+color: #FFF;
+}
+
diff --git a/WebContent/stylesheets/twocolumn.css b/WebContent/stylesheets/twocolumn.css
new file mode 100644
index 0000000..e5b8e84
--- /dev/null
+++ b/WebContent/stylesheets/twocolumn.css
@@ -0,0 +1,53 @@
+@CHARSET "ISO-8859-1";
+
+#container
+{
+width: 90%;
+margin: 10px auto;
+background-color: #fff;
+color: #333;
+border: 1px solid gray;
+line-height: 130%;
+}
+
+#top
+{
+padding: .5em;
+background-color: #ddd;
+border-bottom: 1px solid gray;
+}
+
+#top h1
+{
+padding: 0;
+margin: 0;
+}
+
+#leftnav
+{
+float: left;
+width: 160px;
+margin: 0;
+padding: 1em;
+}
+
+#content
+{
+margin-left: 200px;
+border-left: 1px solid gray;
+padding: 1em;
+max-width: 36em;
+}
+
+#footer
+{
+clear: both;
+margin: 0;
+padding: .5em;
+color: #333;
+background-color: #ddd;
+border-top: 1px solid gray;
+}
+
+#leftnav p { margin: 0 0 1em 0; }
+#content h2 { margin: 0 0 .5em 0; }
diff --git a/WebContent/templates/common.xhtml b/WebContent/templates/common.xhtml
new file mode 100644
index 0000000..151411f
--- /dev/null
+++ b/WebContent/templates/common.xhtml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <head>
+ <title><ui:insert name="pageTitle">Page Title</ui:insert></title>
+ <link rel="stylesheet" type="text/css" href="../stylesheets/twocolumn.css" />
+ <link rel="stylesheet" type="text/css" href="../stylesheets/navigation.css" />
+ <link rel="stylesheet" type="text/css" href="../stylesheets/form.css" />
+ <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+ </head>
+
+ <body>
+
+ <div id="container">
+
+ <div id="top">
+ <ui:insert name="pageHeader">Page Header</ui:insert>
+ </div>
+
+ <div id="leftnav">
+ <ui:insert name="leftnav">
+ <h:form id="navcontainer">
+ <ul>
+ <li>
+ <h:commandLink action="contact">
+ <h:outputText id="contact" value="Cont@ct" />
+ </h:commandLink>
+ </li>
+ <li>
+ <h:commandLink action="categories">
+ <h:outputText id="catalog" value="Catalog" />
+ </h:commandLink>
+ </li>
+ <li>
+ <h:commandLink action="login" id="loginLink">
+ <h:outputText id="login" value="Login" />
+ </h:commandLink>
+ </li>
+ </ul>
+ </h:form>
+ </ui:insert>
+ </div>
+
+ <div id="content">
+ <ui:insert name="body">Page Body</ui:insert>
+ </div>
+
+ <div id="footer">
+ <ui:insert name="footer">Page Footer</ui:insert>
+ </div>
+
+ </div> <!-- id="container" -->
+
+ </body>
+
+</html>
diff --git a/WebContent/templates/loggedin.xhtml b/WebContent/templates/loggedin.xhtml
new file mode 100644
index 0000000..3ac57ca
--- /dev/null
+++ b/WebContent/templates/loggedin.xhtml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <head>
+ <title><ui:insert name="pageTitle">Page Title</ui:insert></title>
+ <link rel="stylesheet" type="text/css" href="../stylesheets/twocolumn.css" />
+ <link rel="stylesheet" type="text/css" href="../stylesheets/navigation.css" />
+ <link rel="stylesheet" type="text/css" href="../stylesheets/form.css" />
+ <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+ </head>
+
+ <body>
+
+ <div id="container">
+
+ <div id="top">
+ <ui:insert name="pageHeader">Page Header</ui:insert>
+ </div>
+
+ <div id="leftnav">
+ <ui:insert name="leftnav">
+ <h:form id="navcontainer">
+ <ul>
+ <li>
+ <h:commandLink action="contact">
+ <h:outputText id="contact" value="Cont@ct" />
+ </h:commandLink>
+ </li>
+ <li>
+ <h:commandLink action="categories">
+ <h:outputText id="catalog" value="Catalog" />
+ </h:commandLink>
+ </li>
+ <li>
+ <h:commandLink action="#{UserManager.logout}" id="logoutLink">
+ <h:outputText id="logout" value="Logout" />
+ </h:commandLink>
+ </li>
+ </ul>
+ </h:form>
+ </ui:insert>
+ </div>
+
+ <div id="content">
+ <ui:insert name="body">Page Body</ui:insert>
+ </div>
+
+ <div id="footer">
+ <ui:insert name="footer">Page Footer</ui:insert>
+ </div>
+
+ </div> <!-- id="container" -->
+
+ </body>
+
+</html>
diff --git a/jcatalog.sql b/jcatalog.sql
new file mode 100644
index 0000000..dafd669
--- /dev/null
+++ b/jcatalog.sql
@@ -0,0 +1,127 @@
+-- phpMyAdmin SQL Dump
+-- version 2.9.0.1
+-- http://www.phpmyadmin.net
+--
+-- Host: localhost
+-- Generation Time: Jan 17, 2007 at 02:57 PM
+-- Server version: 5.0.24
+-- PHP Version: 5.1.6
+--
+-- Database: `catalog`
+--
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `category`
+--
+
+CREATE TABLE `category` (
+ `id` int(10) NOT NULL auto_increment,
+ `name` varchar(50) collate latin1_general_ci NOT NULL,
+ `description` varchar(255) collate latin1_general_ci default NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=5 ;
+
+--
+-- Dumping data for table `category`
+--
+
+INSERT INTO `category` (`id`, `name`, `description`) VALUES (1, 'Category One', 'Category one description');
+INSERT INTO `category` (`id`, `name`, `description`) VALUES (2, 'Category Two', 'Category two description');
+INSERT INTO `category` (`id`, `name`, `description`) VALUES (3, 'Category Three', 'Category three description');
+INSERT INTO `category` (`id`, `name`, `description`) VALUES (4, 'Category Four', 'Category four description');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `product`
+--
+
+CREATE TABLE `product` (
+ `id` int(10) NOT NULL auto_increment,
+ `name` varchar(50) collate latin1_general_ci NOT NULL,
+ `price` decimal(8,2) default NULL,
+ `width` decimal(8,2) default NULL,
+ `height` decimal(8,2) default NULL,
+ `description` longtext collate latin1_general_ci,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=9 ;
+
+--
+-- Dumping data for table `product`
+--
+
+INSERT INTO `product` (`id`, `name`, `price`, `width`, `height`, `description`) VALUES (1, 'Product1', 20.00, 12.00, 16.00, 'JavaServer Faces (JSF) technology is a new user interface framework for J2EE applications. It is particularly suited, by design, for use with applications based on the MVC architecture. Numerous articles have been published to introduce JSF. However, most of them take a highly theoretical approach that does not meet the challenges of real-world enterprise development. There are still a lot of issues that need to be solved. For example, how JSF fits INTO the overall MVC architecture? How JSF integrates with other Java frameworks? Should business logic exist in the JSF backing beans? How to handle security in JSF? And most importantly, how to build a real-world web application using JSF? This article addresses all these issues. It shows you how to integrate JSF with other Java frameworks – specifically, Spring Framework and Hibernate.');
+INSERT INTO `product` (`id`, `name`, `price`, `width`, `height`, `description`) VALUES (2, 'Product2', 40.00, 18.00, 16.00, 'The sample application used in this article is an online product catalog system. By showing you how to build a real-world web application, this article covers each phase of the web application design, including business requirement gathering, analysis, technology selection, high-level architecture and implementation level design. It discusses the advantages and disadvantages of the technologies used in the sample application. It also demonstrates the approach to designing some key aspects of the sample application.This article is aimed at Java architects, developers already working with J2EE based web application. It is not an introduction to JSF, Spring Framework and Hibernate.');
+INSERT INTO `product` (`id`, `name`, `price`, `width`, `height`, `description`) VALUES (3, 'Product3', 38.88, 20.00, 18.00, 'The sample application is a real-world web application, which is realistic enough to provide the basis for a meaningful discussion of web application architectural decisions. It is important to begin by presenting the requirements of the sample application. I will refer back to this section throughout the rest of the article to address the technical decisions and architecture design. The first phase in designing a web application is to gather functional requirements for the system. The sample application is a typical e-business application system.');
+INSERT INTO `product` (`id`, `name`, `price`, `width`, `height`, `description`) VALUES (4, 'Product4', 22.99, 18.00, 14.00, 'There are two groups of pages in the sample application – public internet and administration intranet. The intranet is only accessible to the users who log in the system successfully. ProductSummary is not presented to the users as a separate page. It is shown inside a HTML frame within the Catalog page. ProductList is a special catalog viewable only by the administrators. It contains links to create product, edit product and delete product.');
+INSERT INTO `product` (`id`, `name`, `price`, `width`, `height`, `description`) VALUES (5, 'Product5', 18.68, 17.00, 21.00, 'A multi-tier architecture partitions the whole system INTO distinct functional units - client, presentation, business logic, integration and enterprise information system (EIS). This ensures a clean division of responsibility and makes the system more maintainable and extensible. Systems with three or more tiers have proven more scalable and flexible than a client-server system, in which there is no business logic middle tier.');
+INSERT INTO `product` (`id`, `name`, `price`, `width`, `height`, `description`) VALUES (6, 'Product6', 28.99, 19.00, 20.00, 'The business logic tier contains the business objects and the business services of an application. It receives requests from the presentation tier, processes the business logic based on the requests and mediates access to EIS tier resources. Business logic tier components benefit most from system level services such as security management, transaction management and resource management.');
+INSERT INTO `product` (`id`, `name`, `price`, `width`, `height`, `description`) VALUES (7, 'Product7', 36.66, 16.00, 18.00, 'A multi-tier non-distributed architecture is used for the sample application. The diagram shows us the partitioning of the application tiers, and the technologies chosen for each tier. It also serves as a deployment diagram of the sample application. For a collocated architecture, the presentation tier, business logic tier and integration tier are located in the same web container physically. Well-defined interfaces are used to isolate the responsibility for each tier. The collocated architecture makes the application simple and scalable.');
+INSERT INTO `product` (`id`, `name`, `price`, `width`, `height`, `description`) VALUES (8, 'Product8', 32.99, 26.00, 18.00, 'Model-View-Controller (MVC) is the Java BluePrints recommended architectural design pattern for interactive application. MVC separates design concerns, decreasing code duplication, centralizing control, and making the application more extensible. MVC also helps developers with different skill sets to focus on their core skills and collaborate through clearly defined interfaces. MVC is the architectural design pattern for the presentation tier.');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `product_category`
+--
+
+CREATE TABLE `product_category` (
+ `product_id` int(10) NOT NULL,
+ `category_id` int(10) NOT NULL,
+ PRIMARY KEY (`product_id`,`category_id`),
+ KEY `category_id` (`category_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
+--
+-- Dumping data for table `product_category`
+--
+
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (1, 1);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (2, 1);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (3, 1);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (4, 1);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (5, 1);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (6, 1);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (7, 1);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (8, 1);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (1, 2);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (4, 2);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (6, 2);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (8, 2);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (1, 3);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (2, 3);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (7, 3);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (1, 4);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (3, 4);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (5, 4);
+INSERT INTO `product_category` (`product_id`, `category_id`) VALUES (8, 4);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `user`
+--
+
+CREATE TABLE `user` (
+ `username` varchar(20) collate latin1_general_ci NOT NULL,
+ `password` varchar(32) collate latin1_general_ci NOT NULL,
+ PRIMARY KEY (`username`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
+--
+-- Dumping data for table `user`
+--
+
+INSERT INTO `user` (`username`, `password`) VALUES ('admin', 'abe6db4c9f5484fae8d79f2e868a673c');
+
+--
+-- Constraints for dumped tables
+--
+
+--
+-- Constraints for table `product_category`
+--
+ALTER TABLE `product_category`
+ ADD CONSTRAINT `product_category_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`), ADD CONSTRAINT `product_category_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`);
diff --git a/quellen.txt b/quellen.txt
new file mode 100644
index 0000000..82e584f
--- /dev/null
+++ b/quellen.txt
@@ -0,0 +1,10 @@
+Downloads:
+
+http://myfaces.apache.org/
+https://facelets.dev.java.net/
+http://www.oracle.com/technology/products/ias/toplink/jpa/download.html
+http://dev.mysql.com/downloads/connector/j/3.0.html
+
+Online-Artikel:
+
+http://www.javaworld.com/javaworld/jw-07-2004/jw-0719-jsf.html (Die Vorlage für die Kataloganwendung) \ No newline at end of file
diff --git a/src/META-INF/persistence.xml b/src/META-INF/persistence.xml
new file mode 100644
index 0000000..039a45e
--- /dev/null
+++ b/src/META-INF/persistence.xml
@@ -0,0 +1,15 @@
+<?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>
+<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"/>
+</properties>
+</persistence-unit>
+</persistence>
diff --git a/src/beans/CategoryManager.java b/src/beans/CategoryManager.java
new file mode 100644
index 0000000..7b96d2f
--- /dev/null
+++ b/src/beans/CategoryManager.java
@@ -0,0 +1,83 @@
+/*
+ * $RCSFile$
+ *
+ * Created on 08.03.2007
+ * for Project:
+ * by steins
+ *
+ * (C) 2005-2006 by
+ */
+package beans;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+import jpa.Category;
+
+public class CategoryManager
+{
+ private Category current;
+
+ public Category getCurrent()
+ {
+ return current;
+ }
+
+ public void setCurrent(Category current)
+ {
+ this.current = current;
+ }
+
+ public Collection getCategories()
+ {
+ EntityManagerFactory factory = Persistence
+ .createEntityManagerFactory("catalog");
+ EntityManager manager = factory.createEntityManager();
+ return manager.createQuery("SELECT c FROM Category c ").getResultList();
+ }
+
+ public void select(javax.faces.event.ActionEvent actionEvent)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Map params = facesContext.getExternalContext().getRequestParameterMap();
+ Integer selectedId = Integer.valueOf((String) params.get("selectedId"));
+// System.out.println(selectedId);
+
+ EntityManagerFactory factory = Persistence
+ .createEntityManagerFactory("catalog");
+ EntityManager manager = factory.createEntityManager();
+
+ EntityTransaction tx = manager.getTransaction();
+ tx.begin();
+ try
+ {
+ current = manager.find(Category.class, selectedId);
+// System.out.println(current.getName());
+ tx.commit();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace(System.err);
+ tx.rollback();
+ }
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ try
+ {
+ context.getExternalContext().redirect("products.jsf");
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ context.responseComplete();
+ }
+}
diff --git a/src/beans/ContactManager.java b/src/beans/ContactManager.java
new file mode 100644
index 0000000..43c96e0
--- /dev/null
+++ b/src/beans/ContactManager.java
@@ -0,0 +1,15 @@
+/*
+ * $RCSFile$
+ *
+ * Created on 12.03.2007
+ * for Project:
+ * by steins
+ *
+ * (C) 2005-2006 by
+ */
+package beans;
+
+public class ContactManager
+{
+ // nothing implemented yet
+}
diff --git a/src/beans/ProductManager.java b/src/beans/ProductManager.java
new file mode 100644
index 0000000..cc0dcaa
--- /dev/null
+++ b/src/beans/ProductManager.java
@@ -0,0 +1,70 @@
+/*
+ * $RCSFile$
+ *
+ * Created on 11.06.2007
+ * for Project:
+ * by steins
+ *
+ * (C) 2005-2006 by
+ */
+package beans;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+import jpa.Product;
+
+public class ProductManager
+{
+ private Product current;
+
+ public Product getCurrent()
+ {
+ return current;
+ }
+
+ public void select(javax.faces.event.ActionEvent actionEvent)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Map params = facesContext.getExternalContext().getRequestParameterMap();
+ String selectedId = (String) params.get("selectedId");
+// System.out.println(selectedId);
+
+ EntityManagerFactory factory = Persistence
+ .createEntityManagerFactory("catalog");
+ EntityManager manager = factory.createEntityManager();
+
+ EntityTransaction tx = manager.getTransaction();
+ tx.begin();
+ try
+ {
+ current = manager.find(Product.class, selectedId);
+
+ tx.commit();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace(System.err);
+ tx.rollback();
+ }
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ try
+ {
+ context.getExternalContext().redirect("product.jsf");
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ context.responseComplete();
+ }
+
+}
diff --git a/src/beans/UserManager.java b/src/beans/UserManager.java
new file mode 100644
index 0000000..9e08543
--- /dev/null
+++ b/src/beans/UserManager.java
@@ -0,0 +1,100 @@
+/*
+ * $RCSFile$
+ *
+ * Created on 06.12.2006
+ * for Project:
+ * by steins
+ *
+ * (C) 2005-2006 by
+ */
+package beans;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import jpa.User;
+import static util.DigestUtils.md5;
+
+public class UserManager {
+ private User current;
+
+ private boolean loggedIn;
+
+ 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();
+
+ 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 void setUsername(String username) {
+ current.setUsername(username);
+ }
+
+ public String getUsername() {
+ return current.getUsername();
+ }
+
+ public void setPassword(String password) {
+ current.setPassword(password);
+ }
+
+ public String getPassword() {
+ return current.getPassword();
+ }
+
+ public boolean isLoggedIn() {
+ return loggedIn;
+ }
+
+ 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());
+
+ tx.commit();
+ } catch (Exception ex) {
+ ex.printStackTrace(System.err);
+ tx.rollback();
+ }
+
+ return current;
+ }
+}
diff --git a/src/jpa/Category.java b/src/jpa/Category.java
new file mode 100644
index 0000000..c29c1f7
--- /dev/null
+++ b/src/jpa/Category.java
@@ -0,0 +1,103 @@
+package jpa;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+
+@Entity
+public class Category implements Serializable
+{
+ @Id
+ private int id;
+
+ private String name;
+
+ private String description;
+
+ @ManyToMany(mappedBy = "categoryCollection")
+ private Set<Product> productCollection;
+
+ private static final long serialVersionUID = 1L;
+
+ public Category()
+ {
+ super();
+ }
+
+ public int getId()
+ {
+ return this.id;
+ }
+
+ public void setId(int id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return this.name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getDescription()
+ {
+ return this.description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ /**
+ * 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> getProductCollection()
+ {
+ return this.productCollection;
+ }
+
+ 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);
+ }
+ }
+
+}
diff --git a/src/jpa/JPATest.java b/src/jpa/JPATest.java
new file mode 100644
index 0000000..5a4749e
--- /dev/null
+++ b/src/jpa/JPATest.java
@@ -0,0 +1,62 @@
+package jpa;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+public class JPATest
+{
+ /**
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ EntityManagerFactory factory = Persistence
+ .createEntityManagerFactory("catalog");
+ EntityManager manager = factory.createEntityManager();
+ EntityTransaction tx = manager.getTransaction();
+ tx.begin();
+ try
+ {
+// Product product = manager.find(Product.class, "7");
+// Category newCategory = manager.find(Category.class, 4);
+// product.addCategory(newCategory);
+// manager.persist(product);
+// Collection<Category> categories = product.getCategoryCollection();
+// for (Category category : categories)
+// {
+// System.out.println(category.getName());
+// }
+ Product product = new Product();
+ product.setDescription("Noch ein Testprodukt");
+ product.setName("Produkt");
+ manager.persist(product);
+// User user = new User();
+// user.setUsername("bestertester2");
+// System.out.println(DigestUtils.md5("masterkey"));
+// user.setPassword(DigestUtils.md5("masterkey"));
+// manager.persist(user);
+
+ tx.commit();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace(System.err);
+ tx.rollback();
+ }
+
+// CategoryManager cm = new CategoryManager();
+// Collection<Category> categories = cm.getCategories();
+// for (Category category : categories)
+// {
+// System.out.println(category.getName());
+// Set<Product> products = category.getProductCollection();
+// for (Product product : products)
+// {
+// System.out.println("\t" + product.getName());
+// }
+//
+// }
+ }
+}
diff --git a/src/jpa/Product.java b/src/jpa/Product.java
new file mode 100644
index 0000000..dc0b3f8
--- /dev/null
+++ b/src/jpa/Product.java
@@ -0,0 +1,113 @@
+package jpa;
+
+import java.io.Serializable;
+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;
+
+@Entity
+public class Product implements Serializable {
+ @Id
+ @GeneratedValue(strategy=GenerationType.SEQUENCE)
+ private String id;
+
+ private String description;
+
+ private BigDecimal price;
+
+ private String name;
+
+ private BigDecimal width;
+
+ private BigDecimal height;
+
+ @ManyToMany
+ @JoinTable(
+ joinColumns=@JoinColumn(name="product_id"),
+ inverseJoinColumns=@JoinColumn(name="category_id"))
+ private Set<Category> categoryCollection;
+
+ private static final long serialVersionUID = 1L;
+
+ public Product() {
+ super();
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public BigDecimal getPrice() {
+ return this.price;
+ }
+
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public BigDecimal getWidth() {
+ return this.width;
+ }
+
+ public void setWidth(BigDecimal width) {
+ this.width = width;
+ }
+
+ public BigDecimal getHeight() {
+ return this.height;
+ }
+
+ public void setHeight(BigDecimal height) {
+ this.height = height;
+ }
+
+ public Collection getCategories() {
+ return this.getCategoryCollection();
+ }
+
+ public Set<Category> getCategoryCollection() {
+ return this.categoryCollection;
+ }
+
+ public void setCategoryCollection(Set<Category> categoryCollection) {
+ this.categoryCollection = categoryCollection;
+ }
+
+ public void addCategory(Category category)
+ {
+ Set<Category> categories = getCategoryCollection();
+ if (!categories.contains(category))
+ {
+ categories.add(category);
+ category.addProduct(this);
+ }
+ }
+}
diff --git a/src/jpa/User.java b/src/jpa/User.java
new file mode 100644
index 0000000..32d2af8
--- /dev/null
+++ b/src/jpa/User.java
@@ -0,0 +1,36 @@
+package jpa;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class User implements Serializable {
+ @Id
+ private String username;
+
+ private String password;
+
+ private static final long serialVersionUID = 1L;
+
+ public User() {
+ super();
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
diff --git a/src/resources.properties b/src/resources.properties
new file mode 100644
index 0000000..8e1cc07
--- /dev/null
+++ b/src/resources.properties
@@ -0,0 +1,2 @@
+prompt=Your Name\:
+greeting=Hello
diff --git a/src/util/DigestUtils.java b/src/util/DigestUtils.java
new file mode 100644
index 0000000..4633715
--- /dev/null
+++ b/src/util/DigestUtils.java
@@ -0,0 +1,58 @@
+/*
+ * $RCSFile$
+ *
+ * Created on 06.12.2006
+ * for Project:
+ * by steins
+ *
+ * (C) 2005-2006 by
+ */
+package util;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class DigestUtils
+{
+ private static final String HEX_DIGITS = "0123456789abcdef";
+
+ private DigestUtils()
+ {
+ }
+
+ public static String bin2hex(byte[] bin)
+ {
+ StringBuilder sb = new StringBuilder(32);
+ for (int i = 0; i < bin.length; ++i)
+ {
+ byte b = bin[i];
+ int h = (b & 0xf0) >> 4;
+ sb.append(HEX_DIGITS.charAt(h));
+ h = b & 0x0f;
+ sb.append(HEX_DIGITS.charAt(h));
+ }
+
+ return sb.substring(0);
+ }
+
+ public static String md5(String s)
+ {
+ MessageDigest md = null;
+ try
+ {
+ md = MessageDigest.getInstance("MD5");
+ md.update(s.getBytes("ISO-8859-1"));
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ e.printStackTrace();
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ e.printStackTrace();
+ }
+
+ return bin2hex(md.digest());
+ }
+}