You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2017/07/07 05:34:08 UTC
[08/10] struts-examples git commit: Fixed invalid update been saved:
using clones of Person in MemoryDay.
Fixed invalid update been saved: using clones of Person in MemoryDay.
Project: http://git-wip-us.apache.org/repos/asf/struts-examples/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-examples/commit/1ce1a4f5
Tree: http://git-wip-us.apache.org/repos/asf/struts-examples/tree/1ce1a4f5
Diff: http://git-wip-us.apache.org/repos/asf/struts-examples/diff/1ce1a4f5
Branch: refs/heads/master
Commit: 1ce1a4f5f938d6d6324fa712f010c309ba5fb248
Parents: 78becd7
Author: Antonio Sánchez <ad...@gmail.com>
Authored: Sun May 4 01:03:00 2014 +0200
Committer: Antonio Sánchez <ad...@gmail.com>
Committed: Sun May 4 01:03:00 2014 +0200
----------------------------------------------------------------------
.../java/org/apache/struts/crud/action/PersonAction.java | 9 +++------
.../java/org/apache/struts/crud/dao/MemoryPersonDao.java | 8 +++++++-
.../main/java/org/apache/struts/crud/model/Person.java | 9 ++++++++-
.../org/apache/struts/crud/action/PersonAction.properties | 10 +++++-----
4 files changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts-examples/blob/1ce1a4f5/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java b/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
index 2b7bd5f..044f057 100755
--- a/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
+++ b/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
@@ -12,17 +12,14 @@ import org.apache.struts.crud.service.PersonService;
/**
* Acts as a controller to handle actions related to editing a Person.
*
- * TODO display country name instead of code
* TODO logging
* TODO prepareInput
- * TODO I18e messages in validation.xml
* TODO use templates for patterns: X is required... Person... in properties file
- * TODO I18e all static text in jsps
*
- * SUBTASK I18e database text data
- * SUBTASK Definitely, improve 'country' data implementation
+ * SUBTASK Fully i18e application: database text data; static text in jsp; validation.xml; links for locales.
+ * SUBTASK Definitely, improve 'country' implementation
* SUBTASK add jetty and tomcat plugins to pom.xml
- * SUBTASK look & feel like that of showcase applications; enhance visualization
+ * SUBTASK look & feel like that of showcase applications; enhance visualization (style, css)
*
* @author bruce phillips
* @author antonio sánchez
http://git-wip-us.apache.org/repos/asf/struts-examples/blob/1ce1a4f5/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java b/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
index c1888bd..514db8d 100755
--- a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
+++ b/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
@@ -2,6 +2,8 @@ package org.apache.struts.crud.dao;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.struts.crud.model.Person;
/**
@@ -24,7 +26,11 @@ public class MemoryPersonDao implements PersonDao {
public Person getPerson(Integer id) {
for (Person p : persons) {
if (p.getPersonId().equals(id)) {
- return p;
+ try {
+ return (Person) p.clone();
+ } catch (CloneNotSupportedException ex) {
+ //TODO LOG Logger.getLogger(MemoryPersonDao.class.getName()).log(Level.SEVERE, null, ex);
+ }
}
}
return null;
http://git-wip-us.apache.org/repos/asf/struts-examples/blob/1ce1a4f5/crud/src/main/java/org/apache/struts/crud/model/Person.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/model/Person.java b/crud/src/main/java/org/apache/struts/crud/model/Person.java
index 8dd4a92..7dd2887 100755
--- a/crud/src/main/java/org/apache/struts/crud/model/Person.java
+++ b/crud/src/main/java/org/apache/struts/crud/model/Person.java
@@ -4,11 +4,13 @@ import java.util.Arrays;
/**
* Models a Person who registers.
+ *
+ * Person is Cloneable just an implemention technique for in-memory daos.
*
* @author bruce phillips
* @author antonio sanchez
*/
-public class Person {
+public class Person implements Cloneable {
private Integer personId;
private String firstName;
private String lastName;
@@ -118,6 +120,11 @@ public class Person {
public String getPhoneNumber() {
return phoneNumber;
}
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
@Override
public String toString() {
http://git-wip-us.apache.org/repos/asf/struts-examples/blob/1ce1a4f5/crud/src/main/resources/org/apache/struts/crud/action/PersonAction.properties
----------------------------------------------------------------------
diff --git a/crud/src/main/resources/org/apache/struts/crud/action/PersonAction.properties b/crud/src/main/resources/org/apache/struts/crud/action/PersonAction.properties
index 9215803..b6ed72c 100755
--- a/crud/src/main/resources/org/apache/struts/crud/action/PersonAction.properties
+++ b/crud/src/main/resources/org/apache/struts/crud/action/PersonAction.properties
@@ -21,8 +21,8 @@ button.label.submit=Submit
button.label.cancel=Cancel
##-- errors
-errors.prefix=<span style="color:red;font-weight:bold;">
-errors.suffix=</span>
-errors.general=An Error Has Occcured
-errors.required.firstname=Name is required.
-errors.required.lastname=Last name is required.
\ No newline at end of file
+#errors.prefix=<span style="color:red;font-weight:bold;">
+#errors.suffix=</span>
+#errors.general=An Error Has Occcured
+#errors.required.firstname=Name is required.
+#errors.required.lastname=Last name is required.
\ No newline at end of file