On 16.Jan.2003 -- 08:17 PM, Miles Elam wrote:
> The next thought was Actions, but that was just keeping the code 
> relatively out of sight.  It seemed fairly clumsy for any non-trivial 
> amount (more than 100 lines) of logic and made the sitemap kinda crufty 
> as well.
> 
> Next came Flow.  Although I didn't have multiple pages to work with as 
> is the case with a wizard, it seemed to make a lot of sense in a 
> predominantly procedural logic approach.  However, I ran into a few 
> snags -- mostly related to lack of documentation (yes, I realize it's 
> alpha and the API may be pulled out from under me...I'm prepared to deal 
> with the search/replace/debug repercussions).  I'll keep my code snippet 
> as short as possible.
> 
> function saveShow () {
>  var showData;
>  try {
>    var factory      = 
> javax.xml.parsers.DocumentBuilderFactory.newInstance();
>    var builder      = factory.newDocumentBuilder();
>    var showDocument = builder.parse( /* Somehow get the XML POST data 
> in here */ );
> 
>    var showData = getShowData(showDocument);
>  } catch ( e ) {
>    sendPageAndContinue("showerror");
>  }
> 
>  try {
>    var dbConn = /* Somehow get the datasource by name */.getConnection();
>    var dbStatement = dbConn.createStatement();
>    // ...snip a whole bunch of extraneous JDBC logic...
>  } catch (sqle) {
>    sendPageAndContinue("showerror");
>  }
> }

Why don't you code this in a java class and just use it from flow? Why
would you want to code that in javascript?

> 1) How do I get XML POST data into the function (eg. equivalent to 
> StreamGenerator)?

You could write an InputModule for that and copy the relevant parts
from the StreamGenerator or write an InputModule that can connect to
an internal pipeline (the XMLFileModule does something similar).

> 2) How do I look up a Cocoon datasource by name in JavaScript/Flow?

If you follow suggestion to 1) you could use the database actions from
the modular package and don't need to. Apart from that, you have
pretty much the same options as inside a java component. See
e.g. system.js and JSCocoon.java for the available objects.

See also
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=103811227701167&w=2

        Chris.
-- 
C h r i s t i a n       H a u l
[EMAIL PROTECTED]
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to