Author: jkuhnert
Date: Tue Jan 15 08:05:33 2008
New Revision: 612143

URL: http://svn.apache.org/viewvc?rev=612143&view=rev
Log:
Fixes TAPESTRY-2023. 

core.js was clobbering ie dom listeners for single element nodes that wouldn't 
be re-created for ie as the properties would just be copied over for that 
special case.  

Also added getRenderError() to IFieldTracking so that when clearErrors is 
called it is able to know what to do in subclasses / special cases . (such as 
where css classes are appended to the class attribute for a node when in error 
or missing a value)

Modified:
    
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
    tapestry/tapestry4/trunk/tapestry-examples/pom.xml
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/GTimePicker.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/internal/event/impl/ComponentEventInvoker.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldTracking.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IFieldTracking.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js
    
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/Widget.js

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
 Tue Jan 15 08:05:33 2008
@@ -60,22 +60,27 @@
     @Component(bindings = {"value=date", 
             "displayName=message:task.start.date"})
     public abstract DropdownDatePicker getDatePicker();
+    
     public abstract Date getDate();
     
     @Component(bindings = {"value=startTime", 
"displayName=message:task.start.time",
             "validators=validators:required"})
     public abstract GTimePicker getStartPicker();
+    
     public abstract Date getStartTime();
     
     @Component(bindings = {"value=endTime", 
"displayName=message:task.end.time",
             "validators=validators:required,differ=startPicker"})
     public abstract GTimePicker getEndPicker();
+    
     public abstract Date getEndTime();
+    public abstract void setEndTime(Date time);
     
     @Component(bindings = { "value=description", 
             "displayName=message:task.description",
             "validators=validators:required,maxLength=20"})
     public abstract TextField getDescriptionField();
+    
     public abstract String getDescription();
     
     @InjectObject("service:timetracker.dao.TaskDao")
@@ -145,5 +150,15 @@
     public void showSubProject()
     {
         setShowSubProject(true);
+    }
+
+    @EventListener(targets = "startPicker", events = "onChange")
+    public void onChange()
+    {
+        if (getStartTime() != null) {
+            setEndTime(new Date(getStartTime().getTime() + (1000 * 60 * 60 * 
4)));
+        }
+        
+        getBuilder().updateComponent("endPicker");
     }
 }

Modified: tapestry/tapestry4/trunk/tapestry-examples/pom.xml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/pom.xml?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/pom.xml Tue Jan 15 08:05:33 2008
@@ -12,6 +12,7 @@
         <version>4.1.4-SNAPSHOT</version>
     </parent>
     <name>Examples</name>
+    <description>Tapestry example applications</description>
     <inceptionYear>2006</inceptionYear>
 
     <modules>

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/GTimePicker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/GTimePicker.java?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/GTimePicker.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/form/GTimePicker.java
 Tue Jan 15 08:05:33 2008
@@ -44,11 +44,8 @@
         renderDelegatePrefix(writer, cycle);
 
         writer.beginEmpty("input");
-
         writer.attribute("type", "text");
-        
         writer.attribute("autocomplete", "off");
-
         writer.attribute("name", getName());
 
         if (isDisabled())
@@ -58,7 +55,6 @@
             writer.attribute("value", value);
 
         renderIdAttribute(writer, cycle);
-
         renderDelegateAttributes(writer, cycle);
 
         getTranslatedFieldSupport().renderContributions(this, writer, cycle);
@@ -79,7 +75,6 @@
         cal.set(Calendar.AM_PM, Calendar.AM);
 
         StringBuffer optStr = new StringBuffer("[");
-
         int selectedIndex = -1;
         
         for(int i=0, hour=0; i < TIME_SEGMENT_LENGTH; i++)
@@ -172,4 +167,4 @@
     /** Injected. */
     public abstract ValidatableFieldSupport getValidatableFieldSupport();
 
-}
\ No newline at end of file
+}

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?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- 
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
 Tue Jan 15 08:05:33 2008
@@ -644,7 +644,7 @@
         }
 
         runDeferredRunnables();
-
+        
         if (_submitModes.contains(mode))
         {
             // clear errors during refresh

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/internal/event/impl/ComponentEventInvoker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/internal/event/impl/ComponentEventInvoker.java?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/internal/event/impl/ComponentEventInvoker.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/internal/event/impl/ComponentEventInvoker.java
 Tue Jan 15 08:05:33 2008
@@ -122,15 +122,15 @@
                 // defer execution until after form is done rewinding
 
                 form.addDeferredRunnable(
-                  new 
FormRunnable(target.getListeners().getListener(listeners[e].getMethodName()),
-                                   target,
-                                   cycle));
+                        new 
FormRunnable(target.getListeners().getListener(listeners[e].getMethodName()),
+                                         target,
+                                         cycle));
             }
         }
 
         // Form uses cycle attributes to test whether or not to focus .
         // The attribute existing at all is enough to bypass focusing.
-        
+
         if (disableFocus)
         {
             cycle.disableFocus();
@@ -160,7 +160,7 @@
                 target = 
findComponent(component.getPage().getComponents().values(), listener);
                 props = target.getSpecification().getComponentEvents(idPath);
             }
-            
+
             if (props == null)
                 continue;
 

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldTracking.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldTracking.java?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldTracking.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldTracking.java
 Tue Jan 15 08:05:33 2008
@@ -14,12 +14,12 @@
 
 package org.apache.tapestry.valid;
 
-import java.io.Serializable;
-
 import org.apache.hivemind.util.Defense;
 import org.apache.tapestry.IRender;
 import org.apache.tapestry.form.IFormComponent;
 
+import java.io.Serializable;
+
 /**
  * Default implementation of [EMAIL PROTECTED] IFieldTracking}.
  * 
@@ -42,6 +42,8 @@
 
     private ValidationConstraint _constraint;
 
+    private boolean _renderErrors = true;
+
     /**
      * Constructor used for unassociated errors; errors that are not about any
      * particular field within the form.
@@ -112,4 +114,13 @@
         return _renderer != null;
     }
 
+    public boolean getRenderError()
+    {
+        return _renderErrors;
+    }
+
+    public void setRenderError(boolean value)
+    {
+        _renderErrors = value;
+    }
 }

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IFieldTracking.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IFieldTracking.java?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IFieldTracking.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/IFieldTracking.java
 Tue Jan 15 08:05:33 2008
@@ -40,16 +40,37 @@
     /**
      * Returns true if the field is in error (that is, if it has an error
      * message [EMAIL PROTECTED] #getErrorRenderer() renderer}.
+     *
+     * @return Whether or not field is in error.
      */
 
     boolean isInError();
 
     /**
+     * Whether or not any errors found should cause field decoration / error
+     * renderers to render.   This is set to false on form submissions (such 
as a
+     * refresh submit) where validation shouldn't cause errors to be rendererd.
+     *
+     * @return Whether or not to render errors,  default is true.
+     */
+    boolean getRenderError();
+
+    /**
+     * Sets whether or not to render errors for this tracking.   Gets
+     * set to false on form refresh submits.
+     *
+     * @param value  Whether or not to render errors.
+     */
+    void setRenderError(boolean value);
+
+    /**
      * Returns the field component. This may return null if the error is not
      * associated with any particular field. Note: may return null after the
      * field tracking object is serialized and deserialized (the underlying
      * component reference is transient); this metehod is primarily used for
      * testing.
+     *
+     * @return The associated component,  or null if not specific to a 
component.
      */
 
     IFormComponent getComponent();
@@ -58,7 +79,8 @@
      * Returns an object that will render the error message. The renderer
      * <em>must</em> implement a simple <code>toString()</code> that does
      * not produce markup, but is a simple message.
-     * 
+     *
+     * @return The [EMAIL PROTECTED] IRender} responsible for rendering the 
error, or null if none is set.
      * @see ValidatorException#ValidatorException(String, IRender,
      *      ValidationConstraint)
      * @since 1.0.9
@@ -70,14 +92,17 @@
      * Returns the invalid input recorded for the field. This is stored so 
that,
      * on a subsequent render, the smae invalid input can be presented to the
      * client to be corrected.
+     *
+     * @return The original input value.
      */
-
     String getInput();
 
     /**
      * Returns the name of the field, that is, the name assigned by the form
      * (this will differ from the component's id when any kind of looping
      * operation is in effect).
+     *
+     * @return The name of the field within the form.
      */
 
     String getFieldName();
@@ -85,6 +110,8 @@
     /**
      * Returns the validation constraint that was violated by the input. This
      * may be null if the constraint isn't known.
+     *
+     * @return The associated [EMAIL PROTECTED] ValidationConstraint} that 
caused the field error.
      */
 
     ValidationConstraint getConstraint();

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
 Tue Jan 15 08:05:33 2008
@@ -71,6 +71,7 @@
         {
             FieldTracking ft = (FieldTracking) i.next();
             ft.setErrorRenderer(null);
+            ft.setRenderError(false);
         }
     }
 
@@ -322,7 +323,7 @@
             IFormComponent component, IValidator validator)
     {
         IFieldTracking tracking = getFieldTracking(component);
-        if (tracking == null)
+        if (tracking == null || !tracking.getRenderError())
             return;
 
         if (tracking.getConstraint() != null
@@ -345,7 +346,9 @@
     public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle,
             IFormComponent component, IValidator validator)
     {
-        if (isInError())
+        IFieldTracking tracking = getComponentTracking();
+        
+        if (tracking != null && tracking.isInError() && 
tracking.getRenderError())
         {
             writer.printRaw("&nbsp;");
             writer.begin("font");

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js 
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js Tue Jan 
15 08:05:33 2008
@@ -135,7 +135,7 @@
                        dojo.log.warn("No data received in response.");
                        return;
                }
-
+        
                var resp=data.getElementsByTagName("ajax-response");
                if (!resp || resp.length < 1 || !resp[0].childNodes) {
                        dojo.log.warn("No ajax-response elements received.");
@@ -195,8 +195,8 @@
                                continue;
                        }
 
-                       tapestry.loadContent(id, node, elms[i]);
-               }
+            tapestry.loadContent(id, node, elms[i]);
+        }
 
                // load body scripts before initialization
                for (var i=0; i<bodyScripts.length; i++) {
@@ -256,26 +256,30 @@
             }
         }
 
-       dojo.event.browser.clean(node); // prevent mem leaks in ie
-
        var content=tapestry.html.getContentAsString(element);
        if (djConfig["isDebug"]) {
                dojo.log.debug("Received element content for id <" + id + "> 
of: " + content);
        }
 
+        // on IE don't destroy event listeners on single element nodes like 
form input boxes/etc
+        if (!tapestry.isIE || (tapestry.isIE && node.childNodes && 
node.childNodes.length > 0)){
+            dojo.event.browser.clean(node); // prevent mem leaks in ie
+        }
+
         // fix for IE - setting innerHTML does not work for SELECTs
-        if (tapestry.isIE && node.outerHTML && node.nodeName == "SELECT") {
+        if (tapestry.isIE && !dj_undef("outerHTML", node) && node.nodeName == 
"SELECT") {
             node.outerHTML = 
node.outerHTML.replace(/(<SELECT[^<]*>).*(<\/SELECT>)/, '$1' + content + '$2');
             node=dojo.byId(id);
-        } else if (content && content.length > 0){
+        } else if (content && content.length > 0
+                && (!tapestry.isIE || content.length > 1)){
             node.innerHTML=content;
         }
-
+        
         // copy attributes
                var atts=element.attributes;
                var attnode, i=0;
                while((attnode=atts[i++])){
-                       if(tapestry.isIE){
+            if(tapestry.isIE){
                                if(!attnode){ continue; }
                                if((typeof attnode == "object")&&
                                        (typeof attnode.nodeValue == 
'undefined')||
@@ -298,7 +302,7 @@
             } else {
                                node.setAttribute(nn, nv);
                        }
-               }
+        }
 
        // apply disabled/not disabled
        var disabled = element.getAttribute("disabled");
@@ -446,14 +450,14 @@
                dojo.event.disconnect(target, event, tapestry, funcName);
         }
        },
-        
+
        /**
         * Function: cleanConnectWidget
-         */        
+         */
        cleanConnectWidget:function(target, event, funcName){
-                tapestry.cleanConnect(dojo.widget.byId(target), event, 
funcName);        
-       },        
-        
+                tapestry.cleanConnect(dojo.widget.byId(target), event, 
funcName);
+       },
+
        /**
         * Function: connect
         *
@@ -468,7 +472,7 @@
                dojo.event.connect(target, event, tapestry, funcName);
         }
        },
-        
+
        /**
         * Function: connectBefore
         */
@@ -477,25 +481,25 @@
                if (!dj_undef(funcName, tapestry)){
                dojo.event.connect("before", target, event, tapestry, funcName);
         }
-       },        
-        
+       },
+
        /**
         * Function: connectWidget
         */
        connectWidget:function(target, event, funcName){
-                tapestry.connect(dojo.widget.byId(target), event, funcName);   
     
+                tapestry.connect(dojo.widget.byId(target), event, funcName);
        },
 
        /**
         * Function: byId
      */
     byId:dojo.byId,
-        
+
        /**
         * Function: raise
      */
     raise:dojo.raise,
-        
+
        /**
         * Function: addOnLoad
      */
@@ -557,7 +561,7 @@
         * The string representation of the given node's contents.
         */
        getContentAsString:function(node){
-               if (typeof node.xml != "undefined") {
+        if (typeof node.xml != "undefined") {
                        return this._getContentAsStringIE(node);
                } else if (typeof XMLSerializer != "undefined" ) {
                        return this._getContentAsStringMozilla(node);
@@ -599,15 +603,15 @@
                s += '</' + node.nodeName + '>';
                return s;
        },
-        
+
     /**
      * Adds togglers and js effects to the exception page.
      */
     enhanceExceptionPage:function(){
         // attach toggles + hide content
-        
+
         var elms=dojo.html.getElementsByClass('toggle');
-        
+
         if(elms && elms.length > 0){
             for(var i=0;i<elms.length;i++){
 
@@ -702,14 +706,14 @@
         *                              browser event it will be ignored.
         *      props - The existing property object to set the values on, if 
it doesn't
         *                              exist one will be created.
-        *  args  - The arguments from an method-call interception 
+        *  args  - The arguments from an method-call interception
         * Returns:
         *
         * The desired event properties bound to an object. Ie 
obj.target,obj.charCode, etc..
         */
        buildEventProperties:function(event, props, args){
                if (!props) props={};
-               
+
                if (dojo.event.browser.isEvent(event)) {
                        if(event["type"]) props.beventtype=event.type;
                        if(event["keys"]) props.beventkeys=event.keys;
@@ -723,11 +727,11 @@
                }
 
                props.methodArguments = dojo.json.serialize( args );
-               
+
                return props;
        },
-       
-       
+
+
 
        /**
         * Function: buildTargetProperties
@@ -773,7 +777,7 @@
     /**
     * Function: stopEvent
     */
-    stopEvent:dojo.event.browser.stopEvent        
+    stopEvent:dojo.event.browser.stopEvent
 }
 
 tapestry.lang = {

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?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js 
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js Tue Jan 
15 08:05:33 2008
@@ -499,7 +499,7 @@
        validateForm:function(form, props){
                if (typeof form == "undefined") {return false;}
                if (typeof props == "undefined") {return true;} // form exists 
but no profile? just submit I guess..
-               if (!props.validateForm) {return true;}
+        if (!props.validateForm) {return true;}
 
                try {
                        this.clearValidationDecorations(form, props);

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/TimePicker.js
 Tue Jan 15 08:05:33 2008
@@ -77,7 +77,7 @@
 
         dojo.body().appendChild(this.dropdownNode);
 
-        if(dojo.render.html.ie55||dojo.render.html.ie60){
+        if(dojo.render.html.ie55 || dojo.render.html.ie60){
             this.bgIframe = new dojo.html.BackgroundIframe();
             this.bgIframe.setZIndex(this.dropdownNode);
         }
@@ -202,7 +202,7 @@
     show: function() {
 
         if (tapestry.widget.currentTimePicker &&
-                tapestry.widget.currentTimePicker != this){
+                tapestry.widget.currentTimePicker.widgetId != this.widgetId){
             tapestry.widget.currentTimePicker.hide();
         }
 

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/Widget.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/Widget.js?rev=612143&r1=612142&r2=612143&view=diff
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/Widget.js 
(original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/widget/Widget.js 
Tue Jan 15 08:05:33 2008
@@ -72,9 +72,9 @@
        },
        
        setWidgetProperties: function(w, props){
-               if (!dj_undef("disabled",props) && props.disabled == true 
+               if (!dj_undef("disabled",props) && props.disabled
                        && dojo.lang.isFunction(w["disable"])){
                        w.disable();
                }
        }
-}
\ No newline at end of file
+}


Reply via email to