You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by peter <pe...@silmaril.ie> on 2006/05/23 14:39:36 UTC

Cforms dates and data destinations

I've been experimenting with Cforms and I think I have the hang of it now.

a) I didn't realise that datatype base="date" would pop up a calendar
   applet beside the field -- an excellent idea. But the img src that
   it references doesn't appear to get installed (no problem, I found
   it and copied it); but the link to onclick="forms_calendar.select()"
   doesn't do anything, because there is no javascript embedded or
   referenced that contains that function. Should I have done something
   extra at build time to enable this, or is it something I can add by
   hand?

b) In the examples, I seem to have missed how you deal with the data.
   At the moment only three targets are required: 
      i) mail the data to someone;
     ii) store the data in an XML file on the server for future reuse;
    iii) insert the data as a new element in an existing file on the 
         server (eg the XML equivalent of appending to a dataset).
   Are there built-in functions to do these?
   
///Peter


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


Re: AW: AW: Cforms dates and data destinations

Posted by Peter Flynn <pe...@silmaril.ie>.
Jason Johnston wrote:
[me]
>> Umm. There's already a head element in the template, which is the 
>> sample one from the Cocoon documentation
>
> Are your HTML elements by chance in the http://www.w3.org/1999/xhtml 
> namespace, or another namespace?  The CForms XSLT only matches elements 
> in the null namespace.  I've been tripped up by that before.

Yes, it was my own stupidity :-)
I had added a DocType Declaration to the top of the file for a modified 
copy of the XHTML DTD to help me learn the structure and be able to edit 
the file properly in Emacs/psgml, and of course the moment I commented 
it out, the problem disappeared. Grrr :-)

Thanks for all your suggestions. Now I just need to figure out how to 
write the validated form data to disk...

///Peter

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


Re: AW: AW: Cforms dates and data destinations

Posted by Jason Johnston <co...@lojjic.net>.
peter wrote:
> On Wed, 24 May 2006 10:20:36 +0200, Christofer Dutz wrote
>> 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 to using a simple <xsl:copy-of select="//head"/>
> 
> Umm. There's already a head element in the template, 
> which is the sample one from the Cocoon documentation at 
> http://cocoon.apache.org/2.1/userdocs/basics/sample.html:
> 
>   <head>
>     <title>Registration form</title>
>   </head>

Are your HTML elements by chance in the http://www.w3.org/1999/xhtml 
namespace, or another namespace?  The CForms XSLT only matches elements 
in the null namespace.  I've been tripped up by that before.

> 
> Using the sample transformation from the same place
> (forms-samples-styling.xsl), the output is appearing as:
> 
>   <head xmlns:bu="http://apache.org/cocoon/browser-update/1.0">
>     <title>Registration form</title>
>   </head>
> 
> Obviously something is missing but I can't see what.
> 
> ///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


Re: AW: AW: Cforms dates and data destinations

Posted by peter <pe...@silmaril.ie>.
On Wed, 24 May 2006 10:20:36 +0200, Christofer Dutz wrote
> 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 to using a simple <xsl:copy-of select="//head"/>

Umm. There's already a head element in the template, 
which is the sample one from the Cocoon documentation at 
http://cocoon.apache.org/2.1/userdocs/basics/sample.html:

  <head>
    <title>Registration form</title>
  </head>

Using the sample transformation from the same place
(forms-samples-styling.xsl), the output is appearing as:

  <head xmlns:bu="http://apache.org/cocoon/browser-update/1.0">
    <title>Registration form</title>
  </head>

Obviously something is missing but I can't see what.

///Peter



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


AW: AW: Cforms dates and data destinations

Posted by Christofer Dutz <du...@c-ware.de>.
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


Re: AW: Cforms dates and data destinations

Posted by Peter Flynn <pe...@silmaril.ie>.
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


AW: Cforms dates and data destinations

Posted by Christofer Dutz <du...@c-ware.de>.
Hi Peter

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 ;)

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.

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 [mailto:peter@silmaril.ie] 
Gesendet: Dienstag, 23. Mai 2006 14:40
An: users@cocoon.apache.org
Betreff: Cforms dates and data destinations

I've been experimenting with Cforms and I think I have the hang of it now.

a) I didn't realise that datatype base="date" would pop up a calendar
   applet beside the field -- an excellent idea. But the img src that
   it references doesn't appear to get installed (no problem, I found
   it and copied it); but the link to onclick="forms_calendar.select()"
   doesn't do anything, because there is no javascript embedded or
   referenced that contains that function. Should I have done something
   extra at build time to enable this, or is it something I can add by
   hand?

b) In the examples, I seem to have missed how you deal with the data.
   At the moment only three targets are required: 
      i) mail the data to someone;
     ii) store the data in an XML file on the server for future reuse;
    iii) insert the data as a new element in an existing file on the 
         server (eg the XML equivalent of appending to a dataset).
   Are there built-in functions to do these?
   
///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