You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2008/08/06 11:42:08 UTC
svn commit: r683201 [2/3] - in
/incubator/empire-db/trunk/struts2-ext/DBWebSample: ./ .settings/ WebRoot/
WebRoot/META-INF/ WebRoot/WEB-INF/ WebRoot/css/ WebRoot/jsp/ src/ src/org/
src/org/apache/ src/org/apache/empire/ src/org/apache/empire/struts2/ s...
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeDetails.jsp
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeDetails.jsp?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeDetails.jsp (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeDetails.jsp Wed Aug 6 02:42:05 2008
@@ -0,0 +1,60 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" import="org.apache.empire.struts2.websample.db.*"%>
+<%@ taglib prefix="e" uri="/empire-tags" %>
+<jsp:useBean id="db" scope="application" type="org.apache.empire.struts2.websample.db.SampleDB"/>
+<jsp:useBean id="action" scope="request" type="org.apache.empire.struts2.websample.web.actions.EmployeeDetailAction"/>
+<%
+ SampleDB.Employees EMP = db.T_EMPLOYEES;
+%>
+<html>
+<head>
+ <link href="css/main.css" rel="stylesheet" type="text/css"/>
+ <title><e:text value="!application.title"/></title>
+</head>
+<body>
+<div class="titleDiv"><e:text value="!application.title"/></div>
+<h1>
+<e:if test="<%= action.getEmployee().isNew() %>">
+ <e:text value="!page.label.add"/>
+</e:if>
+<e:else>
+ <e:text value="!page.label.update"/>
+</e:else>
+</h1>
+<e:actionerrors />
+<e:actionmessage />
+
+<e:form record="<%= action.getEmployee() %>" action="!doSave">
+
+ <!--
+ <s:textfield name="employee.firstName" value="%{employee.firstName}" label="%{getText('label.firstName')}" size="40"/>
+ <s:textfield name="employee.lastName" value="%{employee.lastName}" label="%{getText('label.lastName')}" size="40"/>
+ <s:textfield name="employee.age" value="%{employee.age}" label="%{getText('label.age')}" size="20"/>
+ -->
+
+ <e:control column="<%= EMP.C_EMPLOYEE_ID %>" />
+ <e:control column="<%= EMP.C_SALUTATION %>" />
+ <e:control column="<%= EMP.C_FIRSTNAME %>" />
+ <e:control column="<%= EMP.C_LASTNAME %>" />
+ <e:control column="<%= EMP.C_GENDER %>" />
+ <e:control column="<%= EMP.C_DATE_OF_BIRTH %>" />
+ <e:control column="<%= EMP.C_PHONE_NUMBER %>" />
+ <e:control column="<%= EMP.C_DEPARTMENT_ID%>" />
+ <e:control column="<%= EMP.C_RETIRED %>" />
+ <e:control column="<%= EMP.C_UPDATE_TIMESTAMP %>" />
+
+ <%--
+ <s:submit value="%{getText('button.label.submit')}"/>
+ <s:submit value="%{getText('button.label.cancel')}" name="redirect-action:employeeDetail!doCancel"/>
+ --%>
+
+ <tr style="padding-top:20px">
+ <td> </td>
+ <td><e:submit text="!button.label.save" cssStyle="width:100px" embed="false"/>
+ <e:submit text="!button.label.cancel" cssStyle="width:100px" action="!doCancel" embed="false"/>
+ <e:submit text="!button.label.delete" cssStyle="width:100px" action="!doDelete" embed="false"/>
+ </td>
+ </tr>
+
+</e:form>
+</body>
+</html>
\ No newline at end of file
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeList.jsp
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeList.jsp?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeList.jsp (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeList.jsp Wed Aug 6 02:42:05 2008
@@ -0,0 +1,66 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" import="org.apache.empire.struts2.websample.db.*" %>
+<%@ taglib prefix="e" uri="/empire-tags" %>
+<jsp:useBean id="db" scope="application" type="org.apache.empire.struts2.websample.db.SampleDB"/>
+<jsp:useBean id="action" scope="request" type="org.apache.empire.struts2.websample.web.actions.EmployeeListAction"/>
+<%
+ SampleDB.Employees EMP = db.T_EMPLOYEES;
+ SampleDB.Departments DEP = db.T_DEPARTMENTS;
+%>
+<html>
+<head>
+ <link href="css/main.css" rel="stylesheet" type="text/css"/>
+ <e:text tag="title" value="!label.employees"/>
+</head>
+<body>
+<div class="titleDiv"><e:text value="!application.title"/></div>
+<e:actionerrors />
+<e:actionmessage />
+<e:text tag="h1" value="!label.employees.beanList"/>
+<e:link action="employeeDetail!doCreate" text="!link.label.addemployee"/>
+<br/><br/>
+<table class="borderAll">
+ <e:thr>
+ <e:th text="ID" />
+ <e:th text="!label.name" />
+ <e:th text="<%= EMP.C_GENDER.getTitle() %>" />
+ <e:th text="<%= EMP.C_DATE_OF_BIRTH.getTitle() %>" />
+ <e:th text="!label.department" />
+ </e:thr>
+ <e:list source="<%= action.getEmployees() %>">
+ <%-- <jsp:useBean id="bean" scope="page" type="org.apache.empire.struts2.websample.web.actions.EmployeeListAction.EmployeeInfo" /> --%>
+ <e:tr cssClass="even" cssOddClass="odd" columnWrap="nowrap">
+ <e:td column="<%= EMP.C_EMPLOYEE_ID %>" />
+ <e:td column="<%= action.C_FULL_NAME %>" action="employeeDetail!doLoad" item="<%= EMP.C_EMPLOYEE_ID %>" wrap="break-word" />
+ <e:td column="<%= EMP.C_GENDER %>" />
+ <e:td column="<%= EMP.C_DATE_OF_BIRTH %>" />
+ <e:td column="<%= action.C_DEPARTMENT %>" />
+ </e:tr>
+ </e:list>
+</table>
+<p>
+<e:text tag="h1" value="!label.employees.reader"/>
+<p>
+<table class="borderAll">
+ <e:thr>
+ <e:th text="ID" />
+ <e:th column="<%= action.C_FULL_NAME %>" />
+ <e:th column="<%= EMP.C_GENDER %>" />
+ <e:th column="<%= EMP.C_DATE_OF_BIRTH %>" />
+ <e:th column="<%= action.C_DEPARTMENT %>" />
+ </e:thr>
+ <e:list source="<%= action.getReader() %>">
+ <%-- <jsp:useBean id="record" scope="page" type="org.apache.empire.db.DBRecordData" /> --%>
+ <e:tr cssClass="even" cssOddClass="odd" columnWrap="nowrap">
+ <e:td column="<%= EMP.C_EMPLOYEE_ID %>" />
+ <e:td column="<%= action.C_FULL_NAME %>" action="employeeDetail!doLoad" item="<%= EMP.C_EMPLOYEE_ID %>" wrap="break-word" />
+ <e:td column="<%= EMP.C_GENDER %>" />
+ <e:td column="<%= EMP.C_DATE_OF_BIRTH %>" />
+ <e:td column="<%= action.C_DEPARTMENT %>" />
+ </e:tr>
+ </e:list>
+</table>
+<p>
+<e:link action="!doInit" text="!link.label.search"/>
+</p>
+</body>
+</html>
\ No newline at end of file
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeSearch.jsp
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeSearch.jsp?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeSearch.jsp (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/employeeSearch.jsp Wed Aug 6 02:42:05 2008
@@ -0,0 +1,32 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" import="org.apache.empire.struts2.websample.db.*"%>
+<%@ taglib prefix="e" uri="/empire-tags" %>
+<jsp:useBean id="db" scope="application" type="org.apache.empire.struts2.websample.db.SampleDB"/>
+<jsp:useBean id="action" scope="request" type="org.apache.empire.struts2.websample.web.actions.EmployeeListAction"/>
+<%
+ SampleDB.Employees EMP = db.T_EMPLOYEES;
+%>
+<html>
+<head>
+ <link href="css/main.css" rel="stylesheet" type="text/css"/>
+ <title><e:text value="!application.title"/></title>
+</head>
+<body>
+<div class="titleDiv"><e:text value="!application.title"/></div>
+<h1><e:text value="!page.label.search"/></h1>
+<e:actionerrors />
+<e:actionmessage />
+<e:form id="searchForm" action="employeeList!doQuery">
+ <e:control property="searchInfo.employeeId" column="<%= EMP.C_EMPLOYEE_ID %>"></e:control>
+ <e:control property="searchInfo.firstName" column="<%= EMP.C_FIRSTNAME %>" />
+ <e:control property="searchInfo.lastName" column="<%= EMP.C_LASTNAME %>" />
+ <e:control property="searchInfo.departmentId" column="<%= EMP.C_DEPARTMENT_ID %>" options="<%= action.getDepartments() %>" format="allownull" />
+ <!-- Original Struts code -->
+ <!-- s:textfield name="searchInfo.firstName" value="%{searchInfo.firstName}" label="%{getText('label.firstName')}" size="40"/ -->
+ <!-- s:textfield name="searchInfo.lastName" value="%{searchInfo.lastName}" label="%{getText('label.lastName')}" size="40"/ -->
+ <!-- s:select name="searchInfo.departmentId" value="%{searchInfo.departmentId}" list="departments" listKey="key" listValue="value"/ -->
+ <e:submit text="!button.label.search" embed="true"/>
+</e:form>
+<p><e:text value="!page.label.logininfo"/> '<e:text value="%{session.user.userId}"/>'</p>
+<e:link action="login!doLogout" text="!link.label.logout"/>
+</body>
+</html>
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/error.jsp
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/error.jsp?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/error.jsp (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/error.jsp Wed Aug 6 02:42:05 2008
@@ -0,0 +1,19 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="e" uri="/empire-tags" %>
+<html>
+<head>
+ <title>Error Page</title>
+ <link href="<s:url value='/css/main.css'/>" rel="stylesheet" type="text/css"/>
+</head>
+<body>
+<e:actionerrors />
+<br/>
+In order that the development team can address this error, please report what you were doing that caused this error.
+<br/><br/>
+The following information can help the development
+team find where the error happened and what can be done to prevent it from
+happening in the future.
+
+</body>
+</html>
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/login.jsp
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/login.jsp?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/login.jsp (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/WebRoot/jsp/login.jsp Wed Aug 6 02:42:05 2008
@@ -0,0 +1,21 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="e" uri="/empire-tags" %>
+<html>
+<head>
+ <link href="css/main.css" rel="stylesheet" type="text/css"/>
+ <title><e:text value="!application.title"/></title>
+</head>
+<body>
+<div class="titleDiv"><e:text value="!application.title"/></div>
+<h1><e:text value="!page.label.login"/></h1>
+<e:actionerrors />
+<e:actionmessage />
+<p><e:text value="!page.label.loginHint"/></p>
+<e:form action="login!doLogin">
+ <s:textfield name="loginInfo.name" value="%{loginInfo.name}" label="%{getText('label.user.Name')}" size="40"/>
+ <s:textfield name="loginInfo.pwd" value="%{loginInfo.pwd}" label="%{getText('label.user.Pwd')}" size="40"/>
+ <e:submit text="!button.label.login" embed="true"/>
+</e:form>
+</body>
+</html>
\ No newline at end of file
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/classpath_delivery-version
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/classpath_delivery-version?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/classpath_delivery-version (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/classpath_delivery-version Wed Aug 6 02:42:05 2008
@@ -0,0 +1,18 @@
+<?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.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/empire-db-2.0.3.jar"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/empire-struts2-ext-1.0.3.jar"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-beanutils-1.7.0.jar"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-collections-3.2.1.jar"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/log4j-1.2.14.jar"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xwork-2.0.5.jar"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/struts2-core-2.0.11.2.jar"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/ognl-2.6.11.jar"/>
+ <classpathentry kind="lib" path="WebRoot/WEB-INF/lib/hsqldb.jar"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/log4j.dtd
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/log4j.dtd?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/log4j.dtd (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/log4j.dtd Wed Aug 6 02:42:05 2008
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!-- Authors: Chris Taylor, Ceki Gulcu. -->
+
+<!-- Version: 1.2 -->
+
+<!-- A configuration element consists of optional renderer
+elements,appender elements, categories and an optional root
+element. -->
+
+<!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?,
+ categoryFactory?)>
+
+<!-- The "threshold" attribute takes a level value such that all -->
+<!-- logging statements with a level equal or below this value are -->
+<!-- disabled. -->
+
+<!-- Setting the "debug" enable the printing of internal log4j logging -->
+<!-- statements. -->
+
+<!-- By default, debug attribute is "null", meaning that we not do touch -->
+<!-- internal log4j logging settings. The "null" value for the threshold -->
+<!-- attribute can be misleading. The threshold field of a repository -->
+<!-- cannot be set to null. The "null" value for the threshold attribute -->
+<!-- simply means don't touch the threshold field, the threshold field -->
+<!-- keeps its old value. -->
+
+<!ATTLIST log4j:configuration
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ threshold (all|debug|info|warn|error|fatal|off|null) "null"
+ debug (true|false|null) "null"
+>
+
+<!-- renderer elements allow the user to customize the conversion of -->
+<!-- message objects to String. -->
+
+<!ELEMENT renderer EMPTY>
+<!ATTLIST renderer
+ renderedClass CDATA #REQUIRED
+ renderingClass CDATA #REQUIRED
+>
+
+<!-- Appenders must have a name and a class. -->
+<!-- Appenders may contain an error handler, a layout, optional parameters -->
+<!-- and filters. They may also reference (or include) other appenders. -->
+<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)>
+<!ATTLIST appender
+ name ID #REQUIRED
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT layout (param*)>
+<!ATTLIST layout
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT filter (param*)>
+<!ATTLIST filter
+ class CDATA #REQUIRED
+>
+
+<!-- ErrorHandlers can be of any class. They can admit any number of -->
+<!-- parameters. -->
+
+<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)>
+<!ATTLIST errorHandler
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT root-ref EMPTY>
+
+<!ELEMENT logger-ref EMPTY>
+<!ATTLIST logger-ref
+ ref IDREF #REQUIRED
+>
+
+<!ELEMENT param EMPTY>
+<!ATTLIST param
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED
+>
+
+
+<!-- The priority class is org.apache.log4j.Level by default -->
+<!ELEMENT priority (param*)>
+<!ATTLIST priority
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+<!-- The level class is org.apache.log4j.Level by default -->
+<!ELEMENT level (param*)>
+<!ATTLIST level
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named category. -->
+<!ELEMENT category (param*,(priority|level)?,appender-ref*)>
+<!ATTLIST category
+ class CDATA #IMPLIED
+ name CDATA #REQUIRED
+ additivity (true|false) "true"
+>
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named logger. -->
+<!ELEMENT logger (level?,appender-ref*)>
+<!ATTLIST logger
+ name ID #REQUIRED
+ additivity (true|false) "true"
+>
+
+
+<!ELEMENT categoryFactory (param*)>
+<!ATTLIST categoryFactory
+ class CDATA #REQUIRED>
+
+<!ELEMENT appender-ref EMPTY>
+<!ATTLIST appender-ref
+ ref IDREF #REQUIRED
+>
+
+<!-- If no priority element is specified, then the configurator MUST not -->
+<!-- touch the priority of root. -->
+<!-- The root category always exists and cannot be subclassed. -->
+<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
+
+
+<!-- ==================================================================== -->
+<!-- A logging event -->
+<!-- ==================================================================== -->
+<!ELEMENT log4j:eventSet (log4j:event*)>
+<!ATTLIST log4j:eventSet
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ version (1.1|1.2) "1.2"
+ includesLocationInfo (true|false) "true"
+>
+
+
+
+<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?,
+ log4j:locationInfo?) >
+
+<!-- The timestamp format is application dependent. -->
+<!ATTLIST log4j:event
+ logger CDATA #REQUIRED
+ level CDATA #REQUIRED
+ thread CDATA #REQUIRED
+ timestamp CDATA #REQUIRED
+>
+
+<!ELEMENT log4j:message (#PCDATA)>
+<!ELEMENT log4j:NDC (#PCDATA)>
+
+<!ELEMENT log4j:throwable (#PCDATA)>
+
+<!ELEMENT log4j:locationInfo EMPTY>
+<!ATTLIST log4j:locationInfo
+ class CDATA #REQUIRED
+ method CDATA #REQUIRED
+ file CDATA #REQUIRED
+ line CDATA #REQUIRED
+>
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/log4j.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/log4j.xml?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/log4j.xml (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/log4j.xml Wed Aug 6 02:42:05 2008
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="default" class="org.apache.log4j.ConsoleAppender">
+ <!-- layout class="org.apache.log4j.TTCCLayout"/ -->
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- param name="ConversionPattern" value="NSB(%c) %-5p %m at %l%n"/ -->
+ <param name="ConversionPattern" value="%-5p: %m at %l %n"/>
+ </layout>
+ </appender>
+
+ <!-- log detail configuration -->
+
+ <logger name="org.apache" additivity="false">
+ <level value="warn"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <logger name="org.apache.struts2" additivity="false">
+ <level value="info"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <logger name="com.opensymphony.xwork" additivity="false">
+ <level value="info"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <logger name="freemarker" additivity="false">
+ <level value="warn"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <logger name="com.mevipro" additivity="false">
+ <level value="debug"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <logger name="org.apache.empire.commons" additivity="false">
+ <level value="warn"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <logger name="org.apache.empire.db" additivity="false">
+ <level value="debug"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <logger name="org.apache.empire.struts2" additivity="false">
+ <level value="debug"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <logger name="org.apache.empire.struts2.websample" additivity="false">
+ <level value="info"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <root>
+ <priority value="warn"/>
+ <appender-ref ref="default"/>
+ </root>
+
+</log4j:configuration>
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/messages_de.properties
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/messages_de.properties?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/messages_de.properties (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/messages_de.properties Wed Aug 6 02:42:05 2008
@@ -0,0 +1,73 @@
+
+#fields
+field.title.employees.employeeId=Mitarbeiter Nr.
+field.title.employees.salutation=Anrede
+field.title.employees.firstname=Vorname
+field.title.employees.lastname=Nachname
+field.title.employees.dateOfBirth=Geburtsdatum
+field.title.employees.departmentId=Abteilung
+field.title.employees.gender=Geschlecht
+field.title.employees.phoneNumber=Telefonnummer
+field.title.employees.email=E-Mail
+field.title.employees.retired=Ausgeschieden
+field.title.employees.updateTimestamp=Zuletzt geändert am
+field.title.departments.name=Abteilungsname
+field.title.departments.head=Abteilugnsleiter
+
+#options
+option.employee.gender.male=Männlich
+option.employee.gender.female=Weiblich
+
+#labels
+application.title=Mitarbeiterverwaltung (Empire-db)
+label.employees=Mitarbeiterliste
+label.employees.beanList=Mitarbeiterliste (Bean-Liste)
+label.employees.reader=Mitarbeiterliste (DBReader)
+label.delete=Löschen
+label.edit=Bearbeiten
+label.employee.edit=Eintrag bearbeiten
+label.employee.add=Eintrag hinzufügen
+label.name=Name
+label.gender=Geschlecht
+label.age=Alter
+label.department=Abteilung
+label.user.Name=Name
+label.user.Pwd=Passwort
+
+page.label.login=Anmelden
+page.label.loginHint=Hinweis: Geben Sie einen beliebigen Benutzernamen und Kennwort an.
+page.label.logininfo=Sie sind angemeldet als:
+page.label.search=Mitarbeiter suchen
+page.label.list=Mitarbeiter auswählen
+page.label.update=Mitarbeiter bearbeiten
+page.label.add=Mitarbeiter hinzufügen
+
+#button labels
+button.label.login=Anmelden
+button.label.search=Suchen...
+button.label.save=Speichern
+button.label.cancel=Abbrechen
+button.label.delete=Löschen
+
+#link labels
+link.label.addemployee=Neuen Eintrag anlegen
+link.label.edit=Bearbeiten
+link.label.delete=Löschen
+link.label.logout=Logout
+link.label.search=Suchen
+
+##-- errors
+errors.prefix=<span style="color:red;font-weight:bold;">
+errors.suffix=</span>
+
+error.invalidpassword=Der eingegebene Benutzername ist ungültig (Es ist mindestens ein Zeichen erforderlich!)
+error.web.recordsDontMatch=The form submitted is invalid for the current context.
+error.web.columnNotFound=Die Spalte {0} wurde nicht gefunden!
+error.web.fieldError=Feld {0}: {1}
+error.web.input.integerFormat=Ungültiges Zahlenformat
+error.web.input.numberFormat=Ungültiges Zahlenformat
+error.web.input.dateFormat=Ungültiges Datumsformat
+error.web.input.date.notime=Es wurde keine Zeit angegeben
+error.web.input.required=Das Feld ist eingabepflichtig
+error.web.input.outOfRange=Der Wert muss zwischen {0} und {1} liegen.
+error.web.input.textTooShort=Der Wert muss mindestens {0} Zeichen enthalten.
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/messages_en.properties
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/messages_en.properties?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/messages_en.properties (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/messages_en.properties Wed Aug 6 02:42:05 2008
@@ -0,0 +1,70 @@
+
+#fields
+field.title.employees.employeeId=Employee ID
+field.title.employees.salutation=Salutation
+field.title.employees.firstname=Firstname
+field.title.employees.lastname=Lastname
+field.title.employees.dateOfBirth=Date of Birth
+field.title.employees.departmentId=Department
+field.title.employees.gender=Gender
+field.title.employees.phoneNumber=Phone
+field.title.employees.email=E-Mail
+field.title.employees.retired=Retired
+field.title.employees.updateTimestamp=Last change
+field.title.departments.name=Department
+field.title.departments.head=Head of Dept.
+
+#options
+option.employee.gender.male=Male
+option.employee.gender.female=Female
+
+#labels
+application.title=Employee Management Application
+label.employees=List of employees
+label.employees.beanList=Employees (Bean-List)
+label.employees.reader=Employees (DBReader)
+label.delete=Delete
+label.edit=Edit
+label.employee.edit=Employee details
+label.employee.add=Add employee
+label.department=Department
+label.user.Name=Name
+label.user.Pwd=Password
+
+page.label.login=Login
+page.label.loginHint=Hint: enter any non null username and password.
+page.label.logininfo=You are logged in as:
+page.label.search=Search employee
+page.label.list=Select employee
+page.label.update=Edit employee details
+page.label.add=Add new employee
+
+#button labels
+button.label.login=Login
+button.label.search=Search
+button.label.save=Save
+button.label.cancel=Cancel
+button.label.delete=Delete
+
+#link labels
+link.label.addemployee=Add new employee
+link.label.edit=Edit
+link.label.delete=Delete
+link.label.logout=Logout
+link.label.search=Search
+
+##-- errors
+errors.prefix=<span style="color:red;font-weight:bold;">
+errors.suffix=</span>
+
+error.invalidpassword=The username is invalid (At least one character is required!)
+error.web.recordsDontMatch=The form submitted is invalid for the current context.
+error.web.columnNotFound=The column {0} has not been found!
+error.web.fieldError=Field {0}: {1}
+error.web.input.integerFormat=Invalid Integer format
+error.web.input.numberFormat=Invalid number format
+error.web.input.dateFormat=Invalid date format
+error.web.input.date.notime=No time specified.
+error.web.input.required=This field is required
+error.web.input.outOfRange=The value must be in the range of {0} and {1}.
+error.web.input.textTooShort=The value must contain at least {0} characters.
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleDB.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleDB.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleDB.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleDB.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,119 @@
+package org.apache.empire.struts2.websample.db;
+
+import org.apache.empire.commons.Options;
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBColumn;
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBTableColumn;
+import org.apache.empire.struts2.websample.web.SampleApplication;
+
+
+public class SampleDB extends DBDatabase
+{
+ // Static Access
+ public static SampleDB getInstance()
+ {
+ return SampleApplication.getInstance().getDatabase();
+ }
+
+ /**
+ * Tabellendefinition für Departments
+ */
+ public static class Departments extends SampleTable
+ {
+ public final DBTableColumn C_DEPARTMENT_ID;
+ public final DBTableColumn C_NAME;
+ public final DBTableColumn C_HEAD;
+ public final DBTableColumn C_BUSINESS_UNIT;
+ public final DBTableColumn C_UPDATE_TIMESTAMP;
+
+ // Konstruktor für Tabelle
+ public Departments(DBDatabase db)
+ {
+ super("DEPARTMENTS", db);
+ // ID
+ C_DEPARTMENT_ID = addColumn("DEPARTMENT_ID", DataType.AUTOINC, 0, true, "DEP_ID_SEQUENCE");
+ C_NAME = addColumn("NAME", DataType.TEXT, 80, true);
+ C_HEAD = addColumn("HEAD", DataType.TEXT, 80, false);
+ C_BUSINESS_UNIT = addColumn("BUSINESS_UNIT", DataType.TEXT, 4, true, "ITTK");
+ C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME, 0, true);
+
+ // Primary Key
+ setPrimaryKey(C_DEPARTMENT_ID);
+ // Set other Indexes
+ addIndex("DEARTMENT_NAME_IDX", true, new DBColumn[] { C_NAME });
+ // Set timestamp column for save updates
+ setTimestampColumn(C_UPDATE_TIMESTAMP);
+
+ }
+ }
+
+ /**
+ * Tabellendefinition für Persons
+ */
+ public static class Employees extends SampleTable
+ {
+ public final DBTableColumn C_EMPLOYEE_ID;
+ public final DBTableColumn C_SALUTATION;
+ public final DBTableColumn C_FIRSTNAME;
+ public final DBTableColumn C_LASTNAME;
+ public final DBTableColumn C_DATE_OF_BIRTH;
+ public final DBTableColumn C_DEPARTMENT_ID;
+ public final DBTableColumn C_GENDER;
+ public final DBTableColumn C_PHONE_NUMBER;
+ public final DBTableColumn C_EMAIL;
+ public final DBTableColumn C_RETIRED;
+ public final DBTableColumn C_UPDATE_TIMESTAMP;
+
+ // Konstruktor für Tabelle
+ public Employees(DBDatabase db)
+ {
+ super("EMPLOYEES", db);
+ // ID
+ C_EMPLOYEE_ID = addColumn("EMPLOYEE_ID", DataType.AUTOINC, 0, true, "EMPLOYEE_ID_SEQUENCE");
+ C_SALUTATION = addColumn("SALUTATION", DataType.TEXT, 20, false);
+ C_FIRSTNAME = addColumn("FIRSTNAME", DataType.TEXT, 40, true);
+ C_LASTNAME = addColumn("LASTNAME", DataType.TEXT, 40, true);
+ C_DATE_OF_BIRTH = addColumn("DATE_OF_BIRTH", DataType.DATE, 0, false);
+ C_DEPARTMENT_ID = addColumn("DEPARTMENT_ID", DataType.INTEGER, 0, true);
+ C_GENDER = addColumn("GENDER", DataType.TEXT, 1, false);
+ C_PHONE_NUMBER = addColumn("PHONE_NUMBER", DataType.TEXT, 40, false);
+ C_EMAIL = addColumn("EMAIL", DataType.TEXT, 80, false);
+ C_RETIRED = addColumn("RETIRED", DataType.BOOL, 0, true, false);
+ C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME, 0, true);
+
+ // Primary Key
+ setPrimaryKey(C_EMPLOYEE_ID);
+ // Set other Indexes
+ addIndex("PERSON_NAME_IDX", true, new DBColumn[] { C_FIRSTNAME, C_LASTNAME, C_DATE_OF_BIRTH });
+ // Set timestamp column for save updates
+ setTimestampColumn(C_UPDATE_TIMESTAMP);
+
+ // Create Options for GENDER column
+ Options genders = new Options();
+ genders.set("M", "!option.employee.gender.male");
+ genders.set("F", "!option.employee.gender.female");
+ C_GENDER.setOptions(genders);
+ C_GENDER.setControlType("select");
+
+ // Set special control types
+ C_DEPARTMENT_ID.setControlType("select");
+ C_PHONE_NUMBER .setControlType("phone");
+
+ }
+ }
+
+ // Tabellen
+ public final Departments T_DEPARTMENTS = new Departments(this);
+ public final Employees T_EMPLOYEES = new Employees(this);
+
+ /**
+ * Konstruktor SampleDB
+ */
+ public SampleDB()
+ {
+ // Define Foreign-Key Relations
+ addRelation( T_EMPLOYEES.C_DEPARTMENT_ID.referenceOn( T_DEPARTMENTS.C_DEPARTMENT_ID ));
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleRecord.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleRecord.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleRecord.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleRecord.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,19 @@
+/*
+ * ESTEAM Software GmbH, 06.10.2007
+ */
+package org.apache.empire.struts2.websample.db;
+
+import org.apache.empire.db.DBRecord;
+import org.apache.empire.struts2.websample.web.SampleContext;
+
+
+public class SampleRecord extends DBRecord
+{
+ // DBRecord members
+ protected SampleContext context;
+
+ public SampleRecord(SampleContext context)
+ {
+ this.context = context;
+ }
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleTable.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleTable.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleTable.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/SampleTable.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,42 @@
+/*
+ * ESTEAM Software GmbH, 07.12.2007
+ */
+package org.apache.empire.struts2.websample.db;
+
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBTable;
+import org.apache.empire.db.DBTableColumn;
+
+/**
+ * Base class definition for all database tables
+ * Automatically generates a message-key for the field title
+ * e.g. for the column EMPLOYEES.DATE_OF_BIRTH
+ * it generates the key "!field.title.employees.dateOfBirth";
+ */
+public class SampleTable extends DBTable
+{
+ public final String MESSAGE_KEY_PREFIX = "!field.title.";
+
+ public SampleTable(String name, DBDatabase db)
+ {
+ super(name, db);
+ }
+
+ @Override
+ protected boolean addColumn(DBTableColumn column)
+ {
+ // Set Translation Title
+ String col = column.getBeanPropertyName();
+ String tbl = getName().toLowerCase();
+ String key = MESSAGE_KEY_PREFIX + tbl + "." + col;
+ column.setTitle(key);
+
+ // Set Default Control Type
+ DataType type = column.getDataType();
+ column.setControlType((type==DataType.BOOL) ? "checkbox" : "text");
+
+ // Add Column
+ return super.addColumn(column);
+ }
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/records/DepartmentRecord.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/records/DepartmentRecord.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/records/DepartmentRecord.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/records/DepartmentRecord.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,16 @@
+package org.apache.empire.struts2.websample.db.records;
+
+import org.apache.empire.struts2.websample.db.SampleDB;
+import org.apache.empire.struts2.websample.db.SampleRecord;
+import org.apache.empire.struts2.websample.web.SampleContext;
+
+public class DepartmentRecord extends SampleRecord
+{
+ public static final SampleDB.Departments T = SampleDB.getInstance().T_DEPARTMENTS;
+
+ // Department Record
+ public DepartmentRecord(SampleContext context)
+ {
+ super(context);
+ }
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/records/EmployeeRecord.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/records/EmployeeRecord.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/records/EmployeeRecord.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/db/records/EmployeeRecord.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,49 @@
+package org.apache.empire.struts2.websample.db.records;
+
+import org.apache.empire.commons.Options;
+import org.apache.empire.db.DBColumn;
+import org.apache.empire.db.DBCommand;
+import org.apache.empire.struts2.websample.db.SampleDB;
+import org.apache.empire.struts2.websample.db.SampleRecord;
+import org.apache.empire.struts2.websample.web.SampleContext;
+
+
+public class EmployeeRecord extends SampleRecord
+{
+ public static final SampleDB.Employees T = SampleDB.getInstance().T_EMPLOYEES;
+
+ /*
+ * Constructor
+ */
+ public EmployeeRecord(SampleContext context)
+ {
+ super(context);
+ }
+
+ // Sample Implementation for Department Record
+ public DepartmentRecord getDepartmentRecord()
+ {
+ DepartmentRecord rec = new DepartmentRecord(context);
+ SampleDB.Departments table = SampleDB.getInstance().T_DEPARTMENTS;
+ if (!rec.read(table, this.getInt(T.C_DEPARTMENT_ID), context.getConnection())) {
+ log.error("Unable to get department record. Message is " + rec.getErrorMessage());
+ return null;
+ }
+ return rec;
+ }
+
+ @Override
+ public Options getFieldOptions(DBColumn column)
+ {
+ if (column.equals(T.C_DEPARTMENT_ID)) {
+ SampleDB db = (SampleDB)getDatabase();
+ DBCommand cmd = db.createCommand();
+ cmd.select(db.T_DEPARTMENTS.C_DEPARTMENT_ID);
+ cmd.select(db.T_DEPARTMENTS.C_NAME);
+ return db.queryOptionList(cmd.getSelect(), context.getConnection());
+ }
+ // base class implementation
+ return super.getFieldOptions(column);
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleApplication.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleApplication.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleApplication.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleApplication.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,251 @@
+package org.apache.empire.struts2.websample.web;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import javax.servlet.ServletContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.db.DBCommand;
+import org.apache.empire.db.DBDatabaseDriver;
+import org.apache.empire.db.DBRecord;
+import org.apache.empire.db.DBSQLScript;
+import org.apache.empire.db.hsql.DBDatabaseDriverHSql;
+import org.apache.empire.db.mysql.DBDatabaseDriverMySQL;
+import org.apache.empire.db.oracle.DBDatabaseDriverOracle;
+import org.apache.empire.db.sqlserver.DBDatabaseDriverMSSQL;
+import org.apache.empire.struts2.actionsupport.TextProviderActionSupport;
+import org.apache.empire.struts2.html.HtmlTagDictionary;
+import org.apache.empire.struts2.web.WebApplication;
+import org.apache.empire.struts2.websample.db.SampleDB;
+
+
+public class SampleApplication implements WebApplication {
+ // Logger
+ protected static Log log = LogFactory.getLog(SampleApplication.class);
+
+ // must be singleton
+ private static SampleApplication application;
+
+ public static SampleApplication getInstance()
+ {
+ return application;
+ }
+
+ // Non-Static
+ private SampleDB db = new SampleDB();
+ private SampleConfig config = new SampleConfig();
+
+ private Connection conn = null;
+
+ public void init(ServletContext servletContext) {
+ try {
+
+ // Application
+ if (application != null) {
+ log.fatal("Application has already been initiallized!");
+ return;
+ }
+ application = this;
+
+ // register all controls
+ // InputControlManager.registerControl("myType", new
+ // MyTypeInputControl());
+ config.init(servletContext.getRealPath("WEB-INF/config.xml"));
+
+ // Set Html Dictionary
+ HtmlTagDictionary.set(new SampleHtmlTagDictionary());
+
+ // Set Database to Servlet Context
+ servletContext.setAttribute("db", db);
+
+ // Get a JDBC Connection
+ log.info("*** getJDBCConnection() ***");
+ conn = getJDBCConnection(servletContext);
+
+ // Choose a driver
+ log.info("*** create DBDatabaseDriverOracle() ***");
+ DBDatabaseDriver driver = getDatabaseDriver(config.getDatabaseProvider());
+
+ // Open Database (and create if not existing)
+ log.info("*** open database ***");
+ if (!db.open(driver, conn) || !databaseExists(conn)) {
+ // STEP 4: Create Database
+ log.info("*** create Database ***");
+ createSampleDatabase(driver, conn);
+ }
+
+ /*
+ // Check Database Definition against Real Database(log differences)
+ log.info("*** driver.checkDatabase() ***");
+ driver.checkDatabase(db, config.getSchemaName(), conn);
+ */
+
+ // Disable Message caching
+ TextProviderActionSupport.setCachingEnabled(false);
+
+ // Done
+ log.info("Application initialized ");
+
+ } catch (Exception e) {
+ // Error
+ log.info(e.toString());
+ e.printStackTrace();
+ }
+
+ }
+
+ public SampleDB getDatabase() {
+ return db;
+ }
+
+ public Connection getPooledConnection() {
+ return conn;
+ }
+
+ public void releaseConnection(Connection conn) {
+ // Return Connection to Connection Pool
+ }
+
+ /*
+ * getJDBCConnection
+ */
+ private Connection getJDBCConnection(ServletContext servletContext) {
+ // Establish a new database connection
+ Connection conn = null;
+ String jdbcURL = config.getJdbcURL();
+ if (jdbcURL.indexOf("file:")>0)
+ jdbcURL = StringUtils.replace(jdbcURL, "file:", "file:"+servletContext.getRealPath("/"));
+ // Connect
+ log.info("Connecting to Database'" + jdbcURL + "' / User=" + config.getJdbcUser());
+ try { // Connect to the databse
+ Class.forName(config.getJdbcClass()).newInstance();
+ conn = DriverManager.getConnection(jdbcURL, config.getJdbcUser(), config.getJdbcPwd());
+ log.info("Connected successfully");
+ // set the AutoCommit to false this session. You must commit
+ // explicitly now
+ conn.setAutoCommit(false);
+ log.info("AutoCommit is " + conn.getAutoCommit());
+
+ } catch (Exception e) {
+ log.error("Failed to connect directly to '" + config.getJdbcURL() + "' / User=" + config.getJdbcUser());
+ log.error(e.toString());
+ throw new RuntimeException(e);
+ }
+ return conn;
+ }
+
+ /*
+ * getDatabaseDriver
+ */
+ private DBDatabaseDriver getDatabaseDriver(String provider)
+ {
+ if (provider.equalsIgnoreCase("mysql"))
+ {
+ DBDatabaseDriverMySQL driver = new DBDatabaseDriverMySQL();
+ // Set Driver specific properties (if any)
+ driver.setDatabaseName(config.getSchemaName());
+ return driver;
+ }
+ else if (provider.equalsIgnoreCase("oracle"))
+ {
+ DBDatabaseDriverOracle driver = new DBDatabaseDriverOracle();
+ // Set Driver specific properties (if any)
+ return driver;
+ }
+ else if (provider.equalsIgnoreCase("sqlserver"))
+ {
+ DBDatabaseDriverMSSQL driver = new DBDatabaseDriverMSSQL();
+ // Set Driver specific properties (if any)
+ driver.setDatabaseName(config.getSchemaName());
+ return driver;
+ }
+ else if (provider.equalsIgnoreCase("hsqldb"))
+ {
+ DBDatabaseDriverHSql driver = new DBDatabaseDriverHSql();
+ // Set Driver specific properties (if any)
+ return driver;
+ }
+ else
+ { // Unknown Provider
+ throw new RuntimeException("Unknown Database Provider " + provider);
+ }
+ }
+
+ private boolean databaseExists(Connection conn) {
+ // Check wether DB exists
+ DBCommand cmd = db.createCommand();
+ cmd.select(db.T_DEPARTMENTS.count());
+ return (db.querySingleInt(cmd.getSelect(), -1, conn) >= 0);
+ }
+
+ /*
+ * creates a DDL Script for the entire SampleDB Database then checks if the
+ * department table exists by running "select count(*) from DEPARTMENTS" if
+ * the department tables does not exist, the entire dll-script is executed
+ * line by line
+ */
+ private void createSampleDatabase(DBDatabaseDriver driver, Connection conn)
+ {
+ // create DLL for Database Definition
+ DBSQLScript script = new DBSQLScript();
+ db.getCreateDDLScript(driver, script);
+ // Show DLL Statements
+ System.out.println(script.toString());
+ // Execute Script
+ script.run(driver, conn, false);
+ db.commit(conn);
+ // Open again
+ if (!db.isOpen() && !db.open(driver, conn))
+ new RuntimeException(driver.getErrorMessage());
+ // Insert Sample Departments
+ int idDevDep = insertDepartmentSampleRecord(conn, "Development", "ITTK");
+ int idSalDep = insertDepartmentSampleRecord(conn, "Sales", "ITTK");
+ // Insert Sample Employees
+ insertEmployeeSampleRecord(conn, "Mr.", "Eugen", "Miller", "M", idDevDep);
+ insertEmployeeSampleRecord(conn, "Mr.", "Max", "Mc. Callahan", "M", idDevDep);
+ insertEmployeeSampleRecord(conn, "Mrs.", "Anna", "Smith", "F", idSalDep);
+ // Commit
+ db.commit(conn);
+ }
+
+ /*
+ * Insert a department
+ */
+ private int insertDepartmentSampleRecord(Connection conn, String department_name, String businessUnit) {
+ // Insert a Department
+ DBRecord rec = new DBRecord();
+ rec.create(db.T_DEPARTMENTS);
+ rec.setValue(db.T_DEPARTMENTS.C_NAME, department_name);
+ rec.setValue(db.T_DEPARTMENTS.C_BUSINESS_UNIT, businessUnit);
+ if (!rec.update(conn)) {
+ log.error(rec.getErrorMessage());
+ return 0;
+ }
+ // Return Department ID
+ return rec.getInt(db.T_DEPARTMENTS.C_DEPARTMENT_ID);
+ }
+
+ /*
+ * Insert a person
+ */
+ private int insertEmployeeSampleRecord(Connection conn, String salutation, String firstName, String lastName, String gender, int depID) {
+ // Insert an Employee
+ DBRecord rec = new DBRecord();
+ rec.create(db.T_EMPLOYEES);
+ rec.setValue(db.T_EMPLOYEES.C_SALUTATION, salutation);
+ rec.setValue(db.T_EMPLOYEES.C_FIRSTNAME, firstName);
+ rec.setValue(db.T_EMPLOYEES.C_LASTNAME, lastName);
+ rec.setValue(db.T_EMPLOYEES.C_GENDER, gender);
+ rec.setValue(db.T_EMPLOYEES.C_DEPARTMENT_ID, depID);
+ if (!rec.update(conn)) {
+ log.error(rec.getErrorMessage());
+ return 0;
+ }
+ // Return Employee ID
+ return rec.getInt(db.T_EMPLOYEES.C_EMPLOYEE_ID);
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleConfig.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleConfig.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleConfig.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,83 @@
+package org.apache.empire.struts2.websample.web;
+
+import org.apache.empire.xml.XMLConfiguration;
+
+public class SampleConfig extends XMLConfiguration {
+
+ private String databaseProvider = "oracle";
+
+ private String jdbcClass = "oracle.jdbc.driver.OracleDriver";
+
+ private String jdbcURL = "jdbc:oracle:thin:@192.168.0.2:1521:ora10";
+
+ private String jdbcUser = "DBSAMPLE";
+
+ private String jdbcPwd = "DBSAMPLE";
+
+ private String schemaName = "DBSAMPLE";
+
+ /**
+ * Initialize the configuration
+ */
+ public boolean init(String filename) {
+ // Read the properties file
+ if (super.init(filename, false, true) == false)
+ return false;
+ // Done
+ if (readProperties(this, "properties")==false)
+ return false;
+ // Reader Provider Properties
+ return readProperties(this, "properties-" + databaseProvider);
+ }
+
+ public String getDatabaseProvider() {
+ return databaseProvider;
+ }
+
+ public String getJdbcClass() {
+ return jdbcClass;
+ }
+
+ public void setJdbcClass(String jdbcClass) {
+ this.jdbcClass = jdbcClass;
+ }
+
+ public String getJdbcPwd() {
+ return jdbcPwd;
+ }
+
+ public void setJdbcPwd(String jdbcPwd) {
+ this.jdbcPwd = jdbcPwd;
+ }
+
+ public String getJdbcURL() {
+ return jdbcURL;
+ }
+
+ public String getSchemaName() {
+ return schemaName;
+ }
+
+ // ------- Setters -------
+
+ public void setDatabaseProvider(String databaseProvider) {
+ this.databaseProvider = databaseProvider;
+ }
+
+ public void setJdbcURL(String jdbcURL) {
+ this.jdbcURL = jdbcURL;
+ }
+
+ public String getJdbcUser() {
+ return jdbcUser;
+ }
+
+ public void setJdbcUser(String jdbcUser) {
+ this.jdbcUser = jdbcUser;
+ }
+
+ public void setSchemaName(String schemaName) {
+ this.schemaName = schemaName;
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleContext.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleContext.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleContext.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleContext.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,19 @@
+/*
+ * ESTEAM Software GmbH, 17.11.2007
+ */
+package org.apache.empire.struts2.websample.web;
+
+import java.sql.Connection;
+
+import org.apache.empire.struts2.websample.db.SampleDB;
+
+
+public interface SampleContext
+{
+ public SampleDB getDatabase();
+
+ public SampleUser getUser();
+
+ public Connection getConnection();
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleHtmlTagDictionary.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleHtmlTagDictionary.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleHtmlTagDictionary.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleHtmlTagDictionary.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,73 @@
+package org.apache.empire.struts2.websample.web;
+
+import org.apache.empire.struts2.html.DefaultHtmlTagDictionary;
+
+public class SampleHtmlTagDictionary extends DefaultHtmlTagDictionary
+{
+ // ------- Input Control -------
+
+ @Override
+ public boolean InputReadOnlyAsData()
+ {
+ return false; // Show Read Only Input as Data (not as disabled input)
+ }
+
+ @Override
+ public int InputMaxCharSize()
+ {
+ return 40; // Maximum horizontal size in characters
+ }
+
+ @Override
+ public String InputWrapperTag()
+ {
+ return "tr";
+ }
+
+ @Override
+ public String InputLabelTag()
+ {
+ return "td";
+ }
+
+ @Override
+ public String InputControlTag()
+ {
+ return "td";
+ }
+
+ // ------- Errors -------
+
+ @Override
+ public String ErrorItemEntryClass()
+ {
+ return "errorMessage";
+ }
+
+ @Override
+ public String ErrorActionEntryClass()
+ {
+ return "errorMessage";
+ }
+
+ @Override
+ public String ErrorEntryWrapperTag()
+ {
+ return "span";
+ }
+
+ // ------- Message -------
+
+ @Override
+ public String MessageTag()
+ {
+ return "div";
+ }
+
+ @Override
+ public String MessageClass()
+ {
+ return "actionMessage";
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleRequest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleRequest.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleRequest.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleRequest.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,100 @@
+package org.apache.empire.struts2.websample.web;
+
+import java.sql.Connection;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.struts2.web.EmpireStrutsDispatcher;
+import org.apache.empire.struts2.web.WebRequest;
+
+
+public class SampleRequest implements WebRequest
+{
+ // Logger
+ protected static Log log = LogFactory.getLog(SampleRequest.class);
+
+ private HttpServletRequest httpRequest;
+ private HttpServletResponse httpResponse;
+ private SampleSession session;
+ private Connection connection; // Connection for this request
+
+ public static SampleRequest getInstance()
+ {
+ return (SampleRequest)EmpireStrutsDispatcher.getCurrentRequest();
+ }
+
+ public boolean init(HttpServletRequest request, HttpServletResponse response, Object session)
+ {
+ this.httpRequest = request;
+ this.httpResponse = response;
+ // Set Internal objects
+ this.session = (SampleSession)session;
+ if (this.session==null)
+ { // Error
+ log.fatal("Internal Error: Session object is null");
+ return false;
+ }
+ // continue processing
+ return true;
+ }
+
+ public void exit(int exitCode)
+ {
+ // Cleanup
+ if (connection!=null)
+ { // Commit or rollback connection depending on the exit code
+ if (exitCode>=0)
+ { // 0 or positive exitCode indicates success
+ log.debug("Request ended sucessfully. Committing database changes.");
+ getApplication().getDatabase().commit(connection);
+ }
+ else
+ { // negative exitCode indicates an error
+ log.warn("Request ended with errors. Database changes will be rolled back.");
+ getApplication().getDatabase().rollback(connection);
+ }
+ // Release Connection
+ getApplication().releaseConnection(connection);
+ connection= null;
+ }
+ // Release objects
+ this.httpRequest = null;
+ this.httpResponse = null;
+ }
+
+ // Get Session
+ public SampleSession getSession()
+ {
+ return session;
+ }
+
+ // Get Application
+ public SampleApplication getApplication()
+ {
+ return session.getApplication();
+ }
+
+ // Get Connection
+ public Connection getConnection()
+ {
+ // Get a Connection for the Connection Pool
+ if (connection==null)
+ connection= getApplication().getPooledConnection();
+ // return connection
+ return connection;
+ }
+
+ public HttpServletRequest getHttpRequest()
+ {
+ return httpRequest;
+ }
+
+ public HttpServletResponse getHttpResponse()
+ {
+ return httpResponse;
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleSession.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleSession.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleSession.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleSession.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,69 @@
+package org.apache.empire.struts2.websample.web;
+
+import java.util.HashMap;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.struts2.web.WebSession;
+
+
+public class SampleSession implements WebSession
+{
+ // Logger
+ protected static Log log = LogFactory.getLog(SampleSession.class);
+
+ // Non-Static
+ private SampleApplication application = null;
+ public SampleUser user = null;
+ public HashMap<String, Object> objectMap = new HashMap<String, Object>();
+
+ // Init Session
+ public void init(HttpSession session, Object application)
+ {
+ this.application = (SampleApplication) application;
+ if (this.application==null)
+ {
+ throw new RuntimeException("Fatal: Application object is null!");
+ }
+ log.info("Session created ");
+ }
+
+ // Get Application
+ public SampleApplication getApplication()
+ {
+ return application;
+ }
+
+ public SampleUser getUser()
+ {
+ return user;
+ }
+
+ public void setUser(SampleUser user)
+ {
+ this.user = user;
+ }
+
+ public Object getObject(String name)
+ {
+ return objectMap.get(name);
+ }
+
+ public final Object getObject(Class objclass)
+ {
+ return getObject(objclass.getName());
+ }
+
+ public Object setObject(String name, Object obj)
+ {
+ return objectMap.put(name, obj);
+ }
+
+ public final Object setObject(Class objclass, Object obj)
+ {
+ return setObject(objclass.getName(), obj);
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleUser.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleUser.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleUser.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/SampleUser.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,23 @@
+package org.apache.empire.struts2.websample.web;
+
+public class SampleUser
+{
+ private String userId;
+ private String displayName;
+
+ public SampleUser(String userId, String displayName)
+ {
+ this.userId = userId;
+ this.displayName = displayName;
+ }
+
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+ public String getUserId()
+ {
+ return userId;
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/EmployeeDetailAction.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/EmployeeDetailAction.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/EmployeeDetailAction.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/EmployeeDetailAction.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,100 @@
+package org.apache.empire.struts2.websample.web.actions;
+
+import org.apache.empire.db.DBRecord;
+import org.apache.empire.db.DBTable;
+import org.apache.empire.struts2.actionsupport.RecordActionSupport;
+import org.apache.empire.struts2.actionsupport.SessionPersistence;
+import org.apache.empire.struts2.websample.db.records.EmployeeRecord;
+import org.apache.empire.struts2.websample.web.actiontypes.DetailAction;
+import org.apache.struts2.interceptor.NoParameters;
+
+
+@SuppressWarnings("serial")
+/**
+ * EmployeeDetailAction
+ * <p>
+ * This class provides form processing functions for an Employee record.<br>
+ * The class uses a RecordActionSupport object which does most of the work.<br>
+ * For multi-record forms it is possible to have several RecordActionSupport members.<br>
+ * In this case each must be given a differnt property name however (see RecordActionSupport overloads).
+ * </p>
+ */
+public class EmployeeDetailAction extends DetailAction
+ implements NoParameters // set this to provide custom parameter handling
+{
+ /**
+ * Action mappings
+ */
+
+ protected RecordActionSupport recordSupport = null;
+
+ // ------- Action Construction -------
+
+ public EmployeeDetailAction() {
+ // Init Record Support Object
+ DBTable table = getDatabase().T_EMPLOYEES;
+ DBRecord record = new EmployeeRecord(this);
+ // create a support Object
+ recordSupport = new RecordActionSupport(this, table, record, SessionPersistence.Key);
+ }
+
+ // ------- Action Properties -------
+
+ public EmployeeRecord getEmployee()
+ {
+ return (EmployeeRecord) recordSupport.getRecord();
+ }
+
+ // ------- Action Methods -------
+
+ @Override
+ public String doCreate() {
+ // Create Record
+ if (!recordSupport.createRecord()) {
+ setActionError(recordSupport);
+ return RETURN;
+ }
+ // Done
+ return INPUT;
+ }
+
+ @Override
+ public String doLoad() {
+ // Load Record
+ if (!recordSupport.loadRecord()) {
+ setActionError(recordSupport);
+ return RETURN;
+ }
+ // Set Edit Mode
+ return INPUT;
+ }
+
+ @Override
+ public String doSave() {
+ // Load Form Data into record
+ if (!recordSupport.loadFormData()) {
+ if (recordSupport.hasError())
+ setActionError(recordSupport);
+ return INPUT;
+ }
+ // Now save the record
+ if (!recordSupport.saveChanges()) {
+ setActionError(recordSupport);
+ return INPUT;
+ }
+ // Erfolg
+ return RETURN;
+ }
+
+ @Override
+ public String doDelete() {
+ // Delete Record
+ if (!recordSupport.deleteRecord()) {
+ setActionError(recordSupport);
+ return INPUT;
+ }
+ // Erfolg
+ return RETURN;
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/EmployeeListAction.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/EmployeeListAction.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/EmployeeListAction.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/EmployeeListAction.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,247 @@
+package org.apache.empire.struts2.websample.web.actions;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.empire.commons.Options;
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.db.DBColumnExpr;
+import org.apache.empire.db.DBCommand;
+import org.apache.empire.db.DBReader;
+import org.apache.empire.struts2.actionsupport.BeanListActionSupport;
+import org.apache.empire.struts2.actionsupport.ReaderListActionSupport;
+import org.apache.empire.struts2.websample.db.SampleDB;
+import org.apache.empire.struts2.websample.web.actiontypes.Action;
+
+
+@SuppressWarnings("serial")
+/**
+ * EmployeeListAction
+ * <p>
+ * This class provides form functions for searching and displaying a list of employees.
+ * This implementation shows two optional approaches for this.
+ * 1. Use a ReaderListActionSupport object to directly display database query results in the JSP.<br>
+ * This is most efficient, however it lacks some flexibility.<br>
+ * 2. Use a BeanListActionSupport object to obtain a list of JavaBean objects from the query.<br>
+ * From the JSP the data of the list will be accessed though their getter and setters.<br>
+ * While this is not a efficent as the Reader approach, it is more flexible since post processing
+ * of the query result is possbile.
+ * </p>
+ */
+public class EmployeeListAction extends Action
+{
+ /**
+ * Action mappings
+ */
+ public static final String SEARCH = "search";
+ public static final String LIST = "list";
+
+ // the search info
+ public static class SearchInfo
+ {
+ private Integer employeeId;
+ private String firstName;
+ private String lastName;
+ private Integer departmentId;
+
+ public Integer getEmployeeId()
+ {
+ return employeeId;
+ }
+ public void setEmployeeId(Integer employeeId)
+ {
+ this.employeeId = employeeId;
+ }
+ public Integer getDepartmentId()
+ {
+ return departmentId;
+ }
+ public void setDepartmentId(Integer departmentId)
+ {
+ this.departmentId = departmentId;
+ }
+ public String getFirstName()
+ {
+ return firstName;
+ }
+ public void setFirstName(String firstName)
+ {
+ this.firstName = firstName;
+ }
+ public String getLastName()
+ {
+ return lastName;
+ }
+ public void setLastName(String lastName)
+ {
+ this.lastName = lastName;
+ }
+ }
+
+ // the list result
+ public static class EmployeeInfo
+ {
+ private int employeeId;
+ private String name;
+ private String gender;
+ private Date dateOfBirth;
+ private String department;
+
+ public int getEmployeeId()
+ {
+ return employeeId;
+ }
+ public void setEmployeeId(int employeeId)
+ {
+ this.employeeId = employeeId;
+ }
+ public String getName()
+ {
+ return name;
+ }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+ public String getGender()
+ {
+ return gender;
+ }
+ public void setGender(String gender)
+ {
+ this.gender = gender;
+ }
+ public Date getDateOfBirth()
+ {
+ return dateOfBirth;
+ }
+ public void setDateOfBirth(Date dateOfBirth)
+ {
+ this.dateOfBirth = dateOfBirth;
+ }
+ public String getDepartment()
+ {
+ return department;
+ }
+ public void setDepartment(String department)
+ {
+ this.department = department;
+ }
+ }
+
+ private BeanListActionSupport<EmployeeInfo> employeeBeanList = null;
+ private ReaderListActionSupport employeeReader = null;
+ private Options departments;
+
+ public final DBColumnExpr C_FULL_NAME; // Expression for Lastname + Firstname
+ public final DBColumnExpr C_DEPARTMENT;
+
+ // ------- Action Construction -------
+
+ public EmployeeListAction()
+ {
+ SampleDB db = getDatabase();
+ C_FULL_NAME = db.T_EMPLOYEES.C_LASTNAME.append(", ").append(db.T_EMPLOYEES.C_FIRSTNAME).as("NAME");
+ C_DEPARTMENT = db.T_DEPARTMENTS.C_NAME.as("DEPARTMENT");
+
+ // Set Title (optional)
+ C_FULL_NAME .setTitle("!label.name");
+ C_DEPARTMENT.setTitle("!label.department");
+
+ employeeBeanList = new BeanListActionSupport<EmployeeInfo>(this, EmployeeInfo.class, "employees");
+ employeeReader = new ReaderListActionSupport(this, "reader");
+ }
+
+ // ------- Action Properties -------
+
+ public SearchInfo getSearchInfo()
+ {
+ return (SearchInfo)getActionBean(SearchInfo.class, true);
+ }
+
+ public Options getDepartments()
+ {
+ if (departments==null)
+ {
+ SampleDB db = getDatabase();
+ DBCommand cmd = db.createCommand();
+ cmd.select(db.T_DEPARTMENTS.C_DEPARTMENT_ID);
+ cmd.select(db.T_DEPARTMENTS.C_NAME);
+ cmd.orderBy(db.T_DEPARTMENTS.C_NAME);
+ departments = db.queryOptionList(cmd.getSelect(), getConnection());
+ }
+ return departments;
+ }
+
+ // -------- Employee Bean List --------
+
+ public List<EmployeeInfo> getEmployees()
+ {
+ return employeeBeanList.getList();
+ }
+
+ // -------- Employee Reader --------
+
+ public DBReader getReader()
+ { // read only once!
+ return employeeReader.getReader();
+ }
+
+ // -------- Action Methods --------
+
+ public String doInit()
+ {
+ return SEARCH;
+ }
+
+ public String doReset()
+ {
+ removeActionBean(SearchInfo.class);
+ return SEARCH;
+ }
+
+ public String doQuery()
+ {
+ // Reset list status
+ return doList();
+ }
+
+ public String doList()
+ {
+ SampleDB db = getDatabase();
+ SampleDB.Employees EMP = db.T_EMPLOYEES;
+ SampleDB.Departments DEP = db.T_DEPARTMENTS;
+
+ DBCommand cmd = db.createCommand();
+ cmd.select(EMP.C_EMPLOYEE_ID);
+ cmd.select(C_FULL_NAME, EMP.C_GENDER, EMP.C_DATE_OF_BIRTH);
+ cmd.select(C_DEPARTMENT);
+ cmd.join (DEP.C_DEPARTMENT_ID, EMP.C_DEPARTMENT_ID);
+
+ // Set filter constraints
+ SearchInfo si = getSearchInfo();
+ if (si.getDepartmentId()!=null)
+ cmd.where(EMP.C_DEPARTMENT_ID.is(si.getDepartmentId()));
+ if (StringUtils.isValid( si.getFirstName()) )
+ cmd.where(EMP.C_FIRSTNAME.likeUpper( si.getFirstName()+"%" )
+ .or(EMP.C_FIRSTNAME.is(null)));
+ if (StringUtils.isValid( si.getLastName()) )
+ cmd.where(EMP.C_LASTNAME.likeUpper( si.getLastName()+"%" ));
+
+ cmd.orderBy(EMP.C_LASTNAME);
+ cmd.orderBy(EMP.C_FIRSTNAME);
+
+ // Init BeanList
+ if (!employeeBeanList.initBeanList(cmd))
+ {
+ setActionError(employeeBeanList);
+ return LIST;
+ }
+
+ // Init Reader
+ employeeReader.initReader(cmd);
+
+ return LIST;
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/LoginAction.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/LoginAction.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/LoginAction.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actions/LoginAction.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,122 @@
+package org.apache.empire.struts2.websample.web.actions;
+
+import java.util.Map;
+
+import org.apache.empire.commons.Errors;
+import org.apache.empire.struts2.websample.web.SampleUser;
+import org.apache.empire.struts2.websample.web.actiontypes.Action;
+
+import com.opensymphony.xwork2.config.entities.Parameterizable;
+
+
+@SuppressWarnings("serial")
+public class LoginAction extends Action
+ implements Parameterizable // StaticParametersInterceptor
+{
+ // Login Targets
+ public static final String INPUT = "input";
+ public static final String SUCCESS = "success";
+
+ // LoginInfo
+ public class LoginInfo
+ {
+ private String name;
+ private String pwd;
+ public String getName()
+ {
+ return name;
+ }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+ public String getPwd()
+ {
+ return pwd;
+ }
+ public void setPwd(String pwd)
+ {
+ this.pwd = pwd;
+ }
+ }
+
+ // Login Action
+ public LoginAction()
+ {
+ // Constructor
+ }
+
+ // Login requried for this action
+ @Override
+ public boolean loginRequired()
+ {
+ return false;
+ }
+
+ // Login form bean
+ private LoginInfo loginInfo = new LoginInfo();
+ public LoginInfo getLoginInfo()
+ {
+ return loginInfo;
+ }
+
+ public String doInit()
+ {
+ SampleUser user = getUser();
+ if (user!=null)
+ loginInfo.setName(user.getUserId());
+ // Done
+ return INPUT;
+ }
+
+ public String doLogin()
+ {
+ String userID = loginInfo.getName();
+ String userName = userID;
+
+ if (userID==null || userID.length()==0)
+ {
+ setActionError(Errors.InvalidPassword);
+ return INPUT;
+ }
+
+ // Login
+ SampleUser user = new SampleUser(userID, userName);
+ getSession().setUser(user);
+ // Done
+ return SUCCESS;
+ }
+
+ public String doLogout()
+ {
+ getSession().setUser(null);
+ return INPUT;
+ }
+
+ public String doError()
+ {
+ log.info("An error as occurred");
+ return INPUT;
+ }
+
+ /*
+ * Implementation of Parameterizable
+ */
+
+ private Map<String, Object> actionConfigParams = null;
+
+ public void addParam(String name, Object value)
+ {
+ actionConfigParams.put(name, value);
+ }
+
+ public Map getParams()
+ {
+ return actionConfigParams;
+ }
+
+ public void setParams(Map<String, Object> actionConfigParams)
+ {
+ this.actionConfigParams = actionConfigParams;
+ }
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/Action.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/Action.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/Action.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/Action.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,83 @@
+package org.apache.empire.struts2.websample.web.actiontypes;
+
+import java.sql.Connection;
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.struts2.action.WebAction;
+import org.apache.empire.struts2.websample.db.SampleDB;
+import org.apache.empire.struts2.websample.web.SampleApplication;
+import org.apache.empire.struts2.websample.web.SampleContext;
+import org.apache.empire.struts2.websample.web.SampleRequest;
+import org.apache.empire.struts2.websample.web.SampleSession;
+import org.apache.empire.struts2.websample.web.SampleUser;
+
+
+@SuppressWarnings("serial")
+public abstract class Action extends WebAction
+ implements SampleContext
+{
+ // Logger
+ @SuppressWarnings("hiding")
+ protected static Log log = LogFactory.getLog(Action.class);
+
+ public Action()
+ {
+ // Constructor
+ }
+
+ // Login requried for this action
+ @Override
+ public boolean loginRequired()
+ {
+ return (getSession().getUser()==null);
+ }
+
+ @Override
+ public Locale getLocale()
+ {
+ /*
+ Locale loc = super.getLocale();
+ if (loc.equals(Locale.GERMAN))
+ return loc;
+ */
+ return Locale.ENGLISH;
+ }
+
+ // Request
+ public static SampleRequest getRequest()
+ {
+ return SampleRequest.getInstance();
+ }
+
+ // Application getters
+ public SampleApplication getApplication()
+ {
+ return getRequest().getApplication();
+ }
+
+ public SampleSession getSession()
+ {
+ return getRequest().getSession();
+ }
+
+ // ------ Sample Context Implementation ------
+
+ public SampleDB getDatabase()
+ {
+ return getApplication().getDatabase();
+ }
+
+ public SampleUser getUser()
+ {
+ return getSession().getUser();
+ }
+
+ @Override
+ public Connection getConnection()
+ {
+ return getRequest().getConnection();
+ }
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/BeanDetailAction.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/BeanDetailAction.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/BeanDetailAction.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/BeanDetailAction.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,203 @@
+package org.apache.empire.struts2.websample.web.actiontypes;
+
+import org.apache.empire.commons.Errors;
+import org.apache.empire.data.Record;
+import org.apache.empire.data.bean.BeanClass;
+import org.apache.empire.data.bean.BeanRecordProxy;
+import org.apache.empire.struts2.actionsupport.BeanActionSupport;
+import org.apache.empire.struts2.actionsupport.SessionPersistence;
+import org.apache.empire.struts2.web.WebErrors;
+
+import com.opensymphony.xwork2.interceptor.NoParameters;
+
+
+/**
+ * BeanDetailAction
+ * <p>
+ * This class allows using a JavaBean or Data Transfer Object (DTO) for form data processing.
+ * Metadata for the Beans should be provided using the BeanClass and BeanProperty classes.
+ * </p>
+ * @author Rainer
+ */
+public abstract class BeanDetailAction<T> extends DetailAction
+ implements NoParameters // set this to provide custom parameter handling
+{
+ protected final BeanActionSupport<T> beanSupport;
+
+ /**
+ * Constructs a BeanDetailAction from a BeanRecordProxy object
+ * @param record the BeanRecordProxy for the bean
+ * @param persistence persistence level
+ */
+ public BeanDetailAction(BeanRecordProxy<T> record, SessionPersistence persistence)
+ {
+ beanSupport = new BeanActionSupport<T>(this, record, persistence);
+ }
+
+ /**
+ * Constructs a BeanDetailAction from a BeanClass definition
+ * @param beanClass the bean class defining the bean's metadata
+ * @param persistence persistence level
+ */
+ public BeanDetailAction(BeanClass beanClass, SessionPersistence persistence)
+ {
+ beanSupport = new BeanActionSupport<T>(this, beanClass, persistence);
+ }
+
+ /**
+ * Returns the Record interface implmentation for the bean.
+ * @return the Record interface implmentation for the bean.
+ */
+ public Record getRecord()
+ {
+ return beanSupport.getRecord();
+ }
+
+ @Override
+ public String doCreate()
+ {
+ T bean = createBean();
+ if (bean==null)
+ { // Must have an action error set!
+ if (!hasActionError())
+ setActionError(Errors.ObjectNotValid, beanSupport.getRecordPropertyName());
+ return doCancel();
+ }
+ beanSupport.setData(bean);
+ return INPUT;
+ }
+
+ @Override
+ public String doLoad()
+ {
+ // Read Record
+ Object[] key = beanSupport.getActionParamKey();
+ if (key!=null)
+ { // Load the bean
+ T bean = loadBean(key);
+ if (bean==null)
+ { // Must have an action error set!
+ if (!hasActionError())
+ setActionError(Errors.ItemNotFound, beanSupport.getRecordKeyString());
+ return doCancel();
+ }
+ beanSupport.setData(bean);
+ }
+ // Check if record is valid
+ if (beanSupport.isValid()==false)
+ {
+ setActionError(WebErrors.InvalidFormData);
+ return doCancel();
+ }
+ // Test
+ return INPUT;
+ }
+
+ @Override
+ public String doDelete()
+ {
+ Object[] key = null;
+ if (beanSupport.hasActionKey(true))
+ {
+ if (beanSupport.getActionParamNewFlag()==false)
+ key = beanSupport.getActionParamKey();
+ }
+ else
+ { // Get the bean key
+ if (beanSupport.getRecord().isNew()==false)
+ key = beanSupport.getRecordKeyValues();
+ }
+ // Delete the bean
+ if (key!=null && deleteBean(key)==false)
+ { // An Error has occurred;
+ return doCancel();
+ }
+ // Clear Data
+ beanSupport.setData(null);
+ return RETURN;
+ }
+
+ @Override
+ public String doSave() {
+
+ // bean Support
+ if (beanSupport.isValid()==false)
+ { // Create new or reload existing item
+ T bean;
+ if (beanSupport.getActionParamNewFlag())
+ { // crate new Item
+ bean = createBean();
+ }
+ else
+ { // reload existing item
+ bean = loadBean(beanSupport.getActionParamKey());
+ }
+ if (bean==null)
+ { // Must have an action error set!
+ if (!hasActionError())
+ setActionError(Errors.ItemNotFound, beanSupport.getRecordKeyString());
+ return doCancel();
+ }
+ beanSupport.setData(bean);
+ }
+ else if (beanSupport.getRecord().isNew()==false)
+ { // Check whether we have the right key
+ if (!beanSupport.checkKey())
+ { // Record's don't match
+ setActionError(WebErrors.InvalidFormData);
+ return doCancel();
+ }
+ }
+ // LoadFormData
+ if (beanSupport.loadFormData()==false)
+ { // Error loading form data
+ return INPUT;
+ }
+
+ // Save the record
+ boolean isNew = beanSupport.getRecord().isNew();
+ if (saveBean(beanSupport.getData(), isNew)==false)
+ { // Error saving bean
+ return INPUT;
+ }
+
+ // Record has been saved successfully
+ // beanSupport.updateSessionKey();
+ beanSupport.setData(null);
+
+ return RETURN;
+ }
+
+ // ------- overridables -------
+
+ /**
+ * Returns the bean for the supplied object key.
+ * If an error occurs the fuction must set an action error and return null.
+ * @return the bean object
+ */
+ protected abstract T createBean();
+
+ /**
+ * Returns the bean for the supplied object key.
+ * If an error occurs the fuction must set an action error and return null.
+ * @param key the bean's key values
+ * @return the bean object
+ */
+ protected abstract T loadBean(Object[] key);
+
+ /**
+ * Saves a bean object
+ * @param bean
+ * @param isNew true the bean is a newly created object or false otherwise
+ * @return true if the bean has been stored sucessfully or false otherwise
+ */
+ protected abstract boolean saveBean(T bean, boolean isNew);
+
+ /**
+ * Deletes a bean object
+ * @param bean
+ * @return true if the bean has been stored sucessfully or false otherwise
+ */
+ protected abstract boolean deleteBean(Object[] key);
+
+}
Added: incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/DetailAction.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/DetailAction.java?rev=683201&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/DetailAction.java (added)
+++ incubator/empire-db/trunk/struts2-ext/DBWebSample/src/org/apache/empire/struts2/websample/web/actiontypes/DetailAction.java Wed Aug 6 02:42:05 2008
@@ -0,0 +1,32 @@
+package org.apache.empire.struts2.websample.web.actiontypes;
+
+
+public abstract class DetailAction extends Action
+{
+ /**
+ * Action mappings
+ */
+ public static final String INPUT = "input";
+ public static final String RETURN = "return";
+
+ // Detail Action
+ public DetailAction()
+ {
+ // Default constructor
+ }
+
+ public abstract String doCreate();
+
+ public abstract String doLoad();
+
+ public abstract String doSave();
+
+ public abstract String doDelete();
+
+ // Optional overridable
+ public String doCancel()
+ {
+ return RETURN;
+ }
+
+}