Author: jkuhnert
Date: Sun Mar  4 08:16:35 2007
New Revision: 514427

URL: http://svn.apache.org/viewvc?view=rev&rev=514427
Log:
Fixes TAPESTRY-1312. Node attributes weren't properly being carried over during 
xhr requests. Added logic 
to properly detect all incoming attributes so everything is transferred now.

Added:
    
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Dates.java
Modified:
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Dates.html
    
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Dates.page
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/DatePicker.script
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Dates.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Dates.html?view=diff&rev=514427&r1=514426&r2=514427
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Dates.html 
(original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Dates.html 
Sun Mar  4 08:16:35 2007
@@ -11,7 +11,7 @@
 
 <span jwcid="showError"/>
 
-<form jwcid="@Form" delegate="bean:delegate" 
+<form jwcid="[EMAIL PROTECTED]" delegate="bean:delegate" 
                clientValidationEnabled="ognl:clientValidationEnabled" 
                async="true" updateComponents="dateDisplay" >
 

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Dates.page
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Dates.page?view=diff&rev=514427&r1=514426&r2=514427
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Dates.page
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Dates.page
 Sun Mar  4 08:16:35 2007
@@ -19,7 +19,7 @@
   "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
   "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd";>
 
-<page-specification>
+<page-specification class="org.apache.tapestry.workbench.Dates" >
        
   <bean name="delegate" 
class="org.apache.tapestry.workbench.WorkbenchValidationDelegate" 
property="delegate"/>
   

Added: 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Dates.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Dates.java?view=auto&rev=514427
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Dates.java
 (added)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/java/org/apache/tapestry/workbench/Dates.java
 Sun Mar  4 08:16:35 2007
@@ -0,0 +1,48 @@
+// Copyright 2004, 2005 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.workbench;
+
+import java.util.Date;
+
+import org.apache.tapestry.annotations.EventListener;
+import org.apache.tapestry.html.BasePage;
+import org.apache.tapestry.services.ResponseBuilder;
+import org.apache.tapestry.valid.IValidationDelegate;
+
+
+/**
+ * Sample page.
+ */
+public abstract class Dates extends BasePage
+{
+    public abstract ResponseBuilder getBuilder();
+    
+    public abstract void setEndDate(Date date);
+    
+    public abstract Date getStartDate();
+    
+    public abstract IValidationDelegate getDelegate();
+    
+    @EventListener(targets = "startDate", events = {"onchange"}, submitForm = 
"dateForm")
+    public void startChanged()
+    {
+        if (getStartDate() == null)
+            return;
+        
+        getDelegate().clearErrors();
+        
+        setEndDate(new Date(getStartDate().getTime() + (1000 * 60 * 60 * 24 * 
2)));
+        getBuilder().updateComponent("endDate");
+    }
+}

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/DatePicker.script
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/DatePicker.script?view=diff&rev=514427&r1=514426&r2=514427
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/DatePicker.script
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/DatePicker.script
 Sun Mar  4 08:16:35 2007
@@ -65,9 +65,8 @@
   var value = ${calendarObject}.formatDate();
        if (field.value != value) {
     field.value = value;
-    if (field.onchange) field.onchange();
+    if (field.onchange) { field.onchange();}
   }
 }
 </initialization>
 </script>
-

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?view=diff&rev=514427&r1=514426&r2=514427
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js 
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js Sun Mar 
 4 08:16:35 2007
@@ -26,7 +26,8 @@
        scriptInFlight:false, // whether or not javascript is currently being 
eval'd, default false
        ScriptFragment:'(?:<script.*?>)((\n|.|\r)*?)(?:<\/script>)', // regexp 
for script elements
     requestsInFlight:0, // how many ajax requests are currently in progress
-
+    isIE:dojo.render.html.ie,
+    
     /**
         * Function: bind
         * 
@@ -199,12 +200,12 @@
         * 
         */
        loadContent:function(id, node, element){
-       if (element.childNodes && element.childNodes.length > 0) {
+       if (typeof element.childNodes != "undefined" && 
element.childNodes.length > 0) {
                for (var i = 0; i < element.childNodes.length; i++) {
                if (element.childNodes[i].nodeType != 1) { continue; }
                                
                var nodeId = element.childNodes[i].getAttribute("id");
-               if (nodeId && nodeId) {
+               if (nodeId) {
                        element=element.childNodes[i];
                        break;
                }
@@ -213,23 +214,41 @@
        
        dojo.event.browser.clean(node); // prevent mem leaks in ie
        
+       var content=tapestry.html.getContentAsString(element);
        if (djConfig["isDebug"]) {
-               var content=tapestry.html.getContentAsString(element);
                dojo.log.debug("Received element content for id <" + id + "> 
of:", content);
+       }
+       if (content && content.length > 0) {
                node.innerHTML=content;
-       } else {
-               node.innerHTML=tapestry.html.getContentAsString(element);
        }
        
-       // copy style/class css attributes
-       var style=element.getAttribute("style");
-       if(style) {
-               dojo.html.setStyleText(node, style);
-       }
-       var classStr=element.getAttribute("class");
-       if (classStr) {
-               dojo.html.setClass(node, classStr);
-       }
+       // copy attributes
+               var atts=element.attributes;
+               var attnode, i=0;
+               while((attnode=atts[i++])){
+                       if(tapestry.isIE){
+                               if(!attnode){ continue; }
+                               if((typeof attnode == "object")&&
+                                       (typeof attnode.nodeValue == 
'undefined')||
+                                       (attnode.nodeValue == null)||
+                                       (attnode.nodeValue == '')){
+                                       continue;
+                               }
+                       }
+                       
+                       var nn = attnode.nodeName;
+                       var nv = attnode.nodeValue;
+                       if (nn == "id" || nn == "type" || nn == 
"name"){continue;}
+                       
+                       if (nn == "style") {
+                               dojo.html.setStyleText(node, nv);
+                       } else if (nn == "class") {
+                               dojo.html.setClass(node, nv);
+                       } else {
+                               node.setAttribute(nn, nv);
+                       }
+               }
+       
        // apply disabled/not disabled
        var disabled = element.getAttribute("disabled");
        if (!disabled && node["disabled"]) { 
@@ -421,12 +440,13 @@
         * 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" )
+               } else if (typeof XMLSerializer != "undefined" ) {
                        return this._getContentAsStringMozilla(node);
-               else
+               } else {
                        return this._getContentAsStringGeneric(node);
+               }
        },        
        
    /**


Reply via email to