Hi André

That is more or less what I was trying to achieve, ie. write Java code that
can be used in my flowscript but for this Java code to be completely 
independent of cocoon. From reading the documentation I was given 
to understand that this code could be compiled on the fly which would 
of course speed up development time (See the documentation link I referenced 
in the original post). I have never had any problem using standard Java 
classes, such as ArrayList, etc. in flowscript, the problem is accessing 
classes that I have written. So as far as I can see there are three options 
outlined below, the third one being the only one I have been able to
successfully achieve.

Option 1: Have your code compiled on the fly, specifiying in cocoon.xconf a
classpath as to where it should look for source code. I cannot get this to 
work and this was why I posted the message in the first place. In more 
detail this is what I do:

Add the following to cocoon.xconf:

<flow-interpreters default="javascript" logger="flow">
  <component-instance
class="org.apache.cocoon.components.flow.javascript.fom.
FOM_JavaScriptInterpreter"
name="javascript">
   
<load-on-startup>resource://org/apache/cocoon/components/flow/
javascript/fom/fom_system.js</load-on-startup>
    <reload-scripts>true</reload-scripts>
    <check-time>4000</check-time>
    <classpath>file:/path/to/my/java/src</classpath>
  </component-instance>
</flow-interpreters>

Javascript in my flowscript:

var resource = new Packages.mypackage.xyz.MyClass();

Throws the following exception:

org.mozilla.javascript.EcmaError: TypeError: 
[JavaPackage mypackage.xyx.MyClass] is not a function, 
it is org.mozilla.javascript.NativeJavaPackage. 


Option 2: Complile my code to the my application's WEB-INF/classes 
directory (or alternatively place it in a jar file in the application's
WEB-INF/lib directory. This I also tried but to no avail.

Option 3: Place the compiled classes in the cocoon's own classes folder. 
When I do this I can indeed access my Java classes from flowscript. 
But this for me is the least desireable solution as it requires me to 
mix my own class files with cocoons class files which I don't consider 
elegant nor correct. And also, cocoon would need to be restarted 
everytime I make a modication to my Java classes.

Regards
Des


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

Reply via email to