empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1457758 - in /empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main: java/org/apache/empire/jsf2/websample/db/ java/org/apache/empire/jsf2/websample/db/records/ java/org/apache/empire/jsf2/websample/web/ java/org/apache/empire...
Date Mon, 18 Mar 2013 13:28:51 GMT
Author: doebele
Date: Mon Mar 18 13:28:50 2013
New Revision: 1457758

URL: http://svn.apache.org/r1457758
Log:
EMPIREDB-178
JSF2-example: improved employee detail form.

Modified:
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleDB.java
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/EmployeeRecord.java
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/pages/EmployeeListPage.java
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_de.properties
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_en.properties
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/css/content.css
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeDetailPage.xhtml
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeListPage.xhtml

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleDB.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleDB.java?rev=1457758&r1=1457757&r2=1457758&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleDB.java
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/SampleDB.java
Mon Mar 18 13:28:50 2013
@@ -66,11 +66,11 @@ public class SampleDB extends DBDatabase
         {
             super("DEPARTMENTS", db);
             // ID
-            DEPARTMENT_ID = addColumn("DEPARTMENT_ID", DataType.AUTOINC, 0, DataMode.NotNull,
"DEP_ID_SEQUENCE");
-            NAME = addColumn("NAME", DataType.TEXT, 80, DataMode.NotNull);
-            HEAD = addColumn("HEAD", DataType.TEXT, 80, DataMode.Nullable);
-            BUSINESS_UNIT = addColumn("BUSINESS_UNIT", DataType.TEXT, 4, DataMode.NotNull,
"ITTK");
-            UPDATE_TIMESTAMP = addColumn("UPDATE_TIMESTAMP", DataType.DATETIME, 0, DataMode.NotNull);
+            DEPARTMENT_ID 	= addColumn("DEPARTMENT_ID", 	DataType.AUTOINC,	 0, DataMode.NotNull,
"DEP_ID_SEQUENCE");
+            NAME 			= addColumn("NAME", 			DataType.TEXT, 		80, DataMode.NotNull);
+            HEAD 			= addColumn("HEAD", 			DataType.TEXT, 		80, DataMode.Nullable);
+            BUSINESS_UNIT 	= addColumn("BUSINESS_UNIT", 	DataType.TEXT,		 4, DataMode.NotNull,
"ITTK");
+            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,	 0, DataMode.NotNull);
 
             // Primary Key
             setPrimaryKey(DEPARTMENT_ID);
@@ -93,7 +93,7 @@ public class SampleDB extends DBDatabase
 
         public final DBTableColumn EMPLOYEE_ID;
         public final DBTableColumn SALUTATION;
-//        public final DBTableColumn PICTURE;
+//      public final DBTableColumn PICTURE;
         public final DBTableColumn FIRST_NAME;
         public final DBTableColumn LAST_NAME;
         public final DBTableColumn DATE_OF_BIRTH;
@@ -107,18 +107,18 @@ public class SampleDB extends DBDatabase
         {
             super("EMPLOYEES", db);
             // ID
-            EMPLOYEE_ID = addColumn("EMPLOYEE_ID", DataType.AUTOINC, 0, DataMode.NotNull,
"EMPLOYEE_ID_SEQUENCE");
-            SALUTATION = addColumn("SALUTATION", DataType.TEXT, 5, DataMode.Nullable);
-//            PICTURE = addColumn("PICTURE", DataType.BLOB, 0, DataMode.Nullable);
-            FIRST_NAME = addColumn("FIRST_NAME", DataType.TEXT, 40, DataMode.NotNull);
-            LAST_NAME = addColumn("LAST_NAME", DataType.TEXT, 40, DataMode.NotNull);
-            DATE_OF_BIRTH = addColumn("DATE_OF_BIRTH", DataType.DATE, 0, DataMode.Nullable);
-            DEPARTMENT_ID = addColumn("DEPARTMENT_ID", DataType.INTEGER, 0, DataMode.NotNull);
-            GENDER = addColumn("GENDER", DataType.TEXT, 1, DataMode.Nullable);
-            PHONE_NUMBER = addColumn("PHONE_NUMBER", DataType.TEXT, 40, DataMode.Nullable);
-            EMAIL = addColumn("EMAIL", DataType.TEXT, 80, DataMode.Nullable);
-            RETIRED = addColumn("RETIRED", DataType.BOOL, 0, DataMode.NotNull, false);
-            UPDATE_TIMESTAMP = addColumn("UPDATE_TIMESTAMP", DataType.DATETIME, 0, DataMode.NotNull);
+            EMPLOYEE_ID 	= addColumn("EMPLOYEE_ID", 		DataType.AUTOINC, 	 0, DataMode.NotNull,
"EMPLOYEE_ID_SEQUENCE");
+            SALUTATION 		= addColumn("SALUTATION", 		DataType.TEXT, 		 5, DataMode.Nullable);
+            FIRST_NAME 		= addColumn("FIRST_NAME", 		DataType.TEXT, 		40, DataMode.NotNull);
+            LAST_NAME 		= addColumn("LAST_NAME", 		DataType.TEXT, 		40, DataMode.NotNull);
+            DATE_OF_BIRTH 	= addColumn("DATE_OF_BIRTH", 	DataType.DATE,		 0, DataMode.Nullable);
+            DEPARTMENT_ID 	= addColumn("DEPARTMENT_ID", 	DataType.INTEGER, 	 0, DataMode.NotNull);
+            GENDER 			= addColumn("GENDER", 			DataType.TEXT, 		 1, DataMode.Nullable);
+            PHONE_NUMBER 	= addColumn("PHONE_NUMBER", 	DataType.TEXT, 		40, DataMode.Nullable);
+            EMAIL 			= addColumn("EMAIL", 			DataType.TEXT, 		80, DataMode.Nullable);
+            RETIRED			= addColumn("RETIRED", 			DataType.BOOL, 		 0, DataMode.NotNull, false);
+            // PICTURE 		= addColumn("PICTURE", 			DataType.BLOB, 		 0, DataMode.Nullable);
+            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,	 0, DataMode.NotNull);
 
             // Primary Key
             setPrimaryKey(EMPLOYEE_ID);
@@ -135,17 +135,20 @@ public class SampleDB extends DBDatabase
             GENDER.setOptions(genders);
             GENDER.setControlType("select");
 
-            Options retireds = new Options();
-            retireds.set("N", "!option.employee.retired.true");
-            retireds.set("F", "!option.employee.retired.false");
-            RETIRED.setOptions(retireds);
+            Options retired = new Options();
+            retired.set(false, "!option.employee.active");
+            retired.set(true,  "!option.employee.retired");
+            RETIRED.setOptions(retired);
             RETIRED.setControlType("checkbox");
             
             // Set special control types
             DEPARTMENT_ID.setControlType("select");
-            PHONE_NUMBER.setControlType("phone");
+            PHONE_NUMBER .setControlType("phone");
             
-//            PICTURE.setControlType("blob");
+            // Set optional formatting attributes
+            DATE_OF_BIRTH.setAttribute("format:date", "yyyy-MM-dd");
+            
+            // PICTURE.setControlType("blob");
 
         }
     }

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/EmployeeRecord.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/EmployeeRecord.java?rev=1457758&r1=1457757&r2=1457758&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/EmployeeRecord.java
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/db/records/EmployeeRecord.java
Mon Mar 18 13:28:50 2013
@@ -19,6 +19,7 @@
 package org.apache.empire.jsf2.websample.db.records;
 
 import org.apache.empire.commons.Options;
+import org.apache.empire.data.Column;
 import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBCommand;
 import org.apache.empire.jsf2.websample.db.SampleDB;
@@ -33,6 +34,20 @@ public class EmployeeRecord extends Samp
     {
         super(db.T_EMPLOYEES);
     }
+    
+	/*
+	 * Add some business logic:
+	 * Make all fields read only if employee is retired (except the retired field itself!) 
+	 */
+    @Override
+    public boolean isFieldReadOnly(Column column)
+    {
+    	if (column!=T.RETIRED && getBoolean(T.RETIRED))
+    	{	/* Employee is retired */
+    		return true;
+    	}	
+    	return super.isFieldReadOnly(column);	
+    }
 
     @Override
     public Options getFieldOptions(DBColumn column)

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java?rev=1457758&r1=1457757&r2=1457758&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
Mon Mar 18 13:28:50 2013
@@ -225,14 +225,13 @@ public class SampleApplication extends F
 			sampleDB.open(driver, conn);
 		}
 		// Insert Sample Departments
+		insertDepartmentSampleRecord(conn, "Procurement", "ITTK");
 		int idDevDep = insertDepartmentSampleRecord(conn, "Development", "ITTK");
-		int idSalDep = insertDepartmentSampleRecord(conn, "Sales", "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);
+		insertEmployeeSampleRecord(conn, "Mr.", "Eugen", "Miller", "M",		idDevDep);
+		insertEmployeeSampleRecord(conn, "Mr.", "Max", "Mc. Callahan", "M",	idDevDep);
+		insertEmployeeSampleRecord(conn, "Mrs.", "Anna", "Smith", "F", 		idSalDep);
 		// Commit
 		sampleDB.commit(conn);
 	}

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/pages/EmployeeListPage.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/pages/EmployeeListPage.java?rev=1457758&r1=1457757&r2=1457758&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/pages/EmployeeListPage.java
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/pages/EmployeeListPage.java
Mon Mar 18 13:28:50 2013
@@ -60,6 +60,7 @@ public class EmployeeListPage extends Sa
         private String            gender;
         private Date              dateOfBirth;
         private String            department;
+        private boolean	 	      retired;
         private String            idParam;
 
         @Override
@@ -123,6 +124,14 @@ public class EmployeeListPage extends Sa
             this.department = department;
         }
 
+		public boolean isRetired() {
+			return retired;
+		}
+
+		public void setRetired(boolean retired) {
+			this.retired = retired;
+		}
+
     }
 
     public EmployeeListPage()
@@ -170,7 +179,8 @@ public class EmployeeListPage extends Sa
         DBCommand queryCmd = createQueryCommand();
 
         queryCmd.select(EMP.EMPLOYEE_ID, FULL_NAME);
-        queryCmd.select(EMP.GENDER, EMP.DATE_OF_BIRTH);
+        queryCmd.select(EMP.GENDER, EMP.DATE_OF_BIRTH, EMP.RETIRED);
+        // queryCmd.select(EMP.RETIRED.decode(true, "X", "-"));
         queryCmd.select(DEPARTMENT);
 
         queryCmd.join(DEP.DEPARTMENT_ID, EMP.DEPARTMENT_ID);

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_de.properties
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_de.properties?rev=1457758&r1=1457757&r2=1457758&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_de.properties
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_de.properties
Mon Mar 18 13:28:50 2013
@@ -31,8 +31,12 @@ field.title.departments.name=Abteilungsn
 field.title.departments.head=Abteilugnsleiter
 
 #options
-!option.employee.gender.male=Männlich
-!option.employee.gender.female=Weiblich
+option.employee.gender.male=Männlich
+option.employee.gender.female=Weiblich
+
+#options
+option.employee.active=-
+option.employee.retired=Ja
 
 #application
 application_title=Mitarbeiterverwaltungsanwendung

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_en.properties
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_en.properties?rev=1457758&r1=1457757&r2=1457758&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_en.properties
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/resources/lang/messages_en.properties
Mon Mar 18 13:28:50 2013
@@ -34,6 +34,10 @@ field.title.departments.head=Head of Dep
 option.employee.gender.male=Male
 option.employee.gender.female=Female
 
+#options
+option.employee.active=-
+option.employee.retired=Yes
+
 #application
 application_title = Employee Management Application
 application_todo = To do...

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/css/content.css
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/css/content.css?rev=1457758&r1=1457757&r2=1457758&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/css/content.css
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/css/content.css
Mon Mar 18 13:28:50 2013
@@ -29,10 +29,14 @@ table.inputForm {
 	width: 100%;
 }
 table.inputForm td.eCtlLabel {
-	font-weight: bold; 
-	white-space:nowrap; 
 	vertical-align:top;
 	width: 140px;
+	height: 24px;
+	padding-top: 3px;
+	font-weight: bold; 
+}
+table.inputForm td.eCtlInput {
+	vertical-align:top;
 }
 table.inputForm td.buttonBar {
 	padding-top: 8px;
@@ -80,3 +84,33 @@ span.searchResult {
 	color: brown;
 	font-weight: bold;
 }
+
+span.required {
+	color: brown;
+}
+select, 
+input[type=text],
+input[type=password] {
+	border: 1px #8f99ef solid;
+}
+select.eInpReq, 
+input[type=text].eInpReq {
+	border: 1px brown solid;
+}
+select.eInpDis, 
+input[type=text].eInpDis {
+	border: 1px #C0C0C0 solid;
+	color: #808080;
+}
+span.eInpDis {
+	display: inline-block;
+	padding-top: 3px;
+}
+.eUnit {
+	padding-left: 4px;
+	font-style: bold;
+}
+.eInputHint {
+	padding-left: 4px;
+	font-style: italic;
+}

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeDetailPage.xhtml
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeDetailPage.xhtml?rev=1457758&r1=1457757&r2=1457758&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeDetailPage.xhtml
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeDetailPage.xhtml
Mon Mar 18 13:28:50 2013
@@ -42,13 +42,13 @@
 					<tr><e:control column="#{db.EMPLOYEES.SALUTATION}" /></tr>
 					<tr><e:control column="#{db.EMPLOYEES.FIRST_NAME}" /></tr>
 					<tr><e:control column="#{db.EMPLOYEES.LAST_NAME}" /></tr>
-					<tr><e:control column="#{db.EMPLOYEES.DATE_OF_BIRTH}" /></tr>
+					<tr><e:control column="#{db.EMPLOYEES.DATE_OF_BIRTH}" hint="[yyyy-MM-dd]"/></tr>
 					<tr><e:control column="#{db.EMPLOYEES.DEPARTMENT_ID}" /></tr>
 					<tr><e:control column="#{db.EMPLOYEES.GENDER}"   /> </tr>
 					<tr><e:control column="#{db.EMPLOYEES.PHONE_NUMBER}" /></tr>
 					<tr><e:control column="#{db.EMPLOYEES.EMAIL}" /></tr>
 					<tr><e:control column="#{db.EMPLOYEES.RETIRED}" /></tr>
-					<tr><e:control column="#{db.EMPLOYEES.UPDATE_TIMESTAMP}" readonly="true" rendered="#{page.idParam
!= null}" /></tr> 
+					<tr><e:control column="#{db.EMPLOYEES.UPDATE_TIMESTAMP}" format="date-format:full"
readonly="true" rendered="#{page.idParam != null}" /></tr> 
 				</sample:formPanel>
 				<!-- button bar -->
 				<h:panelGroup styleClass="buttonBar" layout="block">

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeListPage.xhtml
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeListPage.xhtml?rev=1457758&r1=1457757&r2=1457758&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeListPage.xhtml
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/pages/employeeListPage.xhtml
Mon Mar 18 13:28:50 2013
@@ -89,6 +89,12 @@
 						</f:facet>
 						<e:value record="#{item}" column="#{db.EMPLOYEES.DATE_OF_BIRTH}" />
 					</h:column>
+					<h:column>
+						<f:facet name="header">
+							<e:title column="#{db.EMPLOYEES.RETIRED}" />
+						</f:facet>
+						<e:value record="#{item}" column="#{db.EMPLOYEES.RETIRED}" />
+					</h:column>
 				</h:dataTable>
 			</h:panelGroup>
 		</h:form>



Mime
View raw message