From 265ee675748e6af11ba7749814ecd34cae26d509 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marko=20Gr=C3=B6nroos?= Date: Tue, 15 Jul 2008 16:45:09 +0000 Subject: [PATCH] Fixes #1949. svn changeset:5107/svn branch:trunk --- src/com/itmill/toolkit/ui/Form.java | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/com/itmill/toolkit/ui/Form.java b/src/com/itmill/toolkit/ui/Form.java index 10c20c893a..d47c21cda0 100644 --- a/src/com/itmill/toolkit/ui/Form.java +++ b/src/com/itmill/toolkit/ui/Form.java @@ -116,6 +116,11 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, private Layout formFooter; + /** + * If this is true, commit implicitly calls setValidationVisible(true). + */ + private boolean validationVisibleOnCommit = true; + /** * Contructs a new form with default layout. * @@ -217,6 +222,36 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, currentBufferedSourceException }); } + /** + * Controls the making validation visible implicitly on commit. + * + * Having commit() call setValidationVisible(true) implicitly is the default + * behaviour. You can disable the implicit setting by setting this property + * as false. + * + * It is useful, because you usually want to start with the form free of + * errors and only display them after the user clicks Ok. You can disable + * the implicit setting by setting this property as false. + * + * @param makeVisible + * If true (default), validation is made visible when commit() is + * called. If false, the visibility is left as it is. + */ + public void setValidationVisibleOnCommit(boolean makeVisible) { + validationVisibleOnCommit = makeVisible; + } + + /** + * Is validation made automatically visible on commit? + * + * See setValidationVisibleOnCommit(). + * + * @return true if validation is made automatically visible on commit. + */ + public boolean isValidationVisibleOnCommit() { + return validationVisibleOnCommit; + } + /* * Commit changes to the data source Don't add a JavaDoc comment here, we * use the default one from the interface. @@ -227,6 +262,8 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, // Only commit on valid state if so requested if (!isInvalidCommitted() && !isValid()) { + if (validationVisibleOnCommit) + setValidationVisible(true); return; } -- 2.39.5