You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stephan Coboos <cr...@gmx.net> on 2004/11/04 20:49:49 UTC

How to access sitemap parameter within JavaFlow?

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?

<map:call function="myJavaFlowMethod">
   <map:parameter name="foo" value="bar"/>
</map:call>

How can I access the parameter "foo" within the JavaFlow?

Thank you a lot!

Regards
Stephan


Re: How to access sitemap parameter within JavaFlow?

Posted by Sylvain Wallez <sy...@apache.org>.
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?
>>
>> <map:call function="myJavaFlowMethod">
>>   <map:parameter name="foo" value="bar"/>
>> </map:call>
>>
>> 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 <map:call continuation="">, 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?

Posted by Ralph Goers <Ra...@dslextreme.com>.
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?

Posted by Stephan Coboos <cr...@gmx.net>.
>> 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?

Posted by Torsten Curdt <tc...@apache.org>.
>> 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?

Posted by Stephan Coboos <cr...@gmx.net>.
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?

Posted by Sylvain Wallez <sy...@apache.org>.
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?
>>>
>>> <map:call function="myJavaFlowMethod">
>>>   <map:parameter name="foo" value="bar"/>
>>> </map:call>
>>>
>>> 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?

Posted by Torsten Curdt <tc...@apache.org>.
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?
>>
>> <map:call function="myJavaFlowMethod">
>>   <map:parameter name="foo" value="bar"/>
>> </map:call>
>>
>> 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?

Posted by Sylvain Wallez <sy...@apache.org>.
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?
>
> <map:call function="myJavaFlowMethod">
>   <map:parameter name="foo" value="bar"/>
> </map:call>
>
> 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 }


Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On 9 Nov 2004, at 13:38, Vadim Gritsenko wrote:

> Hi Guys,
>
> As discussed before, and several times already, it is time to phase 
> out "feature" of passing parameters from the sitemap into flowscript 
> as positioned function parameters:
>
>   function myflow (a, b, c) {
>       ...
>   }
>
> Because this syntax relies on order of <map:parameter/> elements in 
> the sitemap but not names of the parameters. This syntax is replaced 
> with non-ambigous:
>
>   function myflow () {
>       var a = cocoon.parameters.a;
>       ...
>   }
>
> Proposed phase out plan is:
>
>   1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>      syntax is detected.
>   2. Throw exception in 2.1.7 when usage of deprecated syntax
>      is detected.
>   3. Completely remove support of deprecated syntax in 2.2.
>
>
> Please cast your votes.

+1 to all

regards Jeremy

--------------------------------------------------------

                   If email from this address is not signed
                                 IT IS NOT FROM ME

                         Always check the label, folks !!!!!
--------------------------------------------------------


Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Giacomo Pati <gi...@apache.org>.
On Tue, 9 Nov 2004, Vadim Gritsenko wrote:

> Proposed phase out plan is:
>
> 1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>   syntax is detected.
> 2. Throw exception in 2.1.7 when usage of deprecated syntax
>   is detected.
> 3. Completely remove support of deprecated syntax in 2.2.

Make sense. +1 to all

-- 
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com

Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 9 nov. 04, à 14:38, Vadim Gritsenko a écrit :

> ...Proposed phase out plan is:
>
>   1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>      syntax is detected.
>   2. Throw exception in 2.1.7 when usage of deprecated syntax
>      is detected.
>   3. Completely remove support of deprecated syntax in 2.2.

+1

-Bertrand

Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Antonio Gallardo wrote:
> Vadim Gritsenko dijo:
> 
>>Proposed phase out plan is:
>>
>>   1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>>      syntax is detected.
>>   2. Throw exception in 2.1.7 when usage of deprecated syntax
>>      is detected.
>>   3. Completely remove support of deprecated syntax in 2.2.
> 
> 
> Means that we need to rewrite all the old code, but +1. Seems more
> "natural" to me.

You should not used these function arguments in a first place... I did not! :)

Vadim

Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Antonio Gallardo <ag...@agssa.net>.
Vadim Gritsenko dijo:
> Proposed phase out plan is:
>
>    1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>       syntax is detected.
>    2. Throw exception in 2.1.7 when usage of deprecated syntax
>       is detected.
>    3. Completely remove support of deprecated syntax in 2.2.

Means that we need to rewrite all the old code, but +1. Seems more
"natural" to me.

Best Regards,

Antonio Gallardo


Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Vadim Gritsenko wrote:
> Hi Guys,
> 
> As discussed before, and several times already, it is time to phase out 
> "feature" of passing parameters from the sitemap into flowscript as 
> positioned function parameters:
> 
>   function myflow (a, b, c) {
>       ...
>   }
> 
> Because this syntax relies on order of <map:parameter/> elements in the 
> sitemap but not names of the parameters. This syntax is replaced with 
> non-ambigous:
> 
>   function myflow () {
>       var a = cocoon.parameters.a;
>       ...
>   }
> 
> Proposed phase out plan is:
> 
>   1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>      syntax is detected.
>   2. Throw exception in 2.1.7 when usage of deprecated syntax
>      is detected.
>   3. Completely remove support of deprecated syntax in 2.2.
> 
> 
> Please cast your votes.
> 
> 
> Vadim
+1 to all

-- 
Leszek Gawron


Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Tony Collen <co...@umn.edu>.
Sylvain Wallez wrote:

> Vadim Gritsenko wrote:
>> Proposed phase out plan is:
>>
>>   1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>>      syntax is detected.
>>   2. Throw exception in 2.1.7 when usage of deprecated syntax
>>      is detected.
>>   3. Completely remove support of deprecated syntax in 2.2.
>>
>>
>> Please cast your votes.
> 
> For those who haven't followed the discussion, the problem is explained 
> here: http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=109960611029412&w=2

 From Sylvain's message:

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.

+1 as long as we don't lose the all-out ability to write functions with 
parameters (which I don't think will happen, will it?), just to turn off 
the positional-parameter functionality between flow and sitemap.

Sorry for the bad English, I just woke up :)

Tony

[RESULT][VOTE] Remove FlowScript Function Parameters Support

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Sylvain Wallez wrote:
> Vadim Gritsenko wrote:
> 
>> Proposed phase out plan is:
>>
>>   1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>>      syntax is detected.

Done.


>>   2. Throw exception in 2.1.7 when usage of deprecated syntax
>>      is detected.

Has to be done post 2.1.6.


>>   3. Completely remove support of deprecated syntax in 2.2.

Done.

Vadim

Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Torsten Curdt <tc...@apache.org>.
Sylvain Wallez wrote:
> Vadim Gritsenko wrote:
> 
>> Hi Guys,
>>
>> As discussed before, and several times already, it is time to phase 
>> out "feature" of passing parameters from the sitemap into flowscript 
>> as positioned function parameters:
>>
>>   function myflow (a, b, c) {
>>       ...
>>   }

I am not sure if removing the parameters completely
is the best way ...but the order bugged me from day
one of flowscipt.

so +1 from me
--
Torsten

Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Sylvain Wallez <sy...@apache.org>.
Vadim Gritsenko wrote:

> Hi Guys,
>
> As discussed before, and several times already, it is time to phase 
> out "feature" of passing parameters from the sitemap into flowscript 
> as positioned function parameters:
>
>   function myflow (a, b, c) {
>       ...
>   }
>
> Because this syntax relies on order of <map:parameter/> elements in 
> the sitemap but not names of the parameters. This syntax is replaced 
> with non-ambigous:
>
>   function myflow () {
>       var a = cocoon.parameters.a;
>       ...
>   }
>
> Proposed phase out plan is:
>
>   1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>      syntax is detected.
>   2. Throw exception in 2.1.7 when usage of deprecated syntax
>      is detected.
>   3. Completely remove support of deprecated syntax in 2.2.
>
>
> Please cast your votes.


+1.

For those who haven't followed the discussion, the problem is explained 
here: http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=109960611029412&w=2

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Re: [VOTE] Remove FlowScript Function Parameters Support

Posted by Reinhard Poetz <re...@apache.org>.
Vadim Gritsenko wrote:
> Hi Guys,
> 
> As discussed before, and several times already, it is time to phase out 
> "feature" of passing parameters from the sitemap into flowscript as 
> positioned function parameters:
> 
>   function myflow (a, b, c) {
>       ...
>   }
> 
> Because this syntax relies on order of <map:parameter/> elements in the 
> sitemap but not names of the parameters. This syntax is replaced with 
> non-ambigous:
> 
>   function myflow () {
>       var a = cocoon.parameters.a;
>       ...
>   }
> 
> Proposed phase out plan is:
> 
>   1. Write ERROR into the log file in 2.1.6 when usage of deprecated
>      syntax is detected.
>   2. Throw exception in 2.1.7 when usage of deprecated syntax
>      is detected.
>   3. Completely remove support of deprecated syntax in 2.2.
> 
> 
> Please cast your votes.
> 
> 
> Vadim
> 

+1

-- 
Reinhard

[VOTE] Remove FlowScript Function Parameters Support

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Hi Guys,

As discussed before, and several times already, it is time to phase out 
"feature" of passing parameters from the sitemap into flowscript as positioned 
function parameters:

   function myflow (a, b, c) {
       ...
   }

Because this syntax relies on order of <map:parameter/> elements in the sitemap 
but not names of the parameters. This syntax is replaced with non-ambigous:

   function myflow () {
       var a = cocoon.parameters.a;
       ...
   }

Proposed phase out plan is:

   1. Write ERROR into the log file in 2.1.6 when usage of deprecated
      syntax is detected.
   2. Throw exception in 2.1.7 when usage of deprecated syntax
      is detected.
   3. Completely remove support of deprecated syntax in 2.2.


Please cast your votes.


Vadim

Re: FlowScript Parameters, Re: How to access sitemap parameter within JavaFlow?

Posted by Sylvain Wallez <sy...@apache.org>.
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: <map:parameter> 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 <map:parameter>.
>
>
> ...
>
>> 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?

Posted by Vadim Gritsenko <va...@reverycodes.com>.
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: <map:parameter> 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 
> <map:parameter>.

...

> 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?

Posted by Sylvain Wallez <sy...@apache.org>.
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?
>>
>> <map:call function="myJavaFlowMethod">
>>   <map:parameter name="foo" value="bar"/>
>> </map:call>
>>
>> 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: <map:parameter> 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 
<map:parameter>.

Although this isn't a problem with single parameters, this can lead to 
weird bugs with several parameters.

Consider for example:

<map:call function="fun">
  <map:parameter name="foo" value="foo-value"/>
  <map:parameter name="bar" value="bar-value"/>
</map:call>

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:
<map:call function="fun">
  <map:parameter name="bar" value="bar-value"/>
  <map:parameter name="foo" value="foo-value"/>
</map:call>

 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?

Posted by Michael Gerzabek <mi...@gmx.net>.
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?
>
><map:call function="myJavaFlowMethod">
>   <map:parameter name="foo" value="bar"/>
></map:call>
>
>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