jantje wrote:
Query the database from my flowscript? I have an object oriented database
(db4o.com).. is it also possible to query this database in flowscript? do
you know where to find information about this.. and how can I f.i. do this
in flowscript: "import com.db4o.*"

Can someone tell me how to do this in flowscript?



If you can do it in Java you can do it in flowscript (though the syntax usually isn't quite as nice). The reason is that flowscript uses the Rhino JavaScript engine, which allows you to script Java. See http://www.mozilla.org/rhino/ScriptingJava.html for details.

Personally I prefer to write this sort of heavy-lifting model/DAO code in pure Java, and then just make simple method calls from the flowscript to my Java classes. Some people prefer to do it all in flowscript though, because of the quick try/fail/reload cycle.


Okay, here are a couple possibilities:

1) Query the database from your flowscript. You've got the full power of JDBC available to you; you can either write the query code directly in your flowscript or write a Java class that does the query and gets called by your flowscript.

2) If you really want to use a pipeline to do the query (e.g. XSP or SQLTransformer), you can have your flowscript call that pipeline and get the result as a DOM tree, and then grab the values out of it using the DOM API...

var pipelineUtil = new Packages.org.apache.cocoon.components.flow.util.PipelineUtil();
   var dom = pipelineUtil.processToDOM("query-pipeline", {});
   var elements = dom.getElementsByTagName("...");
   var targetArray = [];
   for(var i=0; i<elements.getLength(); i++) {
     targetArray.push(elements.item(i).getFirstChild().getNodeValue());
   }

(or something like that.)

HTH
--Jason

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





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

Reply via email to