cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ugo Cei <...@apache.org>
Subject Re: Using htmlArea 'output' with SVG
Date Fri, 26 Nov 2004 08:23:23 GMT
Il giorno 26/nov/04, alle 08:41, Derek Hohls ha scritto:

> OK, sorry for my obviously too brief explanation.
> I was trying to say that I am using the normal
> Cocoon "binding forms to an XML file" approach.
> That *is*, as far as I understand, very much Cocoon's
> concern. I don't know know how Ccooon does this,
> and the 'where' is not really relevant in this case.
> What I am trying to  figure out is how to get the altered
> string (DOM) "back into" the form data that needs to be
> saved.  i.e. between the two steps that I had listed.
>
> If you do not know how to do this, then I will start a
> new thread, based on all the info to date, and see if
> someone else can help.

OK, I'll bite

1) At the moment, NO released version of Cocoon, up to 2.1.6, has 
support for binding a field (HTMLArea or otherwise) to an XML document 
or to check that the contents of a field is well-formed XML. If you 
want that, you must write some code yourself.

2) The fact that you are using the normal "binding forms to an XML file 
approach" does NOT rule out the possibility of handling some fields 
_outside_ the binding framework, i.e. by hand, as I hinted when I 
wrote:

"You could insert it right after the call to form.showForm(). You 
could, for instance, use the forms binding framework for all fields of 
the supported datatypes, and manually retrieve and parse just the HTML 
fields."

3) Actually, there is no such thing as a "binding forms to an XML file 
approach" in CForms! The binding is, IIRC, to a DOM document, which 
fits quite nicely with the fact that my class returns a DOM.

If you want some pseudocode, how about this:

var model = .... // Some DOM object
form.load(model);
form.showForm("uri");
form.save(model);
var html = form.lookupWidget("/htmlArea).value;
var dom = HTMLParser.parse(html);
var parentNode = model.someDomApiCall() // Use the DOM to get the point 
in the doc where you want to append the HTML
var newNode = model.importNode(html, true); // Import the HTML
parentNode.appendChild(newNode);

The last three calls are straight from the DOM API.

	Ugo

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

Mime
View raw message