Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 86931 invoked from network); 20 Jan 2004 13:05:44 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 20 Jan 2004 13:05:43 -0000 Received: (qmail 7410 invoked by uid 500); 20 Jan 2004 13:05:37 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 7378 invoked by uid 500); 20 Jan 2004 13:05:37 -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 Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 7364 invoked from network); 20 Jan 2004 13:05:37 -0000 Received: from unknown (HELO main.gmane.org) (80.91.224.249) by daedalus.apache.org with SMTP; 20 Jan 2004 13:05:37 -0000 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AivZZ-0005uq-00 for ; Tue, 20 Jan 2004 14:05:37 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: dev@cocoon.apache.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AivZY-0005ui-00 for ; Tue, 20 Jan 2004 14:05:36 +0100 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AivZY-000347-00 for ; Tue, 20 Jan 2004 14:05:36 +0100 From: Joerg Heinicke Subject: Re: [Woody] observations, issues, questions, best practices Date: Tue, 20 Jan 2004 13:05:35 +0000 (UTC) Lines: 54 Message-ID: References: <4005CCA5.1030409@gmx.de> <400C4254.8000505@verizon.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 217.69.240.162 (Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113) Sender: news X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Christopher Oliver verizon.net> writes: > > 2. When a flow script function is not available (called via woody2.js, > > line 213) I only get a "CascadingRuntimeException: The undefined value > > has no properties." Isn't it possible to give a more exact explanation > > or at least to point to the expression that returns undefined? > > You could change the code to this: > > function woody(form_function, form_definition) { > var form = new Form(cocoon.parameters["form-definition"]); > > var args = [form]; > > // set the binding on the form if there's any > var bindingURI = cocoon.parameters["bindingURI"]; > if (bindingURI != null) > form.createBinding(bindingURI); > var funName = cocoon.parameters["function"]; > var fun = this[funName]; > if (!fun) { > throw "Function \\""+funName +"\\" is not defined"; > } else if (!(fun instanceof Function)) { > throw "\\""+funName +"\\" is not a function"; > } > fun.apply(this, args); > } Thanks very much, indeed such helpers I appreciate very much as I have not much experience with the object orientation of JavaScript. What about adding it to Woody in CVS? But I came across another strange issue with the flowscript. Your suggested this[funName] does not work for me, what appeared already yesterday (before your post) to me. While the woody code (like above) works, my does not: 05: var formtype = cocoon.parameters["formtype"]; ... 19: var functionName = "display" + formtype; 20: print(functionName); 21: var function = this[functionName]; SyntaxError: missing variable name (file:/C:/Projekte/cocoon-2.1/build/webapp/samples/erak/flow/form.js; line 21) The print in line 20 is not executed, another print before writing just 'starting form handling' is neither, so it's something like preparsing. At that time functionName is of course not available. Changing the above line 19 - 21 to just var function = this["display" + formtype]; works. Can you tell me why? Joerg PS: We should not need form_function and form_definition as parameters to the woody function, should we?