I'm trying to do something in flowscript that must be pretty common. I
simply want to pass a HashMap of arguments from JavaScript to a Java method
which will then process the Map to perform some useful business function.
Can anyone spot what I'm doing wrong? I get a Javascript exception (listed
at the end of this email).
I suspect I'm not casting the HashMap properly but my JavaScript is weak in
this area. I think I'm doing something similar to the 'Calling Java'
documentation (http://cocoon.apache.org/2.1/userdocs/flow/java.html) but
maybe I missed something.
++++++++
My Flowscript looks something like this: -
importClass(Packages.com.MySingleton);
function main() {
var theParams = new java.util.HashMap();
theParams.put("param1", "value1");
var usefulObject = MySingleton.doSomethingUseful(theParams); <==
Exception occurs here.
cocoon.sendPage("apage.jx", {"useful" : usefulObject} );
}
++++++++
My Java method is defined as follows: -
public synchronized UsefulObject doSomethingUseful(Map params) {
String[] vals = (String[])params.get("param1");
if (vals == null || vals.length < 1)
...
++++++++
When I access the page I get the following error: -
java.lang.String
org.apache.avalon.framework.CascadingRuntimeException:
"file:/D:/projects/.../flow/myflowscript.js", line 6: uncaught JavaScript
exception: at main (file:/D:/projects/.../flow/myflowscript.js, Line 6):
java.lang.ClassCastException: java.lang.String
cause: java.lang.ClassCastException: java.lang.String
full exception chain stacktrace[hide]
org.apache.avalon.framework.CascadingRuntimeException:
"file:/D:/projects/.../flow/myflowscript.js", line 6: uncaught JavaScript
exception:
at main (file:/D:/projects/.../flow/myflowscript.js, Line 6):
java.lang.ClassCastException: java.lang.String
at
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.callFunction(FOM_JavaScriptInterpreter.java:764)
at
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:135)
at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:46)
at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:138)etc...
++++++++
Best Regards,
David Legg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]