Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-26 Thread Reinhard Poetz

Thorsten Scherler wrote:

On Thu, 2005-08-25 at 19:15 +0200, Reinhard Poetz wrote:


Thorsten Scherler wrote:



Cheers, Reinhard.

Good to know. Does it make sense to update the 2.1.x? I could do it, if
you think it is a good idea.


No, it was decided not to upgrade in branch because of the incompatibilities. A 
patch level release wouldn't justify such a change.





Ok, thanks for that info. That means that I will have to stick with the
"new Function" solution for lenya, because we are using 2.1.x there.

I will try in forrest where we use trunk. ;-)


not necessarily, you can only change the rhino lib as it is *mostly* backwards 
compatible.


If this is okay (checkout the status.xml in trunk to find the differences) for 
Lenya, just do it there. We only can't ship a 2.1.x release of Cocoon with an 
incompatible Rhino library.


--
Reinhard Pötz   Independent Consultant, Trainer & (IT)-Coach 


{Software Engineering, Open Source, Web Applications, Apache Cocoon}

   web(log): http://www.poetz.cc



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-26 Thread Thorsten Scherler
On Thu, 2005-08-25 at 19:15 +0200, Reinhard Poetz wrote:
> Thorsten Scherler wrote:
> 
> > Cheers, Reinhard.
> > 
> > Good to know. Does it make sense to update the 2.1.x? I could do it, if
> > you think it is a good idea.
> 
> No, it was decided not to upgrade in branch because of the incompatibilities. 
> A 
> patch level release wouldn't justify such a change.
> 

Ok, thanks for that info. That means that I will have to stick with the
"new Function" solution for lenya, because we are using 2.1.x there.

I will try in forrest where we use trunk. ;-)

thanks again

salu2
-- 
thorsten

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



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Reinhard Poetz

Thorsten Scherler wrote:


Cheers, Reinhard.

Good to know. Does it make sense to update the 2.1.x? I could do it, if
you think it is a good idea.


No, it was decided not to upgrade in branch because of the incompatibilities. A 
patch level release wouldn't justify such a change.


--
Reinhard Pötz   Independent Consultant, Trainer & (IT)-Coach 


{Software Engineering, Open Source, Web Applications, Apache Cocoon}

   web(log): http://www.poetz.cc



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Thorsten Scherler
On Thu, 2005-08-25 at 16:14 +0200, Reinhard Poetz wrote:
> Thorsten Scherler wrote:
> > On Thu, 2005-08-25 at 15:47 +0200, Reinhard Poetz wrote:
> 
> > You mean the Rhino stuff in trunk (2.2) is newer?
> 
> yes, it is. trunk uses the latest Rhino from Mozilla (1.6) and branch uses 
> and a 
> forked version of Rhino 1.5.
> 

Cheers, Reinhard.

Good to know. Does it make sense to update the 2.1.x? I could do it, if
you think it is a good idea.

salu2
-- 
thorsten

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



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Thorsten Scherler
On Thu, 2005-08-25 at 15:48 +0200, Thorsten Scherler wrote:
> On Thu, 2005-08-25 at 07:41 -0600, Jason Johnston wrote:
> > Thorsten Scherler wrote:
> > > On Wed, 2005-08-24 at 16:45 -0500, Antonio Gallardo wrote:
> > >>AFAIK, Thorsten already tried eval() and does not work. :-(
> > >>
> > > 
> > > Yeah, Antonio is right.
> > > 
> > > The eval() gives "Calling eval() with anything other than a primitive
> > > string value will simply return the value. Is this what you intended?". 
> > > 
> > > ...and that is not what I was intended. ;-)
> > 
> > Hmm, you're right, I just tried it myself and got the same thing. 
> > eval() must be broken in Rhino.
> > 
> > Another possibility: use the "new Function(string)" constructor to 
> > create a function from a string and then call it, for example:
> > 
> >var evalFunc = new Function("string of JS code to evaluate here");
> >evalFunc();
> > 
> > If you want to pass particular arguments to it you can do that too; more 
> > details at
> > http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Function#Created_By
> 
> 
> Wow, sweet. Thx a million. I will try that and report back. :)
> 
> Muchas gracias

Yeah, that is working just great.

You made my day, Jason. :)

Thanks as well in the name of the lenya community. :)

http://svn.apache.org/viewcvs?rev=240094&view=rev ;-)

Muchas gracias.

salu2
-- 
thorsten

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



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Reinhard Poetz

Thorsten Scherler wrote:

On Thu, 2005-08-25 at 15:47 +0200, Reinhard Poetz wrote:



You mean the Rhino stuff in trunk (2.2) is newer?


yes, it is. trunk uses the latest Rhino from Mozilla (1.6) and branch uses and a 
forked version of Rhino 1.5.


--
Reinhard Pötz   Independent Consultant, Trainer & (IT)-Coach 


{Software Engineering, Open Source, Web Applications, Apache Cocoon}

   web(log): http://www.poetz.cc



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Thorsten Scherler
On Thu, 2005-08-25 at 15:47 +0200, Reinhard Poetz wrote:

> just for the records: which Cocoon version are you guys using?
> 

2.1.x branch head-version

> Please note, that the Rhino version in trunk is *mostly* compatible with 
> Rhino 
> version in 2.1 branch.
> There are only some some minor issues - see status.xml in trunk to find out 
> the 
> details.
> You should be able to simply replace rhino.jar in branch with the jar from 
> trunk.
> 

You mean the Rhino stuff in trunk (2.2) is newer?

salu2
-- 
thorsten

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



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Thorsten Scherler
On Thu, 2005-08-25 at 07:41 -0600, Jason Johnston wrote:
> Thorsten Scherler wrote:
> > On Wed, 2005-08-24 at 16:45 -0500, Antonio Gallardo wrote:
> >>AFAIK, Thorsten already tried eval() and does not work. :-(
> >>
> > 
> > Yeah, Antonio is right.
> > 
> > The eval() gives "Calling eval() with anything other than a primitive
> > string value will simply return the value. Is this what you intended?". 
> > 
> > ...and that is not what I was intended. ;-)
> 
> Hmm, you're right, I just tried it myself and got the same thing. 
> eval() must be broken in Rhino.
> 
> Another possibility: use the "new Function(string)" constructor to 
> create a function from a string and then call it, for example:
> 
>var evalFunc = new Function("string of JS code to evaluate here");
>evalFunc();
> 
> If you want to pass particular arguments to it you can do that too; more 
> details at
> http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Function#Created_By


Wow, sweet. Thx a million. I will try that and report back. :)

Muchas gracias

salu2
-- 
thorsten

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



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Reinhard Poetz

Jason Johnston wrote:

Thorsten Scherler wrote:


On Wed, 2005-08-24 at 16:45 -0500, Antonio Gallardo wrote:


AFAIK, Thorsten already tried eval() and does not work. :-(



Yeah, Antonio is right.

The eval() gives "Calling eval() with anything other than a primitive
string value will simply return the value. Is this what you intended?".
...and that is not what I was intended. ;-)



Hmm, you're right, I just tried it myself and got the same thing. eval() 
must be broken in Rhino.


Another possibility: use the "new Function(string)" constructor to 
create a function from a string and then call it, for example:


  var evalFunc = new Function("string of JS code to evaluate here");
  evalFunc();


just for the records: which Cocoon version are you guys using?

Please note, that the Rhino version in trunk is *mostly* compatible with Rhino 
version in 2.1 branch.
There are only some some minor issues - see status.xml in trunk to find out the 
details.

You should be able to simply replace rhino.jar in branch with the jar from 
trunk.

--
Reinhard Pötz   Independent Consultant, Trainer & (IT)-Coach 


{Software Engineering, Open Source, Web Applications, Apache Cocoon}

   web(log): http://www.poetz.cc



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Jason Johnston

Thorsten Scherler wrote:

On Wed, 2005-08-24 at 16:45 -0500, Antonio Gallardo wrote:

AFAIK, Thorsten already tried eval() and does not work. :-(



Yeah, Antonio is right.

The eval() gives "Calling eval() with anything other than a primitive
string value will simply return the value. Is this what you intended?". 


...and that is not what I was intended. ;-)


Hmm, you're right, I just tried it myself and got the same thing. 
eval() must be broken in Rhino.


Another possibility: use the "new Function(string)" constructor to 
create a function from a string and then call it, for example:


  var evalFunc = new Function("string of JS code to evaluate here");
  evalFunc();

If you want to pass particular arguments to it you can do that too; more 
details at

http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Function#Created_By


Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Thorsten Scherler
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. 
> > 
> >  form.setAttribute("counter", new java.lang.Integer(0));
> > 
> > 
> > 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
[EMAIL PROTECTED][EMAIL PROTECTED]





Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-25 Thread Thorsten Scherler
On Wed, 2005-08-24 at 16:45 -0500, Antonio Gallardo wrote:
> Jason Johnston wrote:
> 
> >>On Wed, 2005-08-24 at 21:18 +0200, Thorsten Scherler wrote:
> >>
> >>
> >...
> >  
> >
> >>>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?
> >>>  
> >>>
> >
> >Also, have you tried using the eval() JS function?  Seems like that's
> >the simplest way to execute a string.
> >  
> >
> AFAIK, Thorsten already tried eval() and does not work. :-(
> 

Yeah, Antonio is right.

The eval() gives "Calling eval() with anything other than a primitive
string value will simply return the value. Is this what you intended?". 

...and that is not what I was intended. ;-)

salu2
thorsten

> Best Regards,
> 
> Antonio Gallardo
> 
-- 
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
[EMAIL PROTECTED][EMAIL PROTECTED]





Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-24 Thread Antonio Gallardo

Jason Johnston wrote:


On Wed, 2005-08-24 at 21:18 +0200, Thorsten Scherler wrote:
   


...
 


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?
 



Also, have you tried using the eval() JS function?  Seems like that's
the simplest way to execute a string.
 


AFAIK, Thorsten already tried eval() and does not work. :-(

Best Regards,

Antonio Gallardo



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-24 Thread Mark Lundquist


On Aug 24, 2005, at 12:22 PM, 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


Hey, now that is very handy to know! :-)

I had to do this very thing the other day, but for a different 
reason... I had to build an object in flowscript to get handed off to a 
form binding (MultiValueJXPathBinding only knows how to bind to a Java 
Array :-(...).


I did it by building up an ArrayList and then invoking its toArray().  
So there's another way to skin the same cat.


—ml—



Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-24 Thread Jason Johnston
> On Wed, 2005-08-24 at 21:18 +0200, Thorsten Scherler wrote:
...
> > 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?

Also, have you tried using the eval() JS function?  Seems like that's
the simplest way to execute a string.

--Jason




Re: flow - java.util.Object[] {something} causes syntax Error

2005-08-24 Thread Jason Johnston
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. 
> 
>  form.setAttribute("counter", new java.lang.Integer(0));
> 
> 
> 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