You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by co...@apache.org on 2003/07/06 06:18:19 UTC

cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/flow/javascript woody.js

coliver     2003/07/05 21:18:19

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/flow/javascript
                        woody.js
  Log:
  Format code
  
  Revision  Changes    Path
  1.2       +90 -45    cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/flow/javascript/woody.js
  
  Index: woody.js
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/flow/javascript/woody.js,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- woody.js	5 Jul 2003 22:53:33 -0000	1.1
  +++ woody.js	6 Jul 2003 04:18:18 -0000	1.2
  @@ -1,18 +1,68 @@
  +/*
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  +
  + Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  +
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  +
  + 1. Redistributions of  source code must  retain the above copyright  notice,
  +    this list of conditions and the following disclaimer.
  +
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +    this list of conditions and the following disclaimer in the documentation
  +    and/or other materials provided with the distribution.
  +
  + 3. The end-user documentation included with the redistribution, if any, must
  +    include  the following  acknowledgment:  "This product includes  software
  +    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +    Alternately, this  acknowledgment may  appear in the software itself,  if
  +    and wherever such third-party acknowledgments normally appear.
  +
  + 4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
  +    used to  endorse or promote  products derived from  this software without
  +    prior written permission. For written permission, please contact
  +    apache@apache.org.
  +
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +    "Apache" appear  in their name,  without prior written permission  of the
  +    Apache Software Foundation.
  +
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  +
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software  Foundation and was  originally created by
  + Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
  + Software Foundation, please see <http://www.apache.org/>.
  +
  +*/
  +
   defineClass("org.apache.cocoon.woody.flow.javascript.ScriptableWidget");
   
   function Form(formDef, attrName) {
  -  var formMgr = cocoon.componentManager.lookup(Packages.org.apache.cocoon.woody.FormManager.ROLE);
  -  try {
  -    var resolver = cocoon.environment;
  -    var src = resolver.resolveURI(formDef);
  -    this.form = formMgr.createForm(src);
  -    this.formWidget = new Widget(this.form);
  -    this.attrName = attrName;
  -    this.lastWebContinuation = null;
  -    this.rootContinuation = null;
  -  } finally {
  -    cocoon.componentManager.release(formMgr);
  -  }
  +    var formMgr = cocoon.componentManager.lookup(Packages.org.apache.cocoon.woody.FormManager.ROLE);
  +    try {
  +        var resolver = cocoon.environment;
  +        var src = resolver.resolveURI(formDef);
  +        this.form = formMgr.createForm(src);
  +        this.formWidget = new Widget(this.form);
  +        this.attrName = attrName;
  +        this.lastWebContinuation = null;
  +        this.rootContinuation = null;
  +    } finally {
  +        cocoon.componentManager.release(formMgr);
  +    }
   }
   
   Form.prototype.start = function(lastWebCont, timeToLive) {
  @@ -42,13 +92,14 @@
   } 
   
   Form.prototype.getModel = function() {
  -  return this.formWidget;
  +    return this.formWidget;
   }
   
   Form.prototype.show = function(uri, validator) {
       var lastWebCont = this.lastWebContinuation;
       // create a continuation, the invocation of which will resend
  -    // the page: this is used to implement <xf:submit continuation="back">
  +    // the page: this will be used to implement automated "back"
  +    // navigation
       var wk = this.start(lastWebCont);
       while (true) {
           if (cocoon.request == null) {
  @@ -58,35 +109,29 @@
               suicide();
           }
           var thisWebCont = this._show(uri, wk);
  -        // _sendView creates a continuation, the invocation of which
  +        // _show creates a continuation, the invocation of which
           // will return right here: it is used to implement 
  -        // <xf:submit continuation="forward">
  +        // automated "next" navigation
           if (this.dead ||  cocoon.request == null) {
               // this continuation has been invalidated
               handleInvalidContinuation();
               suicide();
           }
  -	var formContext = 
  -	  new Packages.org.apache.cocoon.woody.FormContext(cocoon.request, 
  -							   java.util.Locale.US);
  -	var e = cocoon.request.getParameterNames();
  -	while (e.hasMoreElements()) {
  -	  var paramName = e.nextElement();
  -	  print(paramName + "="+cocoon.request.get(paramName));
  -	}
  -	cocoon.request.setAttribute(this.attrName, this.form);
  +        var formContext = 
  +            new Packages.org.apache.cocoon.woody.FormContext(cocoon.request, 
  +                                                             java.util.Locale.US);
  +        cocoon.request.setAttribute(this.attrName, this.form);
           var finished = this.form.process(formContext);
  -	print("finished="+finished);
  -	var evt = formContext.getActionEvent();
  -	if (evt != null) {
  -	  this.submitId = String(evt.getActionCommand());
  -	} else {
  -	  this.submitId = undefined;
  -	}
  +        var evt = formContext.getActionEvent();
  +        if (evt != null) {
  +            this.submitId = String(evt.getActionCommand());
  +        } else {
  +            this.submitId = undefined;
  +        }
           if (validator != undefined) {
  -	  finished = validator(this) && finished;
  +            finished = validator(this) && finished;
           }
  -	if (finished) {
  +        if (finished) {
               break;
           }
       }
  @@ -102,28 +147,28 @@
       this.lastWebContinuation = wk;
       cocoon.request.setAttribute(this.attrName, this.form);
       cocoon.forwardTo("cocoon://" + 
  -                          cocoon.environment.getURIPrefix() + uri,
  -                          bizData, wk);
  +                     cocoon.environment.getURIPrefix() + uri,
  +                     bizData, wk);
       suicide();
   }
   
   Form.prototype.finish = function() {
  -  this.rootContinuation.invalidate();
  -  this.rootContinuation = null;
  -  this.lastWebContinuation = null;
  -  this.form = null;
  -  this.formWidget = null;
  +    this.rootContinuation.invalidate();
  +    this.rootContinuation = null;
  +    this.lastWebContinuation = null;
  +    this.form = null;
  +    this.formWidget = null;
   }
   
   Form.prototype.getSubmitId = function() {
  -  return this.submitId;
  +    return this.submitId;
   }
   
  -function woody(application, form_definition, attribute_name) {
  +function woody(form_function, form_definition, attribute_name) {
       var args = new Array(arguments.length - 2 + 1);
       args[0] = new Form(form_definition, attribute_name);
       for (var i = 2; i < arguments.length; i++) {
  -      args[i-1] = arguments[i];
  +        args[i-1] = arguments[i];
       }
  -    this[application].apply(this, args);
  +    this[form_function].apply(this, args);
   }