Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4EC69200CCC for ; Fri, 7 Jul 2017 07:34:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4D95D1683C3; Fri, 7 Jul 2017 05:34:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6FCF41683CA for ; Fri, 7 Jul 2017 07:34:05 +0200 (CEST) Received: (qmail 86884 invoked by uid 500); 7 Jul 2017 05:34:03 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 85974 invoked by uid 99); 7 Jul 2017 05:34:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Jul 2017 05:34:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4F9D7F2178; Fri, 7 Jul 2017 05:34:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: lukaszlenart@apache.org To: commits@struts.apache.org Date: Fri, 07 Jul 2017 05:34:08 -0000 Message-Id: In-Reply-To: <7c6cc5a052cf4b74bd0bad26da233e30@git.apache.org> References: <7c6cc5a052cf4b74bd0bad26da233e30@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/10] struts-examples git commit: Fixed invalid update been saved: using clones of Person in MemoryDay. archived-at: Fri, 07 Jul 2017 05:34:06 -0000 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 Authored: Sun May 4 01:03:00 2014 +0200 Committer: Antonio Sánchez 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= -errors.suffix= -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= +#errors.suffix= +#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