Re: call a function not in global object in map:call

2007-01-14 Thread Mark Lundquist


On Jan 13, 2007, at 11:58 PM, Rice Yeh wrote:

Then, should I report this problem to JIRA. Or there is other concern 
not to include this function in trunk?


I'll do it, 'cause I can supply my svn diff as a patch... :-)

—ml—



Re: call a function not in global object in map:call

2007-01-13 Thread Rice Yeh

Hi,
 Do you have an example about how to pass the namespace object? I use it
like the following:

   map:call function=xs.party.use
   map:parameter name=flowpath value={0}/
   /map:call

, but it does not work.

Regards,
Rice




On 1/11/07, Mark Lundquist [EMAIL PROTECTED] wrote:



On Jan 11, 2007, at 6:08 AM, Mark Lundquist wrote:


 On Jan 11, 2007, at 1:36 AM, Rice Yeh wrote:

 Does anyone know whether the function mentioned in
 http://www.mail-archive.com/dev@cocoon.apache.org/msg47930.html works
 now?

 phooey... I forgot to submit this patch to JIRA :-(.  Doing it now...

Never mind! :-)

I never submitted it to JIRA because I didn't need to.  Jeremy Quinn
asked for this feature, and that reminded me how it was something I had
wanted also, so I made a patch and emailed it so he could try it out
—I think I didn't JIRA it at first because I wasn't sure if the
committers would think it was the right way to implement it (not that I
think there's anything wrong with it :-).

Anyway, it turns out that Jeremy committed this along with some of his
other changes.  So this made it into the 2.1.10 release, and it's also
in trunk.

—ml—




Re: call a function not in global object in map:call

2007-01-13 Thread Mark Lundquist


On Jan 13, 2007, at 2:21 AM, Rice Yeh wrote:

  Do you have an example about how to pass the namespace object? I use 
it like the following:


                map:call function=xs.party.use
                    map:parameter name=flowpath value={0}/
                /map:call

, but it does not work.


That should work if there is a function xs.party.use() at the global 
scope.  E.g., something like:


var xs = {};
.
.
.
xs.party = {};
.
.
.
xs.party.use =
function() {
.
.
};

What do you mean by it does not work?

cheers,
—ml—



Re: call a function not in global object in map:call

2007-01-13 Thread Rice Yeh

The fun is not gotten by the code at line 591 in
FOM_JavaScriptInterpreter.java
  Object fun = ScriptableObject.getProperty(thrScope, funName);

, so ResourceNotFoundException is thrown at its following code.
   if (fun == Scriptable.NOT_FOUND) {
   throw new ResourceNotFoundException(Function
\javascript: + funName + ()\ not found);
   }

By studying the source code, I do not think *call a function not in global
object in map:call  *is supported in trunk because function is still
gotten in thrScope. Am I right?
*
Rice
*


On 1/13/07, Mark Lundquist [EMAIL PROTECTED] wrote:



On Jan 13, 2007, at 2:21 AM, Rice Yeh wrote:

 Do you have an example about how to pass the namespace object? I use
 it like the following:

 map:call function=xs.party.use
 map:parameter name=flowpath value={0}/
 /map:call

 , but it does not work.

That should work if there is a function xs.party.use() at the global
scope.  E.g., something like:

var xs = {};
.
.
.
xs.party = {};
.
.
.
xs.party.use =
function() {
.
.
};

What do you mean by it does not work?

cheers,
—ml—




Re: call a function not in global object in map:call

2007-01-13 Thread Mark Lundquist


On Jan 13, 2007, at 11:11 AM, Rice Yeh wrote:

By studying the source code, I do not think call a function not in 
global object in map:call  is supported in trunk because function 
is still gotten in thrScope. Am I right?


I don't think so.  What scope do you think it should compile in?

—ml—



Re: call a function not in global object in map:call

2007-01-13 Thread Mark Lundquist


I just tested like this:

var flowTest =
{
foo: {}
}

flowTest.foo.bar =
function() {
print (Hello from flowTest());
};

...and like this...

map:call function=flowTest.foo.bar /

and it worked fine...

???
—ml—



Re: call a function not in global object in map:call

2007-01-13 Thread Mark Lundquist


On Jan 13, 2007, at 1:41 PM, Mark Lundquist wrote:



I just tested like this:
[...snip..]
and it worked fine...


Note, actually I tested in 2.1.11(dev), not trunk, because that was 
more convenient ATM... but it's the exact same code in 
FOM_JavascriptInterpreter.


cheers,
—ml—



Re: call a function not in global object in map:call

2007-01-13 Thread Mark Lundquist


On Jan 13, 2007, at 11:11 AM, Rice Yeh wrote:

The fun is not gotten by the code at line 591 in 
FOM_JavaScriptInterpreter.java

   Object fun = ScriptableObject.getProperty(thrScope, funName);


hold on, I did not read the above very carefully the first time, 
sorry... :-/


By studying the source code, I do not think call a function not in 
global object in map:call  is supported in trunk


OK, the code you excerpted above is not from trunk HEAD (or 
BRANCH_2_1_X HEAD either.  What version are you looking at there, 
anyway?  The current versions have my change, which looks like this:


// Resolve function name
//
Object fun;
try {
fun = context.compileString (funName, null, 1, 
null)

 .exec (context, thrScope);
} catch (EcmaError ee) {
   throw new ResourceNotFoundException (
Function \javascript: + funName + ()\ 
not found

);
}

HTH,
—ml—



Re: call a function not in global object in map:call

2007-01-13 Thread Rice Yeh

I am sure my code is from trunk. It is at version revision 494774. Please
have a look at
https://svn.apache.org/repos/asf/cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
.
Is the code you add in it?

Rice

On 1/14/07, Mark Lundquist [EMAIL PROTECTED] wrote:



On Jan 13, 2007, at 11:11 AM, Rice Yeh wrote:

 The fun is not gotten by the code at line 591 in
 FOM_JavaScriptInterpreter.java
 Object fun = ScriptableObject.getProperty(thrScope, funName);

hold on, I did not read the above very carefully the first time,
sorry... :-/

 By studying the source code, I do not think call a function not in
 global object in map:call  is supported in trunk

OK, the code you excerpted above is not from trunk HEAD (or
BRANCH_2_1_X HEAD either.  What version are you looking at there,
anyway?  The current versions have my change, which looks like this:

 // Resolve function name
 //
 Object fun;
 try {
 fun = context.compileString (funName, null, 1,
null)
  .exec (context, thrScope);
 } catch (EcmaError ee) {
throw new ResourceNotFoundException (
 Function \javascript: + funName + ()\
not found
 );
 }

HTH,
—ml—





Re: call a function not in global object in map:call

2007-01-13 Thread Rice Yeh

And have a check at
https://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
.

It is sured that this function is not in trunk.

Rice

On 1/14/07, Rice Yeh [EMAIL PROTECTED] wrote:


I am sure my code is from trunk. It is at version revision 494774. Please
have a look at
https://svn.apache.org/repos/asf/cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
.
Is the code you add in it?

Rice

On 1/14/07, Mark Lundquist [EMAIL PROTECTED] wrote:


 On Jan 13, 2007, at 11:11 AM, Rice Yeh wrote:

  The fun is not gotten by the code at line 591 in
  FOM_JavaScriptInterpreter.java
  Object fun = ScriptableObject.getProperty(thrScope, funName);

 hold on, I did not read the above very carefully the first time,
 sorry... :-/

  By studying the source code, I do not think call a function not in
  global object in map:call  is supported in trunk

 OK, the code you excerpted above is not from trunk HEAD (or
 BRANCH_2_1_X HEAD either.  What version are you looking at there,
 anyway?  The current versions have my change, which looks like this:

  // Resolve function name
  //
  Object fun;
  try {
  fun = context.compileString (funName, null, 1,
 null)
   .exec (context, thrScope);
  } catch (EcmaError ee) {
 throw new ResourceNotFoundException (
  Function \javascript: + funName + ()\
 not found
  );
  }

 HTH,
 —ml—






Re: call a function not in global object in map:call

2007-01-13 Thread Mark Lundquist


On Jan 13, 2007, at 8:02 PM, Rice Yeh wrote:


It is sured that this function is not in trunk.


Bah, you are right, sorry, my bad... so I guess it is in BRANCH_2_1_X 
but not in trunk yet.  It turns out that I had this file checked out in 
trunk and was looking at my own checked-out version.


—ml—



Re: call a function not in global object in map:call

2007-01-13 Thread Rice Yeh

Then, should I report this problem to JIRA. Or there is other concern not to
include this function in trunk?

Regards,
Rice

On 1/14/07, Mark Lundquist [EMAIL PROTECTED] wrote:



On Jan 13, 2007, at 8:02 PM, Rice Yeh wrote:

 It is sured that this function is not in trunk.

Bah, you are right, sorry, my bad... so I guess it is in BRANCH_2_1_X
but not in trunk yet.  It turns out that I had this file checked out in
trunk and was looking at my own checked-out version.

—ml—




call a function not in global object in map:call

2007-01-11 Thread Rice Yeh

Hi,
 Does anyone know whether the function mentioned in
http://www.mail-archive.com/dev@cocoon.apache.org/msg47930.html works now?

Rice


Re: call a function not in global object in map:call

2007-01-11 Thread Mark Lundquist


On Jan 11, 2007, at 1:36 AM, Rice Yeh wrote:

  Does anyone know whether the function mentioned in 
http://www.mail-archive.com/dev@cocoon.apache.org/msg47930.html works 
now?


phooey... I forgot to submit this patch to JIRA :-(.  Doing it now...

—ml—



Re: call a function not in global object in map:call

2007-01-11 Thread Mark Lundquist


On Jan 11, 2007, at 6:08 AM, Mark Lundquist wrote:



On Jan 11, 2007, at 1:36 AM, Rice Yeh wrote:

  Does anyone know whether the function mentioned in 
http://www.mail-archive.com/dev@cocoon.apache.org/msg47930.html works 
now?


phooey... I forgot to submit this patch to JIRA :-(.  Doing it now...


Never mind! :-)

I never submitted it to JIRA because I didn't need to.  Jeremy Quinn 
asked for this feature, and that reminded me how it was something I had 
wanted also, so I made a patch and emailed it so he could try it out 
— I think I didn't JIRA it at first because I wasn't sure if the 
committers would think it was the right way to implement it (not that I 
think there's anything wrong with it :-).


Anyway, it turns out that Jeremy committed this along with some of his 
other changes.  So this made it into the 2.1.10 release, and it's also 
in trunk.


—ml—



Re: call a function not in global object in map:call

2006-11-19 Thread Jeremy Quinn

Hi Guys

I am trying this patch in 2_1_10-dev and it does not compile :

compile-core:
Compiling 1 source file to /Users/Shared/Development/Checkouts/Apache/ 
Cocoon/Cocoon_2_1_X/build/cocoon/classes
/Users/Shared/Development/Checkouts/Apache/Cocoon/Cocoon_2_1_X/src/ 
java/org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java:750: cannot find symbol
symbol  : method compileString 
(java.lang.String,nulltype,int,nulltype)

location: class org.mozilla.javascript.Context
fun = context.compileString (funName, null,  
1, null).exec (context, thrScope);

 ^

The method signature looks correct according to this:
	http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/ 
Context.html


Is this another possible issue with our customised Rhino ?

regards Jeremy

On 16 Nov 2006, at 16:56, Vadim Gritsenko wrote:


Jason Johnston wrote:

Mark Lundquist wrote:


On Nov 13, 2006, at 10:14 PM, Rice Yeh wrote:


Thank you. Will this patch go into the trunk eventually?


It's up to the committers.  I'm sure they will take a look at it  
and decide if they think it's a good way.
I can't vouch for the patch, but I'll definitely give my +1 on  
having this feature.  It's something I've wanted for a while, just  
never got around to submitting a request.


Even though same can be achieved in flow itself, it probably is a  
good usability feature so it worth adding it... WDYT?


Vadim


But if you want to try a trunk version, here it is.  I couldn't  
get trunk to build, so you might have to fix this if it doesn't  
compile :-/


cheers,
—ml—

==
--- blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/ 
org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java (revision 474689)
+++ blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/ 
org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java (working copy)

@@ -593,11 +593,19 @@
 }
 cocoon.setParameters(parameters);

-Object fun = ScriptableObject.getProperty 
(thrScope, funName);

-if (fun == Scriptable.NOT_FOUND) {
-throw new ResourceNotFoundException 
(Function \javascript: + funName + ()\ not found);

+// Resolve function name
+//
+Object fun;
+try {
+fun = context.compileString (funName,  
null, 1, null)

+ .exec (context, thrScope);
+} catch (EcmaError ee) {
+   throw new ResourceNotFoundException (
+Function \javascript: + funName +  
()\ not found

+);
 }






smime.p7s
Description: S/MIME cryptographic signature


Re: call a function not in global object in map:call

2006-11-19 Thread Mark Lundquist


On Nov 19, 2006, at 7:11 AM, Jeremy Quinn wrote:


Hi Guys

I am trying this patch in 2_1_10-dev and it does not compile :


Jeremy, thanks for trying the patch.  Sorry for the bad code, I need to  
get up on the learning curve of building trunk :-/  Anyway, see  
below...



compile-core:
Compiling 1 source file to  
/Users/Shared/Development/Checkouts/Apache/Cocoon/Cocoon_2_1_X/build/ 
cocoon/classes
/Users/Shared/Development/Checkouts/Apache/Cocoon/Cocoon_2_1_X/src/ 
java/org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java:750: cannot find symbol
symbol  : method  
compileString(java.lang.String,nulltype,int,nulltype)

location: class org.mozilla.javascript.Context
fun = context.compileString (funName, null, 1,  
null).exec (context, thrScope);

 ^

The method signature looks correct according to this:
	http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/ 
Context.html


Is this another possible issue with our customised Rhino ?


Yeah, I think it must be.  I knew that trunk uses a newer Rhino than  
2.1.10, and I expected the API to be as described in your reference  
above, but I guess it is not.  To fix this, just use the old  
compileReader() method instead.  I think you can probably just use the  
code from the 2.1.10 version of my patch... see earlier in that thread  
(but watch out, I posted two versions of the patch, and the first one  
was BAD... use the second).


Since there has been no outcry of horror and disgust at my patch, I  
think I will go ahead and JIRA it up :-)


My first attempt at this (before any of the patches I posted) was to  
iterate through the path, e.g. some.package.has.my.function, and  
drill down through the object graph with getProperty().  I couldn't  
figure out how to make that work, because getProperty needs a  
ScriptableObject but it only returns a plain old Object.  Whatever :-).  
 So then I thought, let's just Rhino do it, which seemed a little  
hacky at the time, but maybe no! :-).  It seems safe — if Rhino doesn't  
like anything, then you always just get the function not found error.


Have fun,
—ml—



Re: call a function not in global object in map:call

2006-11-19 Thread Jeremy Quinn

Hi Mark

Many thanks for getting back to me so quickly.

It compiled fine, and it seems to work with both namespaced and non- 
namespaced JavaScript.


regards Jeremy


On 13 Nov 2006, at 03:14, Mark Lundquist wrote:



On Nov 12, 2006, at 1:31 AM, I wrote:


[...snip] Here's a patch you can try.  [...snip]


Do'h. my bad!  I didn't realize when I sent you that diff that I  
was in the middle of changing the code from its first working  
form.   Sorry for going off half cocked; here's a version that  
actually works... :-/


===
--- src/java/org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java(revision 472699)
+++ src/java/org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java(working copy)

@@ -69,6 +69,7 @@
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PushbackInputStream;
+import java.io.StringReader;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -744,9 +745,17 @@
 }
 cocoon.setParameters(parameters);

-Object fun = ScriptableObject.getProperty 
(thrScope, funName);

-if (fun == Scriptable.NOT_FOUND) {
-throw new ResourceNotFoundException 
(Function \javascript: + funName + ()\ not found);

+// Resolve function name
+//
+Object fun;
+try {
+fun = context.compileReader (
+thrScope, new StringReader  
(funName), null, 1, null

+).exec (context, thrScope);
+} catch (EcmaError ee) {
+   throw new ResourceNotFoundException (
+Function \javascript: + funName +  
()\ not found

+);
 }

Cheers,
—ml—





smime.p7s
Description: S/MIME cryptographic signature


Re: call a function not in global object in map:call

2006-11-19 Thread Mark Lundquist


On Nov 19, 2006, at 10:38 AM, Jeremy Quinn wrote:


Hi Mark

Many thanks for getting back to me so quickly.


You're welcome :-).

Normally I don't do this on Sunday... but today I ditched church to 
work on my med school applications, so I am home.


So, why am I fooling around with Cocoon, then?  Procrastination, I 
guess :-/.


Anyway -- could you do me a quick favor and paste me an svn diff of 
this file, taken from the context of trunk root?  That will become my 
patch :-).  I'm creating the JIRA issue right now, and I don't want to 
goof and submit bad code... :-/


It compiled fine, and it seems to work with both namespaced and 
non-namespaced JavaScript.


Glad to hear it :-)

cheers,
—ml—
 


Re: call a function not in global object in map:call

2006-11-19 Thread Jeremy Quinn


On 19 Nov 2006, at 18:45, Mark Lundquist wrote:



On Nov 19, 2006, at 10:38 AM, Jeremy Quinn wrote:


Hi Mark

Many thanks for getting back to me so quickly.


You're welcome :-).

Normally I don't do this on Sunday... but today I ditched church to  
work on my med school applications, so I am home.


So, why am I fooling around with Cocoon, then?  Procrastination, I  
guess :-/.


Anyway -- could you do me a quick favor and paste me an svn diff  
of this file, taken from the context of trunk root?  That will  
become my patch :-).  I'm creating the JIRA issue right now, and I  
don't want to goof and submit bad code... :-/


I'd love to help, but I am not running trunk at all at the moment.
This situation should change late next week.

I hope to commit this change to BRANCH_2_1_X shortly.
Once this chunk of work (upload progress bar support) is completed in  
there, I will be adding it all to trunk (along with your patch) .  
if everything works out .


It compiled fine, and it seems to work with both namespaced and  
non-namespaced JavaScript.


Glad to hear it :-)


Many thanks for your help !!

regards Jeremy



smime.p7s
Description: S/MIME cryptographic signature


Re: call a function not in global object in map:call

2006-11-14 Thread Mark Lundquist


On Nov 13, 2006, at 10:14 PM, Rice Yeh wrote:


Thank you. Will this patch go into the trunk eventually?


It's up to the committers.  I'm sure they will take a look at it and  
decide if they think it's a good way.


But if you want to try a trunk version, here it is.  I couldn't get  
trunk to build, so you might have to fix this if it doesn't compile :-/


cheers,
—ml—

==
---  
blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/ 
apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java (revision 474689)
+++  
blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/ 
apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java (working copy)

@@ -593,11 +593,19 @@
 }
 cocoon.setParameters(parameters);

-Object fun =  
ScriptableObject.getProperty(thrScope, funName);

-if (fun == Scriptable.NOT_FOUND) {
-throw new ResourceNotFoundException(Function  
\javascript: + funName + ()\ not found);

+// Resolve function name
+//
+Object fun;
+try {
+fun = context.compileString (funName, null, 1,  
null)

+ .exec (context, thrScope);
+} catch (EcmaError ee) {
+   throw new ResourceNotFoundException (
+Function \javascript: + funName + ()\  
not found

+);
 }



Re: call a function not in global object in map:call

2006-11-14 Thread Jason Johnston

Mark Lundquist wrote:


On Nov 13, 2006, at 10:14 PM, Rice Yeh wrote:


Thank you. Will this patch go into the trunk eventually?


It's up to the committers.  I'm sure they will take a look at it and 
decide if they think it's a good way.


I can't vouch for the patch, but I'll definitely give my +1 on having 
this feature.  It's something I've wanted for a while, just never got 
around to submitting a request.



But if you want to try a trunk version, here it is.  I couldn't get 
trunk to build, so you might have to fix this if it doesn't compile :-/


cheers,
—ml—

==
--- 
blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java 
(revision 474689)
+++ 
blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java 
(working copy)

@@ -593,11 +593,19 @@
 }
 cocoon.setParameters(parameters);

-Object fun = ScriptableObject.getProperty(thrScope, 
funName);

-if (fun == Scriptable.NOT_FOUND) {
-throw new ResourceNotFoundException(Function 
\javascript: + funName + ()\ not found);

+// Resolve function name
+//
+Object fun;
+try {
+fun = context.compileString (funName, null, 1, 
null)

+ .exec (context, thrScope);
+} catch (EcmaError ee) {
+   throw new ResourceNotFoundException (
+Function \javascript: + funName + ()\ 
not found

+);
 }





Re: call a function not in global object in map:call

2006-11-13 Thread Rice Yeh
Thank you. Will this patch go into the trunk eventually?RiceOn 11/13/06, Mark Lundquist [EMAIL PROTECTED]
 wrote:On Nov 12, 2006, at 1:31 AM, I wrote: [...snip] Here's a patch you can try.[...snip]
Do'h. my bad!I didn't realize when I sent you that diff that I was inthe middle of changing the code from its first working form. Sorryfor going off half cocked; here's a version that actually works... :-/
===---src/java/org/apache/cocoon/components/flow/_javascript_/fom/FOM_JavaScriptInterpreter.java(revision 472699)+++src/java/org/apache/cocoon/components/flow/_javascript_/fom/
FOM_JavaScriptInterpreter.java(working copy)@@ -69,6 +69,7 @@import java.io.InputStreamReader;import java.io.OutputStream;import java.io.PushbackInputStream;+import java.io.StringReader;
import java.io.Reader;import java.util.ArrayList;import java.util.HashMap;@@ -744,9 +745,17 @@}cocoon.setParameters(parameters);-Object fun =
ScriptableObject.getProperty(thrScope, funName);-if (fun == Scriptable.NOT_FOUND) {-throw new ResourceNotFoundException(Function\_javascript_: + funName + ()\ not found);
+// Resolve function name+//+Object fun;+try {+fun = context.compileReader (+thrScope, new StringReader
(funName), null, 1, null+).exec (context, thrScope);+} catch (EcmaError ee) {+ throw new ResourceNotFoundException (+Function \_javascript_: + funName + ()\
not found+);}Cheers,—ml—


Re: call a function not in global object in map:call

2006-11-12 Thread Mark Lundquist


On Nov 11, 2006, at 9:16 AM, Rice Yeh wrote:


Hi,
  It seems for now the function attribute in map:call must be a  
function in the global object. I think it might be better if this  
function could be within a scope object because our project groups all  
javascript objects like java packages (or just like what dojo does).


Agreed.

Here's a patch you can try.  I couldn't figure out how to do it the  
real way, so... this way feels kind of sleazy, but it works :-)


Index:  
src/java/org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java

===
---  
src/java/org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java(revision 472699)
+++  
src/java/org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java(working copy)

@@ -69,6 +69,7 @@
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PushbackInputStream;
+import java.io.StringReader;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -744,9 +745,15 @@
 }
 cocoon.setParameters(parameters);

-Object fun =  
ScriptableObject.getProperty(thrScope, funName);

-if (fun == Scriptable.NOT_FOUND) {
-throw new ResourceNotFoundException(Function  
\javascript: + funName + ()\ not found);

+try {
+final Object fun =
+context.compileReader (
+thrScope, new StringReader  
(funName), null, 1, null

+).exec (context, thrScope);
+} catch (EcmaError ee) {
+   throw new ResourceNotFoundException (
+Function \javascript: + funName + ()\  
not found

+);
 }

If some other Cocoon developers think this is not too lame :-), then I  
will make it official and fire up a JIRA issue.


There are more javascript codes than java codes in our project, so  
goruping them in different naming spaces is needed. Cocoon itself is a  
good environment for easily javascript coding at the server side with  
its flowscript and continuation.


Yes :-)

However, it seems not that care about naming space at javascript code  
itself. Maybe some ideas from dojo can be borrowed here. Like dojo has  
dojo naming space, cocoon has cocoon naming space, and within cocoon,  
there are cocoon.flow, cocoon.flow.continuation,...


I agree, Cocoon's own Javascript style is kind of flat that way.

—ml—



Re: call a function not in global object in map:call

2006-11-12 Thread Mark Lundquist


On Nov 12, 2006, at 1:31 AM, I wrote:


[...snip] Here's a patch you can try.  [...snip]


Do'h. my bad!  I didn't realize when I sent you that diff that I was in  
the middle of changing the code from its first working form.   Sorry  
for going off half cocked; here's a version that actually works... :-/


===
---  
src/java/org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java(revision 472699)
+++  
src/java/org/apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java(working copy)

@@ -69,6 +69,7 @@
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PushbackInputStream;
+import java.io.StringReader;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -744,9 +745,17 @@
 }
 cocoon.setParameters(parameters);

-Object fun =  
ScriptableObject.getProperty(thrScope, funName);

-if (fun == Scriptable.NOT_FOUND) {
-throw new ResourceNotFoundException(Function  
\javascript: + funName + ()\ not found);

+// Resolve function name
+//
+Object fun;
+try {
+fun = context.compileReader (
+thrScope, new StringReader  
(funName), null, 1, null

+).exec (context, thrScope);
+} catch (EcmaError ee) {
+   throw new ResourceNotFoundException (
+Function \javascript: + funName + ()\  
not found

+);
 }

Cheers,
—ml—



call a function not in global object in map:call

2006-11-11 Thread Rice Yeh
Hi, It seems for now the function attribute in map:call must be a function in the global object. I think it might be better if this function could be within a scope object because our project groups all _javascript_ objects like java packages (or just like what dojo does). There are more _javascript_ codes than java codes in our project, so goruping them in different naming spaces is needed. Cocoon itself is a good environment for easily _javascript_ coding at the server side with its flowscript and continuation. However, it seems not that care about naming space at _javascript_ code itself. Maybe some ideas from dojo can be borrowed here. Like dojo has dojo naming space, cocoon has cocoon naming space, and within cocoon, there are 
cocoon.flow, cocoon.flow.continuation,...Rice