cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Johnston <jason.johns...@Intrado.com>
Subject Re: flow - java.util.Object[] {something} causes syntax Error
Date Wed, 24 Aug 2005 19:22:58 GMT
The Rhino FAQ has the answer for how to create Java Arrays in JavaScript
(you have to use reflection):

http://www.mozilla.org/rhino/faq.html


On Wed, 2005-08-24 at 21:18 +0200, Thorsten Scherler wrote:
> Hi all,
> 
> Background:
> ****************************************************
> I am trying to activate cforms in Lenya's usecase-fw.
> 
> For this I need to execute javascript snippets that are coming from a
> configuration file. e.g. 
> <after>
>  form.setAttribute("counter", new java.lang.Integer(0));
> </after>
> 
> Antonio pointed me to
> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/util/JavaScriptHelper.html
> 
> I tested before with execScript (I started with that) like:
> jsHelper.execScript(view.getTestScript(),scriptMap,objectModel);
> but that did not work.
> 
> I created a function which I want to access in the flow script. I am
> trying to use "public static Object callFunction(Function func, Object
> thisObject, Object[] arguments, Map objectModel)" from within my *flow*
> script.
> 
> Instead of using:
> form = new Form(viewDef);
> form.setAttribute("counter", new java.lang.Integer(0));
> 
> I want to use:
> var flowHelper =
> cocoon.getComponent("org.apache.lenya.cms.cocoon.flow.FlowHelper");
> var objectModel = flowHelper.getObjectModel(cocoon);
> var jsHelper = new
> Packages.org.apache.cocoon.forms.util.JavaScriptHelper();
> form = new Form(viewDef);
> jsHelper.callFunction(view.getTestFunction(),form,new java.util.Object[]
> {form}, objectModel);
> 
> Problem:
> *****************************************************
> As soon as I try:
> var test = new java.util.Object[] {"test"};
> 
> I get:
> ...
> Caused by: SyntaxError: syntax error
> (file:/home/thorsten/apache/lenya-trunk/build/lenya/webapp/lenya/usecases/usecases.js;
line 144)
>  
> which is above line.
> 
> How can I use JavaScriptHelper.callFunction if I cannot create an
> Object[]?
> 
> Is there another way to create a Object[] then the above mentioned? Is
> this a bug?
> 
> Is there a better way to execute javascript that is stored in a string?
> 
> TIA
> 
> salu2

Mime
View raw message