cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <dani...@nada.kth.se>
Subject Re: [cforms] Simple XML binding
Date Wed, 09 Jun 2004 14:00:00 GMT
Reinhard Poetz wrote:

> Daniel Fagerstrom wrote:
> 
>> I have written an adapter: org.apache.cocoon.forms.util.XMLAdapter 
>> between a form object and a simple XML format that can be used without 
>> needing to wriite a binding definition.
>>
> 
> Thank you very much! I think this is a very valuable addition to Cocoon 
> Forms and is the answer for many form applications which have straight 
> binding.
> 
> One question - why do you make this explicit:
> 
>    // get the documentURI parameter from the sitemap which contains the
>    // location of the file to be edited
>    var documentURI = cocoon.parameters["documentURI"];
> 
>    // get the XML adapter
>    var xmlAdapter = form.getXML();
> 
>    // parse the document to a widget tree
>    var pipeUtil =
>        
> cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.PipelineUtil); 
> 
>    pipeUtil.processToSAX(documentURI, null, xmlAdapter);
> 
> 
> and don't hide it in the form.getXML() function?
> 
> e.g.
> var xmlAdapter = form.getXML( cocoon.parameters["documentURI"] );
> 

Agree :)

I have added loadXML(uri) and saveXML(uri) to the api, now the example 
look like:

     // get the documentURI parameter from the sitemap which contains the
     // location of the file to be edited
     var documentURI = cocoon.parameters["documentURI"];

     // populate the form
     form.loadXML(documentURI);

     // show the form to the user until it is validated successfully
     form.showForm("form2-display-pipeline");

     // save the content of the form to a file
     form.saveXML(makeTargetURI(documentURI));

     // show the xml generated from the form
     cocoon.sendPage("form2simpleXML-success-pipeline", form.getXML());

Here we also save the content to a file (or any modifiable source). The 
getXML() method is still part of the api as it gives the possiblity to 
use the content handler and xmlizable interfaces, and also to set 
properties for the adapter, (this far only the choise of locale for 
string conversion).

/Daniel


Mime
View raw message