cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Denis" <denis.thie...@aic-info.com>
Subject Re: [Woody] observations, issues, questions, best practices
Date Tue, 20 Jan 2004 13:17:24 GMT
If I do understand well, you used 'var function' but function is a reserved
word for JavaScript ...
You should use your own name for this variable such as func, myFunction or
the like ...

Regards,

Denis

----- Original Message ----- 
From: "Joerg Heinicke" <j.heinicke@ewerk.com>
To: <dev@cocoon.apache.org>
Sent: Tuesday, January 20, 2004 2:05 PM
Subject: Re: [Woody] observations, issues, questions, best practices


> 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