You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2013/09/10 00:35:08 UTC
git commit: Modify Errors component to omit duplicates
Updated Branches:
refs/heads/master 1ce11229e -> cfc7351b4
Modify Errors component to omit duplicates
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/cfc7351b
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/cfc7351b
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/cfc7351b
Branch: refs/heads/master
Commit: cfc7351b4c2b1ef5361dafa92e70646457f18ee5
Parents: 1ce1122
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Sep 9 15:35:03 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Mon Sep 9 15:35:03 2013 -0700
----------------------------------------------------------------------
.../tapestry5/corelib/components/Errors.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cfc7351b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Errors.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Errors.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Errors.java
index 5138fce..252262d 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Errors.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Errors.java
@@ -14,13 +14,16 @@
package org.apache.tapestry5.corelib.components;
+import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ValidationTracker;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import java.util.List;
+import java.util.Set;
/**
* Standard validation error presenter. Must be enclosed by a
@@ -44,10 +47,10 @@ public class Errors
private String banner;
/**
- * The CSS class for the div element rendered by the component. The default value is "alert alert-error alert-block".
+ * The CSS class for the div element rendered by the component.
*/
- @Parameter(name = "class")
- private String className = "alert alert-danger";
+ @Parameter(name = "class", defaultPrefix = BindingConstants.LITERAL, value = "alert alert-danger")
+ private String className;
// Allow null so we can generate a better error message if missing
@Environmental(false)
@@ -63,6 +66,9 @@ public class Errors
return;
}
+
+ Set<String> previousErrors = CollectionFactory.newSet();
+
writer.element("div", "class", "alert-dismissable " + className);
writer.element("button",
"type", "button",
@@ -81,9 +87,16 @@ public class Errors
for (String message : errors)
{
+ if (previousErrors.contains(message))
+ {
+ continue;
+ }
+
writer.element("li");
writer.write(message);
writer.end();
+
+ previousErrors.add(message);
}
writer.end(); // ul