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 2006/10/17 07:04:23 UTC
svn commit: r464808 - in /tapestry/tapestry4/trunk/tapestry-framework/src:
java/org/apache/tapestry/form/FormSupportImpl.java js/tapestry/form.js
test/org/apache/tapestry/form/FormSupportTest.java
Author: jkuhnert
Date: Mon Oct 16 22:04:22 2006
New Revision: 464808
URL: http://svn.apache.org/viewvc?view=rev&rev=464808
Log:
Fixed temporary retardation I was having in FormSupportImpl with a boolean expression checking for not null instead of null..
Added support into tapestry.form.focusField() to invoke a widget focus() function if the field being targeted
is a widget and has that function.
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java?view=diff&rev=464808&r1=464807&r2=464808
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java Mon Oct 16 22:04:22 2006
@@ -525,7 +525,7 @@
// Close the <form> tag.
_writer.end();
-
+
String fieldId = _delegate.getFocusField();
if (_pageRenderSupport == null)
@@ -535,7 +535,7 @@
// then do nothing.
if (fieldId != null && _form.getFocus()
- && _cycle.getAttribute(FIELD_FOCUS_ATTRIBUTE) != null) {
+ && _cycle.getAttribute(FIELD_FOCUS_ATTRIBUTE) == null) {
_pageRenderSupport.addInitializationScript(_form, "tapestry.form.focusField('" + fieldId + "');");
_cycle.setAttribute(FIELD_FOCUS_ATTRIBUTE, Boolean.TRUE);
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js?view=diff&rev=464808&r1=464807&r2=464808
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js Mon Oct 16 22:04:22 2006
@@ -31,10 +31,20 @@
focusField:function(field){
if (arguments.length < 1) return;
- field = dojo.byId(field);
- if (!field) return;
- if (field.disabled || field.clientWidth < 1) return;
-
+ field = dojo.widget.byId(field);
+ if(field && !dj_undef("focus", field)){
+ field.focus();
+ return;
+ } else {
+ field = dojo.byId(field);
+ }
+
+ if (!field) { return; }
+
+ if (field.disabled || field.clientWidth < 1) {
+ return;
+ }
+
dojo.html.selectInputText(field);
},
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java?view=diff&rev=464808&r1=464807&r2=464808
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java Mon Oct 16 22:04:22 2006
@@ -208,7 +208,10 @@
// effectively means someone else has already claimed focus
trainGetFieldFocus(cycle, null);
-
+
+ support.addInitializationScript(form, "tapestry.form.focusField('wilma');");
+ cycle.setAttribute(FormSupportImpl.FIELD_FOCUS_ATTRIBUTE, Boolean.TRUE);
+
replay();
fs.render("post", render, link, null, null);
@@ -1066,7 +1069,7 @@
// Side test: check for another form already grabbing focus
- trainGetFieldFocus(cycle, Boolean.TRUE);
+ trainGetFieldFocus(cycle, null);
support.addInitializationScript(form, "tapestry.form.focusField('barney');");
@@ -1216,16 +1219,16 @@
nested.close();
writer.end();
-
+
trainGetFocusField(delegate, "barney");
-
+
// Side test: check for another form already grabbing focus
-
+
trainGetFieldFocus(cycle, Boolean.TRUE);
- support.addInitializationScript(form, "tapestry.form.focusField('barney');");
+ // support.addInitializationScript(form, "tapestry.form.focusField('barney');");
- cycle.setAttribute(FormSupportImpl.FIELD_FOCUS_ATTRIBUTE, true);
+ // cycle.setAttribute(FormSupportImpl.FIELD_FOCUS_ATTRIBUTE, true);
replay();