cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thors...@apache.org>
Subject Re: flow - java.util.Object[] {something} causes syntax Error
Date Thu, 25 Aug 2005 10:14:09 GMT
On Wed, 2005-08-24 at 13:22 -0600, Jason Johnston wrote:
> 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
> 
> 

Cheers that solved the Object[] problem but still I cannot do what is
described in the background. :( It is the same like with execScript. I
think that the context is not right. 

thanks

salu2

> 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
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)

--------------------------------------------------------------
Thorsten Scherler
Wyona Inc.  -  Open Source Content Management  -  Apache Lenya
http://www.wyona.com                   http://lenya.apache.org
thorsten.scherler@wyona.com                thorsten@apache.org




Mime
View raw message