cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From coli...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript xmlForm.js
Date Mon, 21 Apr 2003 16:16:10 GMT
coliver     2003/04/21 09:16:10

  Modified:    src/java/org/apache/cocoon/components/flow/javascript
                        xmlForm.js
  Log:
  Added getSubmitId() function to return the id of the button that was pressed to submit the
form
  
  Revision  Changes    Path
  1.10      +31 -10    cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/xmlForm.js
  
  Index: xmlForm.js
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/xmlForm.js,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- xmlForm.js	1 Apr 2003 20:02:43 -0000	1.9
  +++ xmlForm.js	21 Apr 2003 16:16:10 -0000	1.10
  @@ -23,6 +23,7 @@
       this.lastContinuation = null;
       this.validatorNS = validatorNS;
       this.validatorDoc = validatorDoc;
  +    this.submitId = undefined;
       this.dead = false;
   }
   
  @@ -36,6 +37,14 @@
   }
   
   /**
  + * Return the id of the xf:submit element of the current form submission
  + * @return [String] id attribute of the button that caused this from to be submitted
  + */
  +XForm.prototype.getSubmitId = function() {
  +    return this.submitId;
  +}
  +
  +/**
    * Set the model object of this form
    * @param model [Object] Any Java bean, JavaScript, DOM, or JDOM object 
    */
  @@ -157,9 +166,8 @@
    * @param uri [String] presentation pipeline resource identifier of view
    * @param validator [Function] optional function invoked to perform validation
    */
  -XForm.prototype.sendView = function(phase, uri, validator) {
  +XForm.prototype.sendView = function(view, uri, validator) {
       var lastCont = this.lastContinuation;
  -    var view = this.form.getFormView(this.cocoon.environment.objectModel);
       while (true) {
           // create a continuation, the invocation of which will resend
           // the page: this is used to implement <xf:submit continuation="back">
  @@ -184,10 +192,12 @@
               suicide();
           }
           this.form.populate(this.cocoon.environment.objectModel);
  +        this.submitId = 
  +	  this.cocoon.request.getAttribute("xml-form-submit-id");
           if (validator != undefined) {
  -            validator(this);
  +	    validator(this);
           }
  -        this.form.validate(phase);
  +        this.form.validate(view);
           if (!this.hasViolations()) {
               break;
           }
  @@ -218,10 +228,10 @@
   XForm.prototype.finish = function(uri) {
       this.form.remove( this.cocoon.environment.objectModel, this.id);
       this.form.save( this.cocoon.environment.objectModel, "request");
  -     this.cocoon.forwardTo("cocoon://" + 
  -                      this.cocoon.environment.getURIPrefix() + uri,
  -                      this.form.getModel(), 
  -                      null);
  +    this.cocoon.forwardTo("cocoon://" + 
  +			  this.cocoon.environment.getURIPrefix() + uri,
  +			  this.form.getModel(), 
  +			  null);
       this.dead = true;
       if (this.lastContinuation != null) {
           this.lastContinuation.invalidate();
  @@ -263,7 +273,18 @@
       var command = getCommand();
       if (command != undefined) {
           // invoke a continuation 
  -        cocoon.interpreter.handleContinuation(command, 
  +        // command looks like kontId:id
  +	var id = "";
  +	var kontId = command;
  +	var index = command.indexOf(java.lang.String(":").charAt(0));
  +	if (index > 0) {
  +	    var kontId = command.substring(0, index);
  +	    if (index + 1 < command.length()) {
  +		id = command.substring(index + 1);
  +	    }
  +	}
  +	cocoon.request.setAttribute("xml-form-submit-id", id);
  +        cocoon.interpreter.handleContinuation(kontId, 
                                                 null,
                                                 cocoon.environment);
           return;
  
  
  

Mime
View raw message