Re: FlowScript Parameters, Re: How to access sitemap parameter within JavaFlow?
Vadim Gritsenko wrote: Sylvain Wallez wrote: Michael Gerzabek wrote: Of course you can do. When you declare a sitemap flow function call like above your flow method must be declared like function myJavaFlowMethod( foo ) { } and a "print( foo );" within this method should show "bar" in your Console. I strongly suggest you *do not use it this way*, as it is highly misleading: are name/value associations whereas JS function parameters are only positional, which means the "foo" you write in the function declaration has absolutely no relation with the "foo" in . ... I've been wanting to remove forbid this for a long time, but didn't knew how to identify JS functions with parameters, in order to issue a proper error message if this buggy construct is used. Looking a bit closer to Rhino, I now found it: NativeFunction has a getArity() method which is the number of parameters. We could then raise an error if getArity() != 0. What do people think? IMHO, write ERROR in the log in 2.1.6, throw exception in 2.1.7, remove any traces of this in 2.2. Too draconian? :) Oh no, sounds very good! Should we start a vote on this? Sylvain -- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
FlowScript Parameters, Re: How to access sitemap parameter within JavaFlow?
Sylvain Wallez wrote: Michael Gerzabek wrote: Of course you can do. When you declare a sitemap flow function call like above your flow method must be declared like function myJavaFlowMethod( foo ) { } and a "print( foo );" within this method should show "bar" in your Console. I strongly suggest you *do not use it this way*, as it is highly misleading: are name/value associations whereas JS function parameters are only positional, which means the "foo" you write in the function declaration has absolutely no relation with the "foo" in . ... I've been wanting to remove forbid this for a long time, but didn't knew how to identify JS functions with parameters, in order to issue a proper error message if this buggy construct is used. Looking a bit closer to Rhino, I now found it: NativeFunction has a getArity() method which is the number of parameters. We could then raise an error if getArity() != 0. What do people think? IMHO, write ERROR in the log in 2.1.6, throw exception in 2.1.7, remove any traces of this in 2.2. Too draconian? :) Vadim
Re: How to access sitemap parameter within JavaFlow?
Stephan Coboos wrote: Sorry, but I don't understand. What do you mean with "It exists in trunk."? See http://wiki.apache.org/cocoon/SubversionMigration?action=highlight&value=subversion. Trunk is the 2.2 development branch.
Re: How to access sitemap parameter within JavaFlow?
That's the problem! The AbstractContinuable contains no method getParameters(): http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/flow/java/AbstractContinuable.html It exists in trunk. Sorry, but I don't understand. What do you mean with "It exists in trunk."? Thank you. Regards Stephan
Re: How to access sitemap parameter within JavaFlow?
IIRC the parameters are set inside the continuation context. If you inherit from AbstractContinuable you should be able to just use getParameters(). That's the problem! The AbstractContinuable contains no method getParameters(): http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/flow/java/AbstractContinuable.html It exists in trunk. -- Torsten
Re: How to access sitemap parameter within JavaFlow?
Hi Torsten, I guess he is after JAVAflow ;-) Yes.You're right! ;-) IIRC the parameters are set inside the continuation context. If you inherit from AbstractContinuable you should be able to just use getParameters(). That's the problem! The AbstractContinuable contains no method getParameters(): http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/flow/java/AbstractContinuable.html Thank you. Regards Stephan
Re: How to access sitemap parameter within JavaFlow?
Torsten Curdt wrote: Sylvain Wallez wrote: Stephan Coboos wrote: Hello, I had asked this question in the users list before but got no answer. So I will try it here. I need to access a sitemap parameter within a JavaFlow class. Is this possible? How can I access the parameter "foo" within the JavaFlow? Well, it's as simple as cocoon.parameters["foo"] !! I guess he is after JAVAflow ;-) Woops, sorry, I've read too quickly :-/ Sylvain -- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Re: How to access sitemap parameter within JavaFlow?
Michael Gerzabek wrote: At 20:49 04.11.2004, you wrote: Hello, I had asked this question in the users list before but got no answer. So I will try it here. I need to access a sitemap parameter within a JavaFlow class. Is this possible? How can I access the parameter "foo" within the JavaFlow? Of course you can do. When you declare a sitemap flow function call like above your flow method must be declared like function myJavaFlowMethod( foo ) { } and a "print( foo );" within this method should show "bar" in your Console. I strongly suggest you *do not use it this way*, as it is highly misleading: are name/value associations whereas JS function parameters are only positional, which means the "foo" you write in the function declaration has absolutely no relation with the "foo" in . Although this isn't a problem with single parameters, this can lead to weird bugs with several parameters. Consider for example: And "function fun(foo, bar)". All is well, and this results in calling fun("foo-value", "bar-value"). But one day someone decides to write: From a sitemap point of view, this makes no difference, as parameters are usually basically a hashmap. But in the particular case of flowscript calls, what I consider a hack transform these name/value pairs in a list of positional parameters. So the result is that it calls fun("bar-value", "foo-value"), which is really not what you expected... This behaviour has been there from day one if the flowscript, and it took some time to find that it was a problem. I've been wanting to remove forbid this for a long time, but didn't knew how to identify JS functions with parameters, in order to issue a proper error message if this buggy construct is used. Looking a bit closer to Rhino, I now found it: NativeFunction has a getArity() method which is the number of parameters. We could then raise an error if getArity() != 0. What do people think? -- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Re: How to access sitemap parameter within JavaFlow?
Sylvain Wallez wrote: Stephan Coboos wrote: Hello, I had asked this question in the users list before but got no answer. So I will try it here. I need to access a sitemap parameter within a JavaFlow class. Is this possible? How can I access the parameter "foo" within the JavaFlow? Well, it's as simple as cocoon.parameters["foo"] !! I guess he is after JAVAflow ;-) IIRC the parameters are set inside the continuation context. If you inherit from AbstractContinuable you should be able to just use getParameters(). HTH cheers -- Torsten
Re: How to access sitemap parameter within JavaFlow?
At 20:49 04.11.2004, you wrote: Hello, I had asked this question in the users list before but got no answer. So I will try it here. I need to access a sitemap parameter within a JavaFlow class. Is this possible? How can I access the parameter "foo" within the JavaFlow? Of course you can do. When you declare a sitemap flow function call like above your flow method must be declared like function myJavaFlowMethod( foo ) { } and a "print( foo );" within this method should show "bar" in your Console. Regards, Michael Thank you a lot! Regards Stephan
Re: How to access sitemap parameter within JavaFlow?
Sylvain Wallez wrote: Stephan Coboos wrote: Hello, I had asked this question in the users list before but got no answer. So I will try it here. I need to access a sitemap parameter within a JavaFlow class. Is this possible? How can I access the parameter "foo" within the JavaFlow? Well, it's as simple as cocoon.parameters["foo"] !! Forgot to say: this also works for , which means you'll have different values for cocoon.parameters after a cocoon.sendPageAndWait. Sylvain -- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Re: How to access sitemap parameter within JavaFlow?
Stephan Coboos wrote: Hello, I had asked this question in the users list before but got no answer. So I will try it here. I need to access a sitemap parameter within a JavaFlow class. Is this possible? How can I access the parameter "foo" within the JavaFlow? Well, it's as simple as cocoon.parameters["foo"] !! Sylvain -- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }