You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2014/08/18 12:34:56 UTC
[1/2] git commit: TAP5-736 - TextField validate parameter allows Null,
but throws NPE
Repository: tapestry-5
Updated Branches:
refs/heads/master 93116c9f0 -> 875ca1c0b
TAP5-736 - TextField validate parameter allows Null, but throws NPE
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/c8bf6f97
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/c8bf6f97
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/c8bf6f97
Branch: refs/heads/master
Commit: c8bf6f9739d4ab541d02c7cd9a72689335d8d919
Parents: 93116c9
Author: fscheffer <ma...@felix-scheffer.de>
Authored: Fri Aug 15 00:10:48 2014 +0200
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Mon Aug 18 12:30:06 2014 +0200
----------------------------------------------------------------------
.../java/org/apache/tapestry5/corelib/base/AbstractTextField.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c8bf6f97/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java
index 12c1774..7e6b742 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java
@@ -67,7 +67,7 @@ public abstract class AbstractTextField extends AbstractField
* The object that will perform input validation (which occurs after translation). The validate binding prefix is
* generally used to provide this object in a declarative fashion.
*/
- @Parameter(defaultPrefix = BindingConstants.VALIDATE)
+ @Parameter(defaultPrefix = BindingConstants.VALIDATE, allowNull = false)
@SuppressWarnings("unchecked")
private FieldValidator<Object> validate;
[2/2] git commit: TAP5-736: add a test to ensure that null is not
accepted as a TextField's validate parameter
Posted by jk...@apache.org.
TAP5-736: add a test to ensure that null is not accepted as a TextField's validate parameter
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/875ca1c0
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/875ca1c0
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/875ca1c0
Branch: refs/heads/master
Commit: 875ca1c0bd8aff462715315ec668dd9e23c2560a
Parents: c8bf6f9
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Mon Aug 18 12:34:03 2014 +0200
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Mon Aug 18 12:34:03 2014 +0200
----------------------------------------------------------------------
.../app1/TextFieldWithNullValidateParameter.tml | 11 ++++++++++
.../tapestry5/integration/app1/FormTests.java | 11 ++++++++++
.../tapestry5/integration/app1/pages/Index.java | 4 +++-
.../TextFieldWithNullValidateParameter.java | 23 ++++++++++++++++++++
4 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml b/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml
new file mode 100644
index 0000000..21059d7
--- /dev/null
+++ b/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml
@@ -0,0 +1,11 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <t:form>
+ <t:errors/>
+
+ <t:textfield value="literal:foobar" validate="prop:nullvalidate"/>
+
+ </t:form>
+
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
index 58f252a..70f77e7 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
@@ -1219,4 +1219,15 @@ public class FormTests extends App1TestCase
assertEquals("text", getAttribute("emailValidator@type")); // if HTML5 support was enabled, this would be "email"
}
+ /** TAP5-736 **/
+ @Test
+ public void textfield_requires_non_null_validate_parameter() throws Exception
+ {
+ openLinks("TextField with null validate parameter");
+ if(isTextPresent("java.lang.NullPointerException")){
+ reportAndThrowAssertionError("Unexpected NullPointerException was thrown");
+ }
+ assertTextPresent("This parameter is not allowed to be null.");
+ }
+
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
index 42a4ffa..ae49e59 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
@@ -578,7 +578,9 @@ public class Index
new Item("FormFieldClientIdParameterDemo", "Form Field clientId Parameter Demo", "Shows and tests how to explicitly set the id of a form field component"),
- new Item("gridwithsubmitwithcontextdemo", "Grid with Submit with context", "A grid whose rows contain a Submit component with context")
+ new Item("gridwithsubmitwithcontextdemo", "Grid with Submit with context", "A grid whose rows contain a Submit component with context"),
+
+ new Item("textfieldwithnullvalidateparameter", "TextField with null validate parameter", "A TextField whose validate parameter is bound to null")
);
static
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java
new file mode 100644
index 0000000..e116497
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java
@@ -0,0 +1,23 @@
+// Copyright 2008 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.apache.tapestry5.integration.app1.pages;
+
+
+public class TextFieldWithNullValidateParameter {
+
+ public Object getNullValidate() {
+ return null;
+ }
+}
[2/2] git commit: TAP5-736: add a test to ensure that null is not
accepted as a TextField's validate parameter
Posted by jk...@apache.org.
TAP5-736: add a test to ensure that null is not accepted as a TextField's validate parameter
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/875ca1c0
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/875ca1c0
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/875ca1c0
Branch: refs/heads/master
Commit: 875ca1c0bd8aff462715315ec668dd9e23c2560a
Parents: c8bf6f9
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Mon Aug 18 12:34:03 2014 +0200
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Mon Aug 18 12:34:03 2014 +0200
----------------------------------------------------------------------
.../app1/TextFieldWithNullValidateParameter.tml | 11 ++++++++++
.../tapestry5/integration/app1/FormTests.java | 11 ++++++++++
.../tapestry5/integration/app1/pages/Index.java | 4 +++-
.../TextFieldWithNullValidateParameter.java | 23 ++++++++++++++++++++
4 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml b/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml
new file mode 100644
index 0000000..21059d7
--- /dev/null
+++ b/tapestry-core/src/test/app1/TextFieldWithNullValidateParameter.tml
@@ -0,0 +1,11 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <t:form>
+ <t:errors/>
+
+ <t:textfield value="literal:foobar" validate="prop:nullvalidate"/>
+
+ </t:form>
+
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
index 58f252a..70f77e7 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
@@ -1219,4 +1219,15 @@ public class FormTests extends App1TestCase
assertEquals("text", getAttribute("emailValidator@type")); // if HTML5 support was enabled, this would be "email"
}
+ /** TAP5-736 **/
+ @Test
+ public void textfield_requires_non_null_validate_parameter() throws Exception
+ {
+ openLinks("TextField with null validate parameter");
+ if(isTextPresent("java.lang.NullPointerException")){
+ reportAndThrowAssertionError("Unexpected NullPointerException was thrown");
+ }
+ assertTextPresent("This parameter is not allowed to be null.");
+ }
+
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
index 42a4ffa..ae49e59 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
@@ -578,7 +578,9 @@ public class Index
new Item("FormFieldClientIdParameterDemo", "Form Field clientId Parameter Demo", "Shows and tests how to explicitly set the id of a form field component"),
- new Item("gridwithsubmitwithcontextdemo", "Grid with Submit with context", "A grid whose rows contain a Submit component with context")
+ new Item("gridwithsubmitwithcontextdemo", "Grid with Submit with context", "A grid whose rows contain a Submit component with context"),
+
+ new Item("textfieldwithnullvalidateparameter", "TextField with null validate parameter", "A TextField whose validate parameter is bound to null")
);
static
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/875ca1c0/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java
new file mode 100644
index 0000000..e116497
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/TextFieldWithNullValidateParameter.java
@@ -0,0 +1,23 @@
+// Copyright 2008 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.apache.tapestry5.integration.app1.pages;
+
+
+public class TextFieldWithNullValidateParameter {
+
+ public Object getNullValidate() {
+ return null;
+ }
+}