You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2008/09/12 22:07:38 UTC
svn commit: r694793 - in
/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5:
SymbolConstants.java corelib/components/Form.java
services/TapestryModule.java
Author: hlship
Date: Fri Sep 12 13:07:37 2008
New Revision: 694793
URL: http://svn.apache.org/viewvc?rev=694793&view=rev
Log:
TAPESTRY-2646: There should be a global configuration that controls the default for Form's clientValidation and autofocus parameters
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java?rev=694793&r1=694792&r2=694793&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java Fri Sep 12 13:07:37 2008
@@ -80,8 +80,15 @@
public static final String CHARSET = "tapestry.charset";
/**
+ * Used as the default for the Form's autofocus and clientValidation parameters. If overridden to "false", then
+ * Forms will not (unless explicitly specified) use client validation or autofocus, which in turn, means that most
+ * pages with Forms will not make use of the Tapestry JavaScript stack.
+ */
+ public static final String FORM_CLIENT_LOGIC_ENABLED = "tapestry.form-client-logic-enabled";
+
+ /**
* Name of page used to report exceptions; the page must implement {@link org.apache.tapestry5.services.ExceptionReporter}.
* This is used by the default exception report handler service.
*/
- public static final String EXCEPTION_REPORT_PAGE = "ExceptionReport";
+ public static final String EXCEPTION_REPORT_PAGE = "tapestry.exception-report-page";
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java?rev=694793&r1=694792&r2=694793&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java Fri Sep 12 13:07:37 2008
@@ -29,6 +29,7 @@
import org.apache.tapestry5.ioc.Location;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import org.apache.tapestry5.ioc.internal.util.TapestryException;
import org.apache.tapestry5.ioc.util.ExceptionUtils;
@@ -121,14 +122,27 @@
@Parameter("defaultTracker")
private ValidationTracker tracker;
+ @Inject
+ @Symbol(SymbolConstants.FORM_CLIENT_LOGIC_ENABLED)
+ private boolean clientLogicDefaultEnabled;
+
/**
* If true (the default) then client validation is enabled for the form, and the default set of JavaScript libraries
* (Prototype, Scriptaculous and the Tapestry library) will be added to the rendered page, and the form will
* register itself for validation. This may be turned off when client validation is not desired; for example, when
* many validations are used that do not operate on the client side at all.
*/
- @Parameter("true")
- private boolean clientValidation;
+ @Parameter
+ private boolean clientValidation = clientLogicDefaultEnabled;
+
+ /**
+ * If true (the default), then the JavaScript will be added to position the cursor into the form. The field to
+ * receive focus is the first rendered field that is in error, or required, or present (in that order of priority).
+ *
+ * @see SymbolConstants#FORM_CLIENT_LOGIC_ENABLED
+ */
+ @Parameter
+ private boolean autofocus = clientLogicDefaultEnabled;
/**
* Binding the zone parameter will cause the form submission to be handled as an Ajax request that updates the
@@ -137,13 +151,6 @@
@Parameter(defaultPrefix = BindingConstants.LITERAL)
private String zone;
- /**
- * If true (the default), then the JavaScript will be added to position the cursor into the form. The field to
- * receive focus is the first rendered field that is in error, or required, or present (in that order of priority).
- */
- @Parameter
- private boolean autofocus = true;
-
@Inject
private Logger logger;
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=694793&r1=694792&r2=694793&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Fri Sep 12 13:07:37 2008
@@ -1818,6 +1818,8 @@
configuration.add(MetaDataConstants.SECURE_PAGE, "false");
+ configuration.add(SymbolConstants.FORM_CLIENT_LOGIC_ENABLED, "true");
+
// This is designed to make it easy to keep synchronized with script.aculo.ous. As we
// support a new version, we create a new folder, and update the path entry. We can then
// delete the old version folder (or keep it around). This should be more manageable than