You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Paul Bowler <pa...@www.aventix.co.uk> on 2004/08/13 15:10:06 UTC

Create new form model for later binding

I've got form binding working nicely for existing form documents in my XML database (thanks for all your help). 
However, this only works with data that alrady exists within the database. If I try to use it for a new form instance I 
get 'No cocoon form found' as there is no data from which to load into the form.

How can I create a new instance of the form data that can then be bound to the XML database (i.e. create a new XML 
document from a given form specification)?

The script I am using for editing documents is here:

function editxml(form) {
	var form = new Form(cocoon.parameters["form-definition"]);
	var bindingURI = cocoon.parameters["bindingURI"];
	var dataURI = cocoon.parameters["dataURI"];
	var dataURI = cocoon.parameters["formURI"]; 

	var doc = loadDocument(dataURI);

	form.createBinding(bindingURI);
	form.load(doc);
	form.showForm(formURI);
	form.save(doc);

	saveDocument(doc, dataURI);
}

I think I need to replace the loadDocument() call but don't know what with.

Many thanks,

Paul.

--
Paul Bowler
Aventix Associates Ltd

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


Re: Create new form model for later binding

Posted by Paul Bowler <pa...@aventix.co.uk>.
> Paul Bowler wrote:
> > I've got form binding working nicely for existing form documents in my XML database (thanks for all your help). 
> > However, this only works with data that alrady exists within the database. If I try to use it for a new form 
instance I 
> > get 'No cocoon form found' as there is no data from which to load into the form.
> > 
> > How can I create a new instance of the form data that can then be bound to the XML database (i.e. create a new XML 
> > document from a given form specification)?
> > 
> > The script I am using for editing documents is here:
> > 
> > function editxml(form) {
> > 	var form = new Form(cocoon.parameters["form-definition"]);
> > 	var bindingURI = cocoon.parameters["bindingURI"];
> > 	var dataURI = cocoon.parameters["dataURI"];
> > 	var dataURI = cocoon.parameters["formURI"]; 
> > 
> > 	var doc = loadDocument(dataURI);
> 
> var doc = loadDocument("cocoon://data-creation-pipeline");
> and here we go :)

Thanks, but this is not what I mean. This is a NEW instance of a form (i.e. a form that has no data yet) so there is 
nowhere to load the data from. I need to miss out the loadDocument() function altogether, but this means I don't have 
a 'document' object for the required saveDocument() function.

Can I create a 'document' from the forms validated 'model' object?

Thanks,

Paul.

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


Re: Create new form model for later binding

Posted by Olivier Billard <ol...@laposte.net>.
Paul Bowler wrote:
> I've got form binding working nicely for existing form documents in my XML database (thanks for all your help). 
> However, this only works with data that alrady exists within the database. If I try to use it for a new form instance I 
> get 'No cocoon form found' as there is no data from which to load into the form.
> 
> How can I create a new instance of the form data that can then be bound to the XML database (i.e. create a new XML 
> document from a given form specification)?
> 
> The script I am using for editing documents is here:
> 
> function editxml(form) {
> 	var form = new Form(cocoon.parameters["form-definition"]);
> 	var bindingURI = cocoon.parameters["bindingURI"];
> 	var dataURI = cocoon.parameters["dataURI"];
> 	var dataURI = cocoon.parameters["formURI"]; 
> 
> 	var doc = loadDocument(dataURI);

var doc = loadDocument("cocoon://data-creation-pipeline");
and here we go :)

> 
> 	form.createBinding(bindingURI);
> 	form.load(doc);
> 	form.showForm(formURI);
> 	form.save(doc);
> 
> 	saveDocument(doc, dataURI);
> }
> 
> I think I need to replace the loadDocument() call but don't know what with.
> 
> Many thanks,
> 
> Paul.
> 
> --
> Paul Bowler
> Aventix Associates Ltd


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


Re: Create new form model for later binding

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 13/ago/04, alle 15:10, Paul Bowler ha scritto:

> How can I create a new instance of the form data that can then be 
> bound to the XML database (i.e. create a new XML
> document from a given form specification)?

I usually create a "skeleton" document that has all the elements 
required by the schema, only empty or with default values.

	Ugo

-- 
Ugo Cei - http://beblogging.com/