[Jifty-commit] r1308 - in jifty/trunk: share/web/static/js share/web/templates/__jifty/webservices

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Jun 16 15:09:19 EDT 2006


Author: alexmv
Date: Fri Jun 16 15:09:18 2006
New Revision: 1308

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/share/web/static/js/jifty.js
   jifty/trunk/share/web/templates/__jifty/webservices/xml

Log:
 r13998 at zoq-fot-pik:  chmrr | 2006-06-16 15:09:09 -0400
  * Send arguments back to the client, so they know what the server
 rendered with.  This fixes bugs with the client not knowing the
 current defaults if they were due to argument mapping.


Modified: jifty/trunk/share/web/static/js/jifty.js
==============================================================================
--- jifty/trunk/share/web/static/js/jifty.js	(original)
+++ jifty/trunk/share/web/static/js/jifty.js	Fri Jun 16 15:09:18 2006
@@ -606,21 +606,39 @@
                      response_fragment = response_fragment.nextSibling) {
                     if (response_fragment.nodeName == 'fragment') {
                         if (response_fragment.getAttribute("id") == f['region']) {
-                            var textContent;
-                            if (response_fragment.textContent) {
-                                textContent = response_fragment.textContent;
-                            } else {
-                                textContent = response_fragment.firstChild.nodeValue;
+                            // We found the right fragment
+                            var dom_fragment = fragments[f['region']];
+                            var new_dom_args = $H();
+
+                            for (var fragment_bit = response_fragment.firstChild;
+                                 fragment_bit != null;
+                                 fragment_bit = fragment_bit.nextSibling) {
+                                if (fragment_bit.nodeName == 'argument') {
+                                    // First, update the fragment's arguments
+                                    // with what the server actually used --
+                                    // this is needed in case there was
+                                    // argument mapping going on
+                                    new_dom_args[fragment_bit.getAttribute("name")] = fragment_bit.textContent;
+                                } else if (fragment_bit.nodeName == 'content') {
+                                    var textContent;
+                                    if (fragment_bit.textContent) {
+                                        textContent = fragment_bit.textContent;
+                                    } else {
+                                        textContent = fragment_bit.firstChild.nodeValue;
+                                    }
+
+                                    // Once we find it, do the insertion
+                                    if (insertion) {
+                                        new insertion(element, textContent.stripScripts());
+                                    } else {
+                                        Element.update(element, textContent.stripScripts());
+                                    }
+                                    // We need to give the browser some "settle" time before we eval scripts in the body
+                                    setTimeout((function() { this.evalScripts() }).bind(textContent), 10);
+                                    Behaviour.apply(f['element']);
+                                }
                             }
-                            // Once we find it, do the insertion
-                            if (insertion) {
-                                new insertion(element, textContent.stripScripts());
-                            } else {
-                                Element.update(element, textContent.stripScripts());
-                            }
-                            // We need to give the browser some "settle" time before we eval scripts in the body
-                            setTimeout((function() { this.evalScripts() }).bind(textContent), 10);
-			    Behaviour.apply(f['element']);
+                            dom_fragment.setArgs(new_dom_args);
                         }
                     }
                 }

Modified: jifty/trunk/share/web/templates/__jifty/webservices/xml
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/webservices/xml	(original)
+++ jifty/trunk/share/web/templates/__jifty/webservices/xml	Fri Jun 16 15:09:18 2006
@@ -35,7 +35,9 @@
 
     # Stuff the rendered region into the XML
     $writer->startTag( "fragment", id => Jifty->web->current_region->qualified_name );
-    $writer->cdata( Jifty->web->current_region->as_string );
+    my %args = %{ Jifty->web->current_region->arguments };
+    $writer->dataElement( "argument", $args{$_}, name => $_) for sort keys %args;
+    $writer->cdataElement( "content", Jifty->web->current_region->as_string );
     $writer->endTag();
 
     Jifty->web->current_region->exit while Jifty->web->current_region;


More information about the Jifty-commit mailing list