cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christofer Dutz" <d...@c-ware.de>
Subject AW: AW: Cforms dates and data destinations
Date Wed, 24 May 2006 08:20:36 GMT
If you add a tag called "head" anywhere in your template, then CForms will
add all CForm stuff (CSS, JavaScript, ... everything that belongs into a
html head-tag) it needs inside this tag. All you have to do in any
transformation is to "move" the entire content to the place it belongs o
using a simple <xsl:copy-of select="//head"/>

One hint to the reading direction If you want to avoid having to code
multiple functions for reading from multiple places ... let cocoon do that
for you. If you add the following code to your CForm, then you can read from
any source cocoon can read from.

// For loadDocument
importClass(org.apache.excalibur.xml.dom.DOMParser);
importClass(org.apache.cocoon.environment.SourceResolver);
importClass(org.xml.sax.InputSource);

function loadDocument(uri) {
    var parser = null;
    var source = null;
    var resolver = null;
    try {
        parser = cocoon.getComponent(DOMParser.ROLE);
        resolver = cocoon.getComponent(SourceResolver.ROLE);
        source = resolver.resolveURI(uri);
        var is = new InputSource(source.getInputStream());
        is.setSystemId(source.getURI());
        return parser.parseDocument(is);
    } finally {
        if (source != null)
            resolver.release(source);
        cocoon.releaseComponent(parser);
        cocoon.releaseComponent(resolver);
    }
}


Here an example for using it:

    var form = new Form("definition/guestbook-def.xml");
    form.createBinding("bindings/guestbook-bind.xml");

    var doc = loadDocument("cocoon:/guestbook.db?position=" + position);
    form.load(doc);  
    
    // Show the form
    form.showForm("guestbook-templ.jexl");

I use XQuery with update functions for saving, but since this only works
with few Xml Databases, I left the code for saving out. I think you would
have to do this manually.

Chris

[ c h r i s t o f e r   d u t z ]

IT-Berater
univativ GmbH & Co. KG
Robert-Bosch-Str. 7, 64293 Darmstadt

fon:  0 61 51 / 66 717 -0
fax:  0 61 51 / 66 717 -29
email:  christofer.dutz@univativ.de
http://www.univativ.de

Darmstadt, Stuttgart, Karlsruhe, Düsseldorf


-----Ursprüngliche Nachricht-----
Von: Peter Flynn [mailto:peter@silmaril.ie] 
Gesendet: Dienstag, 23. Mai 2006 23:13
An: users@cocoon.apache.org
Betreff: Re: AW: Cforms dates and data destinations

Christofer Dutz wrote:
> a: The samples-styling xslt looks for a head-tag to insert the javascript.
> When starting to use CForms I missed that at first. Either change the xslt
> or add a dummy "head" element somewhere. You can move the stuff in another
> transformation ;)

Changing the XSLT is easy, but this sounds like I have to know what
Javascript it wants, and I wouldn't know where to start looking.

> b: As far as I understood everything you can either use W3C DOM Objects or
> java Beans with all get and set methods implemented. In flowscript you can
> do whatever you like with them. If you need some assistance, just mail me
> which form you prefer to store your data and I will send you some sample
> code.

DOM Objects would be preferable, but I haven't started learning
flowscript yet. I was just curious to see how Cocoon would be
expected to handle writing to the server disk, given that its
principal mode of operation is to read from disk and write down
the wire to the user.

Thanks very much for your offer, I'll mail separately about this.

///Peter

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




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


Mime
View raw message