Author: mlusetti
Date: Fri Dec  9 08:06:09 2011
New Revision: 1212270

URL: http://svn.apache.org/viewvc?rev=1212270&view=rev
Log:
TAP5-1773 Add a new OverrideFieldFocus mixin which supersed and deprecate the 
old one FormFieldFocus

Added:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/OverrideFieldFocus.java
      - copied, changed from r1211021, 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormFieldFocus.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/OverrideFieldFocusDemo.tml
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/OverrideFieldFocusDemo.java
      - copied, changed from r1211021, 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/FormFieldFocusTest.groovy
Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormFieldFocus.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/FormFieldFocusTest.groovy
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormFieldFocus.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormFieldFocus.java?rev=1212270&r1=1212269&r2=1212270&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormFieldFocus.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormFieldFocus.java
 Fri Dec  9 08:06:09 2011
@@ -34,8 +34,10 @@ import org.slf4j.Logger;
  * This is meant to be used only with {@link 
org.apache.tapestry5.corelib.components.Form} component.
  *
  * @since 5.3
+ * @deprecated As of release 5.4, replaced by {@link 
org.apache.tapestry5.corelib.mixins.OverrideFieldFocus}
  * @tapestrydoc
  */
+@Deprecated
 public class FormFieldFocus
 {
     @Inject
@@ -61,9 +63,9 @@ public class FormFieldFocus
     @AfterRender
     void focusField()
     {
-        javascriptSupport.autofocus(FieldFocusPriority.OVERRIDE, 
focusField.getControlName());
+        javascriptSupport.autofocus(FieldFocusPriority.OVERRIDE, 
focusField.getClientId());
 
-        logger.trace("Focus OVERRIDE done on field {}", 
focusField.getControlName());
+        logger.trace("Focus OVERRIDE done on field {}", 
focusField.getClientId());
     }
 
 }

Copied: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/OverrideFieldFocus.java
 (from r1211021, 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormFieldFocus.java)
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/OverrideFieldFocus.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/OverrideFieldFocus.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormFieldFocus.java&r1=1211021&r2=1212270&rev=1212270&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/FormFieldFocus.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/OverrideFieldFocus.java
 Fri Dec  9 08:06:09 2011
@@ -15,7 +15,6 @@
 package org.apache.tapestry5.corelib.mixins;
 
 import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ClientElement;
 import org.apache.tapestry5.Field;
 import org.apache.tapestry5.FieldFocusPriority;
 import org.apache.tapestry5.annotations.AfterRender;
@@ -28,15 +27,14 @@ import org.apache.tapestry5.services.jav
 import org.slf4j.Logger;
 
 /**
- * A mixin that instruments the outer {@link 
org.apache.tapestry5.corelib.components.Form} on which
- * component the focus should be activated.
+ * A mixin that let a {@link org.apache.tapestry5.Field} gain focus.
  * <p/>
- * This is meant to be used only with {@link 
org.apache.tapestry5.corelib.components.Form} component.
+ * This supersede {@link org.apache.tapestry5.corelib.mixins.FormFieldFocus} 
in 5.4
  *
- * @since 5.3
+ * @since 5.4
  * @tapestrydoc
  */
-public class FormFieldFocus
+public class OverrideFieldFocus
 {
     @Inject
     private Logger logger;
@@ -45,14 +43,7 @@ public class FormFieldFocus
      * The outer Form
      */
     @InjectContainer
-    private Form form;
-
-    /**
-     * The {@link org.apache.tapestry5.Field} instance that will receive the 
focus within
-     * the {@link org.apache.tapestry5.corelib.components.Form}.
-     */
-    @Parameter(required = true, defaultPrefix = BindingConstants.COMPONENT, 
allowNull = false)
-    private Field focusField;
+    private Field container;
 
     @Environmental
     private JavaScriptSupport javascriptSupport;
@@ -61,9 +52,9 @@ public class FormFieldFocus
     @AfterRender
     void focusField()
     {
-        javascriptSupport.autofocus(FieldFocusPriority.OVERRIDE, 
focusField.getControlName());
+        javascriptSupport.autofocus(FieldFocusPriority.OVERRIDE, 
container.getClientId());
 
-        logger.trace("Focus OVERRIDE done on field {}", 
focusField.getControlName());
+        logger.trace("Focus OVERRIDE done on field {}", 
container.getClientId());
     }
 
 }

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/OverrideFieldFocusDemo.tml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/OverrideFieldFocusDemo.tml?rev=1212270&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/OverrideFieldFocusDemo.tml 
(added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/OverrideFieldFocusDemo.tml 
Fri Dec  9 08:06:09 2011
@@ -0,0 +1,14 @@
+<html t:type="Border" 
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"; 
xml:space="default">
+    <h1>Override Field Focus Demo</h1>
+
+    <t:form t:id="focusform" name="focusform">
+
+        <t:label for="requiredValue" />
+        <t:textfield t:id="requiredValue" t:validate="required"/>
+        <br/>
+        <t:label for="overrideFocus" />
+        <t:textfield t:id="overrideFocus" t:value="overrideFocusValue" 
t:mixins="overridefieldfocus" />
+
+    </t:form>
+
+</html>
\ No newline at end of file

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/FormFieldFocusTest.groovy
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/FormFieldFocusTest.groovy?rev=1212270&r1=1212269&r2=1212270&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/FormFieldFocusTest.groovy
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/FormFieldFocusTest.groovy
 Fri Dec  9 08:06:09 2011
@@ -19,14 +19,24 @@ import org.apache.tapestry5.integration.
 import org.testng.annotations.Test
 
 /**
- * Integration test to veryfiy {@link FormFieldFocusTest} mixin.
+ * Integration test to veryfiy {@link 
com.gargoylesoftware.htmlunit.javascript.host.FormField}
+ * and {@link org.apache.tapestry5.corelib.mixins.OverrideFieldfocus} mixin.
  */
 class FormFieldFocusTest extends TapestryCoreTestCase
 {
     @Test
     void form_field_focus_mixin()
     {
-        openLinks "FormFieldFocus Demo"
+        openLinks "FormFieldFocus (DEPRECATED) Demo"
+
+        assertEquals getEval("window.document.activeElement.value"), "But I 
got the focus!"
+
+    }
+
+    @Test
+    void override_field_focus_mixin()
+    {
+        openLinks "OverrideFieldFocus Demo"
 
         assertEquals getEval("window.document.activeElement.value"), "But I 
got the focus!"
 

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=1212270&r1=1212269&r2=1212270&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 Fri Dec  9 08:06:09 2011
@@ -508,9 +508,11 @@ public class Index
 
                     new Item("ExpressionInJsFunction", "Expressions in JS 
Functions Demo", "Expressions can be used inside javascript functions"),
 
-                    new Item("FormFieldFocusDemo", "FormFieldFocus Demo", 
"Setting the Form focus on a specific field"),
+                    new Item("FormFieldFocusDemo", "FormFieldFocus 
(DEPRECATED) Demo", "Setting the Form focus on a specific field"),
 
-                    new Item("FormFragmentExplicitVisibleBoundsDemo", "Form 
Fragment Explicit Visible Bounds Demo", "Check for form fragment parent 
visibility can be bounded to")
+                    new Item("FormFragmentExplicitVisibleBoundsDemo", "Form 
Fragment Explicit Visible Bounds Demo", "Check for form fragment parent 
visibility can be bounded to"),
+
+                    new Item("OverrideFieldFocusDemo", "OverrideFieldFocus 
Demo", "Setting the focus in a form to a specific field")
 
             );
 

Copied: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/OverrideFieldFocusDemo.java
 (from r1211021, 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/FormFieldFocusTest.groovy)
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/OverrideFieldFocusDemo.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/OverrideFieldFocusDemo.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/FormFieldFocusTest.groovy&r1=1211021&r2=1212270&rev=1212270&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/FormFieldFocusTest.groovy
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/OverrideFieldFocusDemo.java
 Fri Dec  9 08:06:09 2011
@@ -12,23 +12,24 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package org.apache.tapestry5.integration.app1.pages;
 
-package org.apache.tapestry5.integration.app1
+import org.apache.tapestry5.annotations.Property;
 
-import org.apache.tapestry5.integration.TapestryCoreTestCase
-import org.testng.annotations.Test
-
-/**
- * Integration test to veryfiy {@link FormFieldFocusTest} mixin.
- */
-class FormFieldFocusTest extends TapestryCoreTestCase
+public class OverrideFieldFocusDemo
 {
-    @Test
-    void form_field_focus_mixin()
-    {
-        openLinks "FormFieldFocus Demo"
+    @Property
+    private String requiredValue;
+
+    @Property
+    private String overrideFocusValue;
 
-        assertEquals getEval("window.document.activeElement.value"), "But I 
got the focus!"
 
+    void beginRender()
+    {
+        requiredValue = "I'm required";
+
+        overrideFocusValue = "But I got the focus!";
     }
+
 }


Reply via email to