You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/01/03 19:23:35 UTC

svn commit: r608587 - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry/corelib/base/ tapestry-core/src/main/java/org/apache/tapestry/corelib/components/ tapestry-core/src/test/app1/ tapestry-core/src/test/java/org/apache/ta...

Author: hlship
Date: Thu Jan  3 10:23:32 2008
New Revision: 608587

URL: http://svn.apache.org/viewvc?rev=608587&view=rev
Log:
TAPESTRY-1926: DateField disabling does not work

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DisabledFields.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DisabledFields.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/internal/services/system_doctype.xml
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry/upload/components/Upload.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java Thu Jan  3 10:23:32 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -48,10 +48,6 @@
      */
     @Parameter("false")
     private boolean _disabled;
-
-    @SuppressWarnings("unused")
-    @Mixin
-    private RenderDisabled _renderDisabled;
 
     @SuppressWarnings("unused")
     @Mixin

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java Thu Jan  3 10:23:32 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -15,10 +15,8 @@
 package org.apache.tapestry.corelib.base;
 
 import org.apache.tapestry.*;
-import org.apache.tapestry.annotations.AfterRender;
-import org.apache.tapestry.annotations.BeginRender;
-import org.apache.tapestry.annotations.Environmental;
-import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.annotations.*;
+import org.apache.tapestry.corelib.mixins.RenderDisabled;
 import org.apache.tapestry.ioc.annotations.Inject;
 import org.apache.tapestry.services.FieldValidationSupport;
 import org.apache.tapestry.services.FieldValidatorDefaultSource;
@@ -91,6 +89,10 @@
 
     @Inject
     private FieldValidationSupport _fieldValidationSupport;
+
+    @SuppressWarnings("unused")
+    @Mixin
+    private RenderDisabled _renderDisabled;
 
     /**
      * Computes a default value for the "translate" parameter using {@link TranslatorDefaultSource}.

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java Thu Jan  3 10:23:32 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -19,8 +19,10 @@
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.annotations.AfterRender;
 import org.apache.tapestry.annotations.BeginRender;
+import org.apache.tapestry.annotations.Mixin;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.corelib.base.AbstractField;
+import org.apache.tapestry.corelib.mixins.RenderDisabled;
 import org.apache.tapestry.ioc.annotations.Inject;
 import org.apache.tapestry.services.Request;
 
@@ -31,6 +33,10 @@
 {
     @Inject
     private Request _request;
+
+    @SuppressWarnings("unused")
+    @Mixin
+    private RenderDisabled _renderDisabled;
 
     /**
      * The value to be read or updated. If not bound, the Checkbox will attempt to edit a property

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java Thu Jan  3 10:23:32 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -151,6 +151,8 @@
 
                        "value", value);
 
+        writeDisabled(writer);
+
         _validate.render(writer);
 
         _resources.renderInformalParameters(writer);
@@ -167,6 +169,9 @@
 
                        "id", triggerId);
 
+        writeDisabled(writer);
+
+
         writer.element("img",
 
                        "src", _defaultIcon.toClientURL(),
@@ -188,6 +193,11 @@
         configure(setup);
 
         _support.addScript("Calendar.setup(%s);", setup);
+    }
+
+    private void writeDisabled(MarkupWriter writer)
+    {
+        if (isDisabled()) writer.attributes("disabled", "disabled");
     }
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java Thu Jan  3 10:23:32 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -17,8 +17,10 @@
 import org.apache.tapestry.*;
 import org.apache.tapestry.annotations.BeforeRenderTemplate;
 import org.apache.tapestry.annotations.Environmental;
+import org.apache.tapestry.annotations.Mixin;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.corelib.base.AbstractField;
+import org.apache.tapestry.corelib.mixins.RenderDisabled;
 import org.apache.tapestry.internal.util.SelectModelRenderer;
 import org.apache.tapestry.ioc.annotations.Inject;
 import org.apache.tapestry.services.*;
@@ -106,6 +108,10 @@
 
     @Inject
     private FieldValidationSupport _fieldValidationSupport;
+
+    @SuppressWarnings("unused")
+    @Mixin
+    private RenderDisabled _renderDisabled;
 
     @SuppressWarnings({"unchecked"})
     @Override

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java Thu Jan  3 10:23:32 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -17,8 +17,10 @@
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.annotations.Environmental;
+import org.apache.tapestry.annotations.Mixin;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.corelib.base.AbstractField;
+import org.apache.tapestry.corelib.mixins.RenderDisabled;
 import org.apache.tapestry.ioc.annotations.Inject;
 import org.apache.tapestry.services.FormSupport;
 import org.apache.tapestry.services.Heartbeat;
@@ -52,6 +54,10 @@
 
     @Inject
     private Request _request;
+
+    @SuppressWarnings("unused")
+    @Mixin
+    private RenderDisabled _renderDisabled;
 
     public Submit()
     {

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DisabledFields.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DisabledFields.tml?rev=608587&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DisabledFields.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DisabledFields.tml Thu Jan  3 10:23:32 2008
@@ -0,0 +1,42 @@
+<html t:type="Border"
+      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+
+    <h1>Disabled Fields Demo</h1>
+
+    <t:form>
+
+        <t:textfield t:id="textfield" value="stringValue" disabled="true"/>
+        <br/>
+        <t:passwordfield t:id="passwordfield" value="stringValue" disabled="true"/>
+        <br/>
+        <t:textarea t:id="textarea" value="stringValue" disabled="true"/>
+        <br/>
+        <t:checkbox t:id="checkbox" value="flag" disabled="true"/>
+        <br/>
+        <t:select t:id="select" value="stringValue" disabled="true" model="literal:Up,Down,Strange,Charm,Bottom,Top"/>
+        <br/>
+        <t:radiogroup t:id="group1" value="stringValue" disabled="true">
+            <t:radio t:id="radio1" value="literal:Right"/>
+        </t:radiogroup>
+
+        <br/>
+
+        <t:radiogroup t:id="group2" value="stringValue">
+            <t:radio t:id="radio2" disabled="true" value="literal:Left"/>
+        </t:radiogroup>
+
+        <br/>
+
+        <t:datefield t:id="datefield" value="date" disabled="true"/>
+
+        <br/>
+
+        <t:palette t:id="palette" selected="values" disabled="true" encoder="encoder"
+                   model="literal:Fred,Barney,Wilma,Betty"/>
+
+        <br/>
+
+        <t:submit t:id="submit" disabled="true"/>
+    </t:form>
+</html>
\ No newline at end of file

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml Thu Jan  3 10:23:32 2008
@@ -296,6 +296,12 @@
             -- Demo a component which inherits informal parameters from its container
         </li>
 
+        <li>
+            <t:pagelink page="disabledfields">Disabled Fields</t:pagelink>
+            -- Demonstrate a bunch of disabled fields, to verify that the RenderDisabled mixin works
+            and is being used properly
+        </li>
+
     </ul>
 
 </html>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Thu Jan  3 10:23:32 2008
@@ -1265,4 +1265,45 @@
         assertText("//span[@id='target']/@class", "inherit");
     }
 
+    @Test
+    public void disabled_fields() throws Exception
+    {
+        start("Disabled Fields");
+
+        String[] paths = new String[]{"//input[@id='textfield']",
+
+                                      "//input[@id='passwordfield']",
+
+                                      "//textarea[@id='textarea']",
+
+                                      "//input[@id='checkbox']",
+
+                                      "//select[@id='select']",
+
+                                      "//input[@id='radio1']",
+
+                                      "//input[@id='radio2']",
+
+                                      "//input[@id='datefield']",
+
+                                      "//button[@id='datefield:trigger']",
+
+                                      "//select[@id='palette:avail']",
+
+                                      "//button[@id='palette:select']",
+
+                                      "//button[@id='palette:deselect']",
+
+                                      "//select[@id='palette']",
+
+                                      "//input[@id='submit']"};
+
+        for (String path : paths)
+        {
+            String locator = String.format("%s/@disabled", path);
+
+            assertText(locator, "disabled");
+        }
+    }
+
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DisabledFields.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DisabledFields.java?rev=608587&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DisabledFields.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DisabledFields.java Thu Jan  3 10:23:32 2008
@@ -0,0 +1,77 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.integration.app1.pages;
+
+import org.apache.tapestry.ValueEncoder;
+import org.apache.tapestry.internal.services.StringValueEncoder;
+
+import java.util.Date;
+import java.util.List;
+
+public class DisabledFields
+{
+    private String _stringValue;
+
+    private boolean _flag;
+
+    private Date _date;
+
+    private List<String> _values;
+
+    public String getStringValue()
+    {
+        return _stringValue;
+    }
+
+    public void setStringValue(String stringValue)
+    {
+        _stringValue = stringValue;
+    }
+
+    public boolean isFlag()
+    {
+        return _flag;
+    }
+
+    public void setFlag(boolean flag)
+    {
+        _flag = flag;
+    }
+
+    public Date getDate()
+    {
+        return _date;
+    }
+
+    public void setDate(Date date)
+    {
+        _date = date;
+    }
+
+    public List<String> getValues()
+    {
+        return _values;
+    }
+
+    public void setValues(List<String> values)
+    {
+        _values = values;
+    }
+
+    public ValueEncoder getEncoder()
+    {
+        return new StringValueEncoder();
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/internal/services/system_doctype.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/internal/services/system_doctype.xml?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/internal/services/system_doctype.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/internal/services/system_doctype.xml Thu Jan  3 10:23:32 2008
@@ -1,5 +1,4 @@
-<!DOCTYPE foo SYSTEM "src/test/resources/org/apache/tapestry/internal/services/simple.dtd" >
-<!-- 
+<!--
    Copyright 2007, 2008 The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,5 +13,5 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-
-<foo>bar</foo>
\ No newline at end of file
+<!DOCTYPE foo SYSTEM "src/test/resources/org/apache/tapestry/internal/services/simple.dtd" >
+<foo>bar</foo>

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry/upload/components/Upload.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry/upload/components/Upload.java?rev=608587&r1=608586&r2=608587&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry/upload/components/Upload.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry/upload/components/Upload.java Thu Jan  3 10:23:32 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -16,8 +16,10 @@
 
 import org.apache.tapestry.*;
 import org.apache.tapestry.annotations.Environmental;
+import org.apache.tapestry.annotations.Mixin;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.corelib.base.AbstractField;
+import org.apache.tapestry.corelib.mixins.RenderDisabled;
 import org.apache.tapestry.ioc.annotations.Inject;
 import org.apache.tapestry.services.FieldValidationSupport;
 import org.apache.tapestry.services.FieldValidatorDefaultSource;
@@ -69,6 +71,10 @@
 
     @Inject
     private FieldValidationSupport _fieldValidationSupport;
+
+    @SuppressWarnings("unused")
+    @Mixin
+    private RenderDisabled _renderDisabled;
 
     /**
      * Computes a default value for the "validate" parameter using