cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Hutchinson" <simon.hutchin...@misgl.com>
Subject Re: Validate an XML document in a flowscript
Date Wed, 16 Jun 2004 15:11:29 GMT
Vilya Harvey wrote:

 > What I'd like to be able to do is insert some code after the
 > form.save(...) line which validates the form, and loops back to the
 > form.load(...) line if validation fails. Any suggestions?


Sounds like a simple while loop might do the trick.

var isValid = false;

function enterForecasts(form)
     {
       // parse the document to a DOM-tree
       var documentObj = loadDocument("sampledata.xml");

       // bind the document data to the form

       while(!isValid) {
       	form.load(documentObj);
      	 // show the form to the user until it is validated successfully
       	form.showForm("form-display-pipeline");
       	// bind the form's data back to the document
       	form.save(documentObj);

	validateForm(form);
       }

       // save the DOM-tree back to an XML file, the makeTargetURI
       // function makes a modified filename so that the
       // original document is not overwritten
       saveDocument(documentObj, makeTargetURI(documentURI));

       cocoon.sendPage("form-success-pipeline");
}

function validateForm(form) {
	//pseudo code
			
	//do validation stuff
	if(validates) {
	   isValid=true;		
	}
	
	return;
}


Cheers

Si
 
 
 
 
 
-- 
 
Merlin Information Systems Limited, 
 
Merlin House, Gawcott Road, Buckingham, United Kingdom. MK18 1TN
 
Tel: +44 (0) 1280 824331  Fax: +44 (0) 1280 824112
 

 
http://www.misgl.com
 
Provider of IT Services and Online Portal Support Services. 
 
 
 
Confidentiality:
 
The information contained in this email (including any attachments) is confidential and is
intended solely for the use of the named addressee. Access, copying or re-use of the information
in it by any other person is not authorised. If you are not the intended recipient, please
notify us immediately by telephone or by e-mail to admin@misgl.com
 

 
 
 
*** This mail has been scanned for viruses ***
 

 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message