You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Rob Berens (JIRA)" <ji...@apache.org> on 2006/03/23 11:42:58 UTC

[jira] Created: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

[PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
------------------------------------------------------------------------------------------

         Key: COCOON-1811
         URL: http://issues.apache.org/jira/browse/COCOON-1811
     Project: Cocoon
        Type: Improvement
  Components: Blocks: Forms  
    Versions: 2.2-dev (Current SVN), 2.1.9-dev (current SVN)    
    Reporter: Rob Berens
    Priority: Minor
 Attachments: FOM_JavaScriptInterpreter.txt

Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.


-------------------------------
function myObject() {                // at this point the current
implementation throws the exception
     // constructor for myObject
}

myObject.prototype.myMethod = function() {
    // implementation of myMethod
}
-------------------------------


from within a script fragment like this one:


-------------------------------
function loadScript() {
    var scriptURI = "determineScriptURIFromRequest";
    cocoon.load(scriptURI);
}
-------------------------------

The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

Posted by "Rob Berens (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1811?page=comments#action_12372949 ] 

Rob Berens commented on COCOON-1811:
------------------------------------

Loading the myObject class in the scope if the loadscript() function would leave us with the serious limitation that the statement:

Object anObject = new myObject()

only makes sense within the loadScript() function.
And therefore upon reuse of that class in another function we have to reload it again.

Note that my original patch is completely in line with the behaviour of the put method for native java classes for which it is also allowed to be created in the global scope at any moment.

> [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
> ------------------------------------------------------------------------------------------
>
>          Key: COCOON-1811
>          URL: http://issues.apache.org/jira/browse/COCOON-1811
>      Project: Cocoon
>         Type: Improvement

>   Components: Blocks: Forms
>     Versions: 2.2-dev (Current SVN), 2.1.9-dev (current SVN)
>     Reporter: Rob Berens
>     Priority: Minor
>  Attachments: FOM_JavaScriptInterpreter.txt
>
> Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.
> -------------------------------
> function myObject() {                // at this point the current
> implementation throws the exception
>      // constructor for myObject
> }
> myObject.prototype.myMethod = function() {
>     // implementation of myMethod
> }
> -------------------------------
> from within a script fragment like this one:
> -------------------------------
> function loadScript() {
>     var scriptURI = "determineScriptURIFromRequest";
>     cocoon.load(scriptURI);
> }
> -------------------------------
> The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1811?page=all ]

Jörg Heinicke reassigned COCOON-1811:
-------------------------------------

    Assignee: Jörg Heinicke

> [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
> ------------------------------------------------------------------------------------------
>
>                 Key: COCOON-1811
>                 URL: http://issues.apache.org/jira/browse/COCOON-1811
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: Blocks: Forms
>    Affects Versions: 2.2-dev (Current SVN), 2.1.9
>            Reporter: Rob Berens
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>         Attachments: 20060409-cocoon-forms-1811
>
>
> Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.
> -------------------------------
> function myObject() {                // at this point the current
> implementation throws the exception
>      // constructor for myObject
> }
> myObject.prototype.myMethod = function() {
>     // implementation of myMethod
> }
> -------------------------------
> from within a script fragment like this one:
> -------------------------------
> function loadScript() {
>     var scriptURI = "determineScriptURIFromRequest";
>     cocoon.load(scriptURI);
> }
> -------------------------------
> The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] Closed: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1811?page=all ]

Jörg Heinicke closed COCOON-1811.
---------------------------------

    Fix Version/s: 2.2-dev (Current SVN)
                   2.1.10-dev (current SVN)
       Resolution: Fixed

Fixed with that patch, but ... if we actually want to prevent variables to be put into global scope, isn't there a possibility to check for it directly instead of "!(value instanceof NativeJavaClass) && !(value instanceof Function)"?

> [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
> ------------------------------------------------------------------------------------------
>
>                 Key: COCOON-1811
>                 URL: http://issues.apache.org/jira/browse/COCOON-1811
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: Blocks: Forms
>    Affects Versions: 2.2-dev (Current SVN), 2.1.9
>            Reporter: Rob Berens
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>             Fix For: 2.2-dev (Current SVN), 2.1.10-dev (current SVN)
>
>         Attachments: 20060409-cocoon-forms-1811
>
>
> Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.
> -------------------------------
> function myObject() {                // at this point the current
> implementation throws the exception
>      // constructor for myObject
> }
> myObject.prototype.myMethod = function() {
>     // implementation of myMethod
> }
> -------------------------------
> from within a script fragment like this one:
> -------------------------------
> function loadScript() {
>     var scriptURI = "determineScriptURIFromRequest";
>     cocoon.load(scriptURI);
> }
> -------------------------------
> The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] Commented: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

Posted by "Jean-Baptiste Quenot (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1811?page=comments#action_12372896 ] 

Jean-Baptiste Quenot commented on COCOON-1811:
----------------------------------------------

Hello, could you please explain what is a "locked scope"?  I could call cocoon.load() from anywhere in the code without problem.

> [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
> ------------------------------------------------------------------------------------------
>
>          Key: COCOON-1811
>          URL: http://issues.apache.org/jira/browse/COCOON-1811
>      Project: Cocoon
>         Type: Improvement

>   Components: Blocks: Forms
>     Versions: 2.2-dev (Current SVN), 2.1.9-dev (current SVN)
>     Reporter: Rob Berens
>     Priority: Minor
>  Attachments: FOM_JavaScriptInterpreter.txt
>
> Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.
> -------------------------------
> function myObject() {                // at this point the current
> implementation throws the exception
>      // constructor for myObject
> }
> myObject.prototype.myMethod = function() {
>     // implementation of myMethod
> }
> -------------------------------
> from within a script fragment like this one:
> -------------------------------
> function loadScript() {
>     var scriptURI = "determineScriptURIFromRequest";
>     cocoon.load(scriptURI);
> }
> -------------------------------
> The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

Posted by "Rob Berens (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1811?page=comments#action_12372922 ] 

Rob Berens commented on COCOON-1811:
------------------------------------

See the internal class ThreadScope in FOM_JavaScriptInterpreter.java. This class has a locked flag to indicate that it is no longer allowed to add global variables to the scope. This is checked in the put(String , Scriptable, Object) method. The lock is set after the global scope of the scripts has been loaded and thus before any methods in the scripts are executed.
Also the statement:
function myObject() 
is implicitly interpreted as the the declaration of the var myObject and therefore the before mentioned put method will throw an exception when a script containing this statement is loaded fromt within the method in another script:

main.js:

cocoon.load("myScript1"); // when called from here no problem.


Alternatively:

main2.js:

function someMethod() {
    cocoon.load("myScript1"); // when called from here exception is thrown
}.


> [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
> ------------------------------------------------------------------------------------------
>
>          Key: COCOON-1811
>          URL: http://issues.apache.org/jira/browse/COCOON-1811
>      Project: Cocoon
>         Type: Improvement

>   Components: Blocks: Forms
>     Versions: 2.2-dev (Current SVN), 2.1.9-dev (current SVN)
>     Reporter: Rob Berens
>     Priority: Minor
>  Attachments: FOM_JavaScriptInterpreter.txt
>
> Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.
> -------------------------------
> function myObject() {                // at this point the current
> implementation throws the exception
>      // constructor for myObject
> }
> myObject.prototype.myMethod = function() {
>     // implementation of myMethod
> }
> -------------------------------
> from within a script fragment like this one:
> -------------------------------
> function loadScript() {
>     var scriptURI = "determineScriptURIFromRequest";
>     cocoon.load(scriptURI);
> }
> -------------------------------
> The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

Posted by "Rob Berens (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1811?page=comments#action_12373770 ] 

Rob Berens commented on COCOON-1811:
------------------------------------

In the original patch FOM_JavaScriptInterpreter.txt there was a parenthesis misplaced. I therefore added the new patch 20060409-cocoon-forms-1811. Please use the latter.

> [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
> ------------------------------------------------------------------------------------------
>
>          Key: COCOON-1811
>          URL: http://issues.apache.org/jira/browse/COCOON-1811
>      Project: Cocoon
>         Type: Improvement

>   Components: Blocks: Forms
>     Versions: 2.2-dev (Current SVN), 2.1.9
>     Reporter: Rob Berens
>     Priority: Minor
>  Attachments: 20060409-cocoon-forms-1811, FOM_JavaScriptInterpreter.txt
>
> Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.
> -------------------------------
> function myObject() {                // at this point the current
> implementation throws the exception
>      // constructor for myObject
> }
> myObject.prototype.myMethod = function() {
>     // implementation of myMethod
> }
> -------------------------------
> from within a script fragment like this one:
> -------------------------------
> function loadScript() {
>     var scriptURI = "determineScriptURIFromRequest";
>     cocoon.load(scriptURI);
> }
> -------------------------------
> The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1811?page=all ]

Jörg Heinicke updated COCOON-1811:
----------------------------------

    Attachment:     (was: FOM_JavaScriptInterpreter.txt)

> [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
> ------------------------------------------------------------------------------------------
>
>                 Key: COCOON-1811
>                 URL: http://issues.apache.org/jira/browse/COCOON-1811
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: Blocks: Forms
>    Affects Versions: 2.2-dev (Current SVN), 2.1.9
>            Reporter: Rob Berens
>            Priority: Minor
>         Attachments: 20060409-cocoon-forms-1811
>
>
> Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.
> -------------------------------
> function myObject() {                // at this point the current
> implementation throws the exception
>      // constructor for myObject
> }
> myObject.prototype.myMethod = function() {
>     // implementation of myMethod
> }
> -------------------------------
> from within a script fragment like this one:
> -------------------------------
> function loadScript() {
>     var scriptURI = "determineScriptURIFromRequest";
>     cocoon.load(scriptURI);
> }
> -------------------------------
> The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] Updated: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

Posted by "Rob Berens (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1811?page=all ]

Rob Berens updated COCOON-1811:
-------------------------------

    Attachment: 20060409-cocoon-forms-1811

> [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
> ------------------------------------------------------------------------------------------
>
>          Key: COCOON-1811
>          URL: http://issues.apache.org/jira/browse/COCOON-1811
>      Project: Cocoon
>         Type: Improvement

>   Components: Blocks: Forms
>     Versions: 2.2-dev (Current SVN), 2.1.9
>     Reporter: Rob Berens
>     Priority: Minor
>  Attachments: 20060409-cocoon-forms-1811, FOM_JavaScriptInterpreter.txt
>
> Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.
> -------------------------------
> function myObject() {                // at this point the current
> implementation throws the exception
>      // constructor for myObject
> }
> myObject.prototype.myMethod = function() {
>     // implementation of myMethod
> }
> -------------------------------
> from within a script fragment like this one:
> -------------------------------
> function loadScript() {
>     var scriptURI = "determineScriptURIFromRequest";
>     cocoon.load(scriptURI);
> }
> -------------------------------
> The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked

Posted by "Jason Johnston (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1811?page=comments#action_12372945 ] 

Jason Johnston commented on COCOON-1811:
----------------------------------------

Would it perhaps make more sense to modify the behavior of cocoon.load() so that it loads the target script not into the top-level scope but instead into the scope from which it is called? So in the original example the myObject class would only be defined within the scope of the loadScript() function. This seems cleaner to me.

> [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked
> ------------------------------------------------------------------------------------------
>
>          Key: COCOON-1811
>          URL: http://issues.apache.org/jira/browse/COCOON-1811
>      Project: Cocoon
>         Type: Improvement

>   Components: Blocks: Forms
>     Versions: 2.2-dev (Current SVN), 2.1.9-dev (current SVN)
>     Reporter: Rob Berens
>     Priority: Minor
>  Attachments: FOM_JavaScriptInterpreter.txt
>
> Currently it is not possible to add variables to the scope of a FOM_JavaScriptInterpreter, unless the scope is not locked yet or when still in the main loading process or when loading native java classes. Therefore it is not possible to dynamically load JavaScript classes like the one below:.
> -------------------------------
> function myObject() {                // at this point the current
> implementation throws the exception
>      // constructor for myObject
> }
> myObject.prototype.myMethod = function() {
>     // implementation of myMethod
> }
> -------------------------------
> from within a script fragment like this one:
> -------------------------------
> function loadScript() {
>     var scriptURI = "determineScriptURIFromRequest";
>     cocoon.load(scriptURI);
> }
> -------------------------------
> The attached patch solves this by allowing also objects of the type org.mozilla.javascript.Function to be loaded into a locked scope.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira