Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 23010 invoked from network); 3 Apr 2006 09:47:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Apr 2006 09:47:19 -0000 Received: (qmail 28517 invoked by uid 500); 3 Apr 2006 09:47:07 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 28027 invoked by uid 500); 3 Apr 2006 09:47:05 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 28016 invoked by uid 99); 3 Apr 2006 09:47:05 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Apr 2006 02:47:05 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Apr 2006 02:47:04 -0700 Received: from ajax (localhost.localdomain [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id B54C56ACB1 for ; Mon, 3 Apr 2006 10:46:43 +0100 (BST) Message-ID: <1857779459.1144057603723.JavaMail.jira@ajax> Date: Mon, 3 Apr 2006 10:46:43 +0100 (BST) From: "Rob Berens (JIRA)" To: dev@cocoon.apache.org Subject: [jira] Commented: (COCOON-1811) [PATCH] Flow Script: Allow dynamic loading of JavaScript objects even when scope is locked In-Reply-To: <1124739328.1143110578946.JavaMail.jira@ajax> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ 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