cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <j.heini...@ewerk.com>
Subject Re: [Woody] observations, issues, questions, best practices
Date Tue, 20 Jan 2004 13:05:35 GMT
Christopher Oliver <res1cf5x <at> 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?


Mime
View raw message