cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jer...@apache.org
Subject svn commit: r474260 - in /cocoon/trunk/blocks/cocoon-forms: cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/ cocoon-forms-sample/src/main/resources/COB-INF/flow/ cocoon-forms-sample/src/main/resources/COB-INF/forms/
Date Mon, 13 Nov 2006 11:34:38 GMT
Author: jeremy
Date: Mon Nov 13 03:34:36 2006
New Revision: 474260

URL: http://svn.apache.org/viewvc?view=rev&rev=474260
Log:
resolving some encoding and whitespace issues
forgot to make the upload sample use ajax !!

Modified:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsForm.js
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/common.js
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/upload_example.js
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/upload_template.xml

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsForm.js
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsForm.js?view=diff&rev=474260&r1=474259&r2=474260
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsForm.js
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsForm.js
Mon Nov 13 03:34:36 2006
@@ -1,4 +1,4 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -6,7 +6,7 @@
  * (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
+ *          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,
@@ -30,155 +30,154 @@
  */
 
 dojo.widget.defineWidget(
-	"cocoon.forms.CFormsForm",
-	dojo.widget.DomWidget,
-	{
-
-	// properties
-	widgetType: "CFormsForm",
-  isContainer: true,
+    "cocoon.forms.CFormsForm",
+    dojo.widget.DomWidget,
+    {
+
+    // properties
+    widgetType: "CFormsForm",
+    isContainer: true,
+        
+    // Widget definition
+    buildRendering: function(args, parserFragment, parentWidget) {
+        // Magical statement to get the dom node, stolen in DomWidget
+        this.domNode = parserFragment["dojo:"+this.widgetType.toLowerCase()].nodeRef;
+        this.id = this.domNode.getAttribute("id");
+        this.domNode.setAttribute("dojoWidgetId", this.widgetId);
+        dojo.event.connect("around", this.domNode, "onsubmit", this, "_browserSubmit");
+        dojo.event.connect(this.domNode, "onclick", this, "_grabClickTarget");
+    },
+
+    _grabClickTarget: function(event) {
+        // Keep targets of onclick so that we can know what input triggered the submit
+        // (the event in onsubmit() is the HTMLFormElement).
+        this.lastClickTarget = dojo.html.getEventTarget(event);
+    },
+
+    /** Connected to the forms 'onsubmit' event, called when the user clicks a submit input
*/
+    _browserSubmit: function(invocation) {
+        if (invocation.proceed() == false) {
+            // onsubmit handlers stopped submission
+            return false;
+        }
+        var event = invocation.args[0] || window.event;
+        // Interestingly, FF provides the explicitOriginalTarget property that can avoid
+        // grabClickTarget above, but avoid browser specifics for now.
+        var target = /*event.explicitOriginalTarget ||*/ this.lastClickTarget;
+        this.submit(target && target.name);
+        // If real submit has to occur, it's taken care of in submit()
+        return false;
+    },
+
+    /**
+     * Submit the form, choosing the right transport depending on the widgets in the form.
+     *
+     * @param name the name of the widget that triggered the submit (if any)
+     * @param params an object containing additional parameters to be added to the
+     *              query string (optional)
+     */
+    submit: function(name, params) {
+        var form = this.domNode;                                    /* the form node */
+        var thisWidget = this;                                      /* closure magic for
the callback handler */
+        var mimetype = "text/xml";                              /* the default mime-type
*/
+        if (!params) params = {};                                   /* create if not passed
*/
+        
+        // Provide feedback that something is happening.
+        document.body.style.cursor = "wait";
+        
+        // The "ajax-action" attribute specifies an alternate submit location used in Ajax
mode.
+        // This allows to use Ajax in the portal where forms are normally posted to the portal
URL.
+        var uri = form.getAttribute("ajax-action");
+        if (!uri) uri = form.action;
+        if (uri == "") uri = document.location;
+
+        form["forms_submit_id"].value = name;           /* name of the button doing the submit
*/
+        params["cocoon-ajax"] = true;                           /* tell Cocoon we want AJAX-style
browser updates */
+        if (dojo.io.formHasFile(form)) {                    /* check for file-upload fields
*/
+            if (dojo.render.html.safari) {                  /* poor old safari, hopefully
Apple will fix this soon, it works in the nightly builds of WebKit (2006-10-11) */
+                form.submit();                                              /* do a full-page
submit */
+                return;
+            }
+            dojo.require("dojo.io.IframeIO");               /* using IframeIO as we have
file-upload fields */
+            mimetype = "text/html";                                 /* a different mime-type
is required for IframeIO */
+        }
+
+        dojo.io.bind({
+            url: uri,
+            handle: function(type, data, evt) { thisWidget._handleBrowserUpdate(thisWidget,
name, type, data, evt) },
+            method: "post",
+            mimetype: mimetype,                                         /* the mimetype of
the response */
+            content: params,                                                /* add extra
params to the form */
+            formNode: form,                                                 /* the form */
+            sendTransport: true                                         /* tell cocoon what
transport we are using */
+        });
+        // Toggle the click target off, so it does not get resubmitted if another submit
is fired before this has finished
+        // NB. This must be done after the form is assembled by dojo, or certain onChange
handlers may fail
+        // Avoid the use of widget.lastClickTarget as it may already be out of date
+        if (form[name]) form[name].disabled = true;
+    },
+        
+    /**
+     * Handle the server response
+     */
+    _handleBrowserUpdate: function(widget, name, type, data, evt) {     
+        // Restore normal cursor
+        document.body.style.cursor = "auto";
+        // Attempt to re-enable the click target
+        if (this.domNode[name]) this.domNode[name].disabled = false;
+        
+        var updater = new cocoon.ajax.BUHandler();
+        if (type == "load") {
+            // Handle browser update directives
+            if (!data) {
+                cocoon.ajax.BUHandler.handleError("No xml answer", evt);
+                return;
+            }
+            updater.handlers['continue'] = function() { widget._continue(); }
+            updater.processResponse(data, evt);
+        } else if (type == "error") {
+            updater.handleError("Request failed", evt);
+        } else {
+            // umm, how did we get here ?
+        }
+    },
     
-	// Widget definition
-	buildRendering: function(args, parserFragment, parentWidget) {
-		// Magical statement to get the dom node, stolen in DomWidget
-		this.domNode = parserFragment["dojo:"+this.widgetType.toLowerCase()].nodeRef;
-		this.id = this.domNode.getAttribute("id");
-		this.domNode.setAttribute("dojoWidgetId", this.widgetId);
-		dojo.event.connect("around", this.domNode, "onsubmit", this, "_browserSubmit");
-		dojo.event.connect(this.domNode, "onclick", this, "_grabClickTarget");
-	},
-
-	_grabClickTarget: function(event) {
-		// Keep targets of onclick so that we can know what input triggered the submit
-		// (the event in onsubmit() is the HTMLFormElement).
-		this.lastClickTarget = dojo.html.getEventTarget(event);
-	},
-
-	/** Connected to the forms 'onsubmit' event, called when the user clicks a submit input
*/
-	_browserSubmit: function(invocation) {
-		if (invocation.proceed() == false) {
-			// onsubmit handlers stopped submission
-			return false;
-		}
-		var event = invocation.args[0] || window.event;
-		// Interestingly, FF provides the explicitOriginalTarget property that can avoid
-		// grabClickTarget above, but avoid browser specifics for now.
-		var target = /*event.explicitOriginalTarget ||*/ this.lastClickTarget;
-		this.submit(target && target.name);
-		// If real submit has to occur, it's taken care of in submit()
-		return false;
-	},
-
-	/**
-	 * Submit the form, choosing the right transport depending on the widgets in the form.
-	 *
-	 * @param name the name of the widget that triggered the submit (if any)
-	 * @param params an object containing additional parameters to be added to the
-	 *        query string (optional)
-	 */
-	submit: function(name, params) {
-		var form = this.domNode;                  /* the form node */
-		var thisWidget = this;                    /* closure magic for the callback handler */
-		var mimetype = "text/xml";		            /* the default mime-type */
-		if (!params) params = {};                 /* create if not passed */
-		
-		// Provide feedback that something is happening.
-		document.body.style.cursor = "wait";
-		
-		// The "ajax-action" attribute specifies an alternate submit location used in Ajax mode.
-		// This allows to use Ajax in the portal where forms are normally posted to the portal
URL.
-		var uri = form.getAttribute("ajax-action");
-		if (!uri) uri = form.action;
-		if (uri == "") uri = document.location;
-
-		form["forms_submit_id"].value = name;     /* name of the button doing the submit */
-		params["cocoon-ajax"] = true;             /* tell Cocoon we want AJAX-style browser updates
*/
-		if (dojo.io.formHasFile(form)) {          /* check for file-upload fields */
-			if (dojo.render.html.safari) {          /* poor old safari, hopefully Apple will fix this
soon, it works in the nightly builds of WebKit (2006-10-11) */
-				form.submit();                        /* do a full-page submit */
-				return;
-			}
-			dojo.require("dojo.io.IframeIO");       /* using IframeIO as we have file-upload fields
*/
-			mimetype = "text/html";                 /* a different mime-type is required for IframeIO
*/
-		}
-
-		dojo.io.bind({
-			url: uri,
-			handle: function(type, data, evt) { thisWidget._handleBrowserUpdate(thisWidget, name,
type, data, evt) },
-			method: "post",
-			mimetype: mimetype,                     /* the mimetype of the response */
-			content: params,                        /* add extra params to the form */
-			formNode: form,                         /* the form */
-			sendTransport: true                     /* tell cocoon what transport we are using */
-		});
-		// Toggle the click target off, so it does not get resubmitted if another submit is fired
before this has finished
-		// NB. This must be done after the form is assembled by dojo, or certain onChange handlers
may fail
-		// Avoid the use of widget.lastClickTarget as it may already be out of date
-		if (form[name]) form[name].disabled = true;
-	},
-    
-	/**
-	 * Handle the server response
-	 */
-	_handleBrowserUpdate: function(widget, name, type, data, evt) {		
-		// Restore normal cursor
-		document.body.style.cursor = "auto";
-		// Attempt to re-enable the click target
-		if (this.domNode[name]) this.domNode[name].disabled = false;
-		
-		var updater = new cocoon.ajax.BUHandler();
-		if (type == "load") {
-			// Handle browser update directives
-			if (!data) {
-				cocoon.ajax.BUHandler.handleError("No xml answer", evt);
-				return;
-			}
-			updater.handlers['continue'] = function() { widget._continue(); }
-			updater.processResponse(data, evt);
-		} else if (type == "error") {
-			updater.handleError("Request failed", evt);
-		} else {
-			// umm, how did we get here ?
-		}
-	},
-	
-	_continue: function() {
-		//alert("_continue()");
-		var form = this.domNode;
-		if (form.method.toLowerCase() == "post") {
-			// Create a fake form and post it
-			var div = document.createElement("div");
-			var content = "<form action='" + form.action + "' method='POST'>" +
-								"<input type='hidden' name='cocoon-ajax-continue' value='true'/>";
-			if (form.elements["continuation-id"]) {
-				content += "<input type='hidden' name='continuation-id' value='" +
-						form.elements["continuation-id"].value + "'/>";
-			}
-			content += "</form>";
-			div.innerHTML = content;
-			document.body.appendChild(div);
-			div.firstChild.submit();
-		} else {	    
-			// Redirect to the form's action URL
-			var contParam = '?cocoon-ajax-continue=true';
-			if (form.elements["continuation-id"]) {
-				contParam += "&continuation-id=" + form.elements["continuation-id"].value;
-			}
-			window.location.href = form.action + contParam;
-		}
-	}
-	
+    _continue: function() {
+        //alert("_continue()");
+        var form = this.domNode;
+        if (form.method.toLowerCase() == "post") {
+            // Create a fake form and post it
+            var div = document.createElement("div");
+            var content = "<form action='" + form.action + "' method='POST'>" +
+                                "<input type='hidden' name='cocoon-ajax-continue' value='true'/>";
+            if (form.elements["continuation-id"]) {
+                content += "<input type='hidden' name='continuation-id' value='" +
+                        form.elements["continuation-id"].value + "'/>";
+            }
+            content += "</form>";
+            div.innerHTML = content;
+            document.body.appendChild(div);
+            div.firstChild.submit();
+        } else {            
+            // Redirect to the form's action URL
+            var contParam = '?cocoon-ajax-continue=true';
+            if (form.elements["continuation-id"]) {
+                contParam += "&continuation-id=" + form.elements["continuation-id"].value;
+            }
+            window.location.href = form.action + contParam;
+        }
+    }
 });
 
 // override built-in dojo function, we do not care about 'file' fields that are disabled
 dojo.io.checkChildrenForFile = function(node) {
-	var hasFile = false;
-	var inputs = node.getElementsByTagName("input");
-	dojo.lang.forEach(inputs, function(input){
-		if(hasFile){ return; }
-		if(input.getAttribute("type")=="file" && !input.disabled){
-			hasFile = true;
-		}
-	});
-	return hasFile;
+    var hasFile = false;
+    var inputs = node.getElementsByTagName("input");
+    dojo.lang.forEach(inputs, function(input){
+        if(hasFile){ return; }
+        if(input.getAttribute("type")=="file" && !input.disabled){
+            hasFile = true;
+        }
+    });
+    return hasFile;
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/common.js
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/common.js?view=diff&rev=474260&r1=474259&r2=474260
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/common.js
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/common.js
Mon Nov 13 03:34:36 2006
@@ -43,31 +43,31 @@
  * Submits a form. If ajax mode is on and the browser is ajax-aware, the page isn't reloaded
  */
 cocoon.forms.submitForm = function(element, name) {
-	var form = this.getForm(element);
-	if (form == null) {
-			alert("Cannot find form for " + element);
-			return;
-	}
+    var form = this.getForm(element);
+    if (form == null) {
+        alert("Cannot find form for " + element);
+        return;
+    }
 
-	if (!name) name = element.name;
+    if (!name) name = element.name;
 
-	var dojoId = form.getAttribute("dojoWidgetId");
-	if (dojoId) {
-		// Delegate to the CFormsForm widget
-		dojo.widget.byId(dojoId).submit(name);
-	} else {
-			// Regular submit. How old-fashioned :-)
-			
-			// Send the identifier of the widget that triggered the submit
-			form["forms_submit_id"].value = name;
+    var dojoId = form.getAttribute("dojoWidgetId");
+    if (dojoId) {
+        // Delegate to the CFormsForm widget
+        dojo.widget.byId(dojoId).submit(name);
+    } else {
+				// Regular submit. How old-fashioned :-)
+				
+				// Send the identifier of the widget that triggered the submit
+				form["forms_submit_id"].value = name;
 
-			// A form's onsubmit is only called when submit is triggered by user action, but not when
-			// called by a script. So don't forget to call it, cancelling the submit if (and only
if)
-			// it returns false
-		if (!form.onsubmit || form.onsubmit() != false) {
-				form.submit();
-		}
-	}
+				// A form's onsubmit is only called when submit is triggered by user action, but not
when
+				// called by a script. So don't forget to call it, cancelling the submit if (and only
if)
+				// it returns false
+        if (!form.onsubmit || form.onsubmit() != false) {
+            form.submit();
+        }
+    }
 }
 
 // Override the default forms_submitForm

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/upload_example.js
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/upload_example.js?view=diff&rev=474260&r1=474259&r2=474260
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/upload_example.js
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/upload_example.js
Mon Nov 13 03:34:36 2006
@@ -19,7 +19,7 @@
 function upload() {
     
     var form = new Form("forms/upload_model.xml");
-    var k = form.showForm("upload-display-pipeline");
+    var k = form.showForm("upload-display-pipeline.jx");
 
     k.invalidate();
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/upload_template.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/upload_template.xml?view=diff&rev=474260&r1=474259&r2=474260
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/upload_template.xml
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/upload_template.xml
Mon Nov 13 03:34:36 2006
@@ -16,14 +16,15 @@
   limitations under the License.
 -->
 <page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
-      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
+      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+      <jx:import uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
   <h4 class="samplesGroup">Upload widget</h4>
   <title>Upload Sample</title>
   <content>
     <para>
     For this example to work, you must enable uploads in your web.xml file.
     </para>
-    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST" enctype="multipart/form-data">
+    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST" enctype="multipart/form-data"
ajax="true">
       <fi:group>
         <fi:styling layout="columns"/>
         <fi:items>



Mime
View raw message