You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by ta...@apache.org on 2012/06/17 04:34:32 UTC
git commit: TAP5-1938: JpaValueEncoder encodes transient value is
null instead of throwing an exception
Updated Branches:
refs/heads/5.3 55ba4e0dd -> be4b9afb8
TAP5-1938: JpaValueEncoder encodes transient value is null instead of throwing an exception
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/be4b9afb
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/be4b9afb
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/be4b9afb
Branch: refs/heads/5.3
Commit: be4b9afb89cd7d85c410e71e560cb8b353c46d75
Parents: 55ba4e0
Author: Taha Hafeez <ta...@gmail.com>
Authored: Sun Jun 17 07:43:50 2012 +0530
Committer: Taha Hafeez <ta...@gmail.com>
Committed: Sun Jun 17 07:43:50 2012 +0530
----------------------------------------------------------------------
.../tapestry5/internal/jpa/JpaValueEncoder.java | 7 +--
.../src/test/app1/EncodeTransientEntities.tml | 10 ++++
.../jpa/integration/app1/JpaIntegrationTest.java | 7 +++
.../app1/pages/EncodeTransientEntities.java | 34 +++++++++++++++
4 files changed, 54 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/be4b9afb/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/JpaValueEncoder.java
----------------------------------------------------------------------
diff --git a/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/JpaValueEncoder.java b/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/JpaValueEncoder.java
index 38f0b68..77dc455 100644
--- a/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/JpaValueEncoder.java
+++ b/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/JpaValueEncoder.java
@@ -70,10 +70,9 @@ public class JpaValueEncoder<E> implements ValueEncoder<E>
final Object id = propertyAdapter.get(value);
if (id == null)
- throw new IllegalStateException(
- String.format(
- "Entity %s has an %s property of null; this probably means that it has not been persisted yet.",
- value, idPropertyName));
+ {
+ return null;
+ }
return typeCoercer.coerce(id, String.class);
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/be4b9afb/tapestry-jpa/src/test/app1/EncodeTransientEntities.tml
----------------------------------------------------------------------
diff --git a/tapestry-jpa/src/test/app1/EncodeTransientEntities.tml b/tapestry-jpa/src/test/app1/EncodeTransientEntities.tml
new file mode 100644
index 0000000..011543a
--- /dev/null
+++ b/tapestry-jpa/src/test/app1/EncodeTransientEntities.tml
@@ -0,0 +1,10 @@
+<html xmlns:t='http://tapestry.apache.org/schema/tapestry_5_3.xsd'>
+ <body>
+
+ <form t:type='form' action=''>
+ <input t:type='textField' t:value='user.email'/>
+ <input type='button' id='doNothingButton' value='Do Nothing'/>
+ </form>
+
+ </body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/be4b9afb/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app1/JpaIntegrationTest.java
----------------------------------------------------------------------
diff --git a/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app1/JpaIntegrationTest.java b/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app1/JpaIntegrationTest.java
index bbc5355..d0d341f 100644
--- a/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app1/JpaIntegrationTest.java
+++ b/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app1/JpaIntegrationTest.java
@@ -39,6 +39,13 @@ public class JpaIntegrationTest extends SeleniumTestCase
}
@Test
+ public void valueencode_transient_entities() throws Exception {
+ open("/EncodeTransientEntities");
+
+ assertTrue(isElementPresent("doNothingButton"));
+ }
+
+ @Test
public void persist_entities()
{
open("/persistentity");
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/be4b9afb/tapestry-jpa/src/test/java/org/example/app1/pages/EncodeTransientEntities.java
----------------------------------------------------------------------
diff --git a/tapestry-jpa/src/test/java/org/example/app1/pages/EncodeTransientEntities.java b/tapestry-jpa/src/test/java/org/example/app1/pages/EncodeTransientEntities.java
new file mode 100644
index 0000000..5d6f369
--- /dev/null
+++ b/tapestry-jpa/src/test/java/org/example/app1/pages/EncodeTransientEntities.java
@@ -0,0 +1,34 @@
+// Copyright 2012 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.example.app1.pages;
+
+import org.apache.tapestry5.annotations.PageActivationContext;
+import org.apache.tapestry5.annotations.Property;
+import org.example.app1.entities.User;
+
+public class EncodeTransientEntities
+{
+ @PageActivationContext
+ @Property
+ private User user;
+
+ void onActivate()
+ {
+ if (user == null)
+ {
+ user = new User();
+ }
+ }
+
+}