hlship 2005/08/23 16:21:21
Modified: framework/src/java/org/apache/tapestry/form Form.js
AbstractFormComponent.java Hidden.java
. status.xml
Log:
TAPESTRY-581: Tapestry attempts to invoke focus() on client-side objects that
don't implement it
Revision Changes Path
1.10 +2 -1
jakarta-tapestry/framework/src/java/org/apache/tapestry/form/Form.js
Index: Form.js
===================================================================
RCS file:
/home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/form/Form.js,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Form.js 19 Aug 2005 13:28:16 -0000 1.9
+++ Form.js 23 Aug 2005 23:21:21 -0000 1.10
@@ -34,7 +34,8 @@
Tapestry.set_focus = function (field)
{
- field.focus();
+ if (field.focus)
+ field.focus();
if (field.select)
field.select();
1.12 +19 -3
jakarta-tapestry/framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
Index: AbstractFormComponent.java
===================================================================
RCS file:
/home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AbstractFormComponent.java 9 Aug 2005 21:35:52 -0000 1.11
+++ AbstractFormComponent.java 23 Aug 2005 23:21:21 -0000 1.12
@@ -41,6 +41,17 @@
public abstract void setName(String name);
/**
+ * Returns true if the corresponding field, on the client side, can
accept user focus (i.e.,
+ * implements the focus() method). Most components can take focus, but a
few ([EMAIL PROTECTED] Hidden})
+ * override this method to return false.
+ */
+
+ protected boolean getCanTakeFocus()
+ {
+ return true;
+ }
+
+ /**
* Should be connected to a parameter named "id" (annotations would be
helpful here!). For
* components w/o such a parameter, this will simply return null.
*/
@@ -69,7 +80,7 @@
if (rawId == null)
return;
- String id = cycle.getUniqueId(rawId);
+ String id =
cycle.getUniqueId(TapestryUtils.convertTapestryIdToNMToken(rawId));
// Store for later access by the FieldLabel (or JavaScript).
@@ -106,12 +117,17 @@
}
else if (!cycle.isRewinding())
{
- if (!isDisabled())
+ boolean canFocus = getCanTakeFocus();
+
+ if (canFocus && !isDisabled())
delegate.registerForFocus(this,
ValidationConstants.NORMAL_FIELD);
renderFormComponent(writer, cycle);
- if (delegate.isInError())
+ // Can't think of a component that can be in error and not take
focus,
+ // but whatever ...
+
+ if (canFocus && delegate.isInError())
delegate.registerForFocus(this,
ValidationConstants.ERROR_FIELD);
}
}
1.14 +9 -0
jakarta-tapestry/framework/src/java/org/apache/tapestry/form/Hidden.java
Index: Hidden.java
===================================================================
RCS file:
/home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/form/Hidden.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Hidden.java 10 Aug 2005 19:28:05 -0000 1.13
+++ Hidden.java 23 Aug 2005 23:21:21 -0000 1.14
@@ -32,6 +32,15 @@
public abstract class Hidden extends AbstractFormComponent
{
/**
+ * Returns false.
+ */
+
+ protected boolean getCanTakeFocus()
+ {
+ return false;
+ }
+
+ /**
* @see
org.apache.tapestry.form.AbstractFormComponent#renderFormComponent(org.apache.tapestry.IMarkupWriter,
* org.apache.tapestry.IRequestCycle)
*/
1.224 +1 -0 jakarta-tapestry/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/jakarta-tapestry/status.xml,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -r1.223 -r1.224
--- status.xml 23 Aug 2005 22:07:50 -0000 1.223
+++ status.xml 23 Aug 2005 23:21:21 -0000 1.224
@@ -74,6 +74,7 @@
<action type="fix" dev="HLS" fixes-bug="TAPESTRY-584">Form should have
an element id when rendered (same applies to various FormComponents as
well)</action>
<action type="fix" dev="HLS" fixes-bug="TAPESTRY-585">$ signs in
generated element names / ids are illegal in XHTML</action>
<action type="fix" dev="HLS" fixes-bug="TAPESTRY-579">E-mail validator
pattern doesn't take new TLDs into account</action>
+ <action type="fix" dev="HLS" fixes-bug="TAPESTRY-581">Tapestry
attempts to invoke focus() on client-side objects that don't implement
it</action>
</release>
<release version="4.0-beta-4" date="Aug 10 2005">
<action type="fix" dev="HLS">Add getComponent() method to
IComponent.</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]