You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Sebastien Arbogast <se...@gmail.com> on 2005/05/13 20:32:06 UTC

Flowscript function calls parameters

I've noticed something weird with sitemap and flowscript.
I had made a syntax error in one of my matchers :

<map:match pattern="internal/repository">
  <map:call function="displayRepositoryDetails()"/>
</map:match>

Notice the two parenthesis after the name of the function parameter.
Of course it's wrong as the function parameter is supposed to contain
only the name of the function. But the thing is that when I ran my
application to this point, the exception thrown showed that
"displayRepositoryDetails()() was not found", which seems to mean that
the flowscript call is made from the sitemap parameter is simply a
concatenation of the function name appended by "()".
So my question is : wouldn't it possible to use another syntaxt for
passing parameters, something like :

<map:match pattern="edit-user">
  <map:call function="editUser({request:/username})"/>
</map:match>

with a natural flowscript function like this :

function editUser(username){...}

Instead of the current less natural syntax which looks like that :

<map:match pattern="edit-user">
  <map:call function="editUser">
    <map:parameter name="username" value="{request:/username}"/>
  </map:call>
</map:match>

function editUser(){
  var username= cocoon.parameters["username"];
}

I know nothing about the technical feasability of that,it's more a
curious question because I would find this syntax much more practical.

WDYT ?

-- 
Sebastien ARBOGAST

Re: Flowscript function calls parameters

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Sebastien Arbogast wrote:
> I've noticed something weird with sitemap and flowscript.
> I had made a syntax error in one of my matchers :
> 
> <map:match pattern="internal/repository">
>   <map:call function="displayRepositoryDetails()"/>
> </map:match>
> 
> Notice the two parenthesis after the name of the function parameter.
> Of course it's wrong as the function parameter is supposed to contain
> only the name of the function. But the thing is that when I ran my
> application to this point, the exception thrown showed that
> "displayRepositoryDetails()() was not found", which seems to mean that
> the flowscript call is made from the sitemap parameter is simply a
> concatenation of the function name appended by "()".

No, it's just the error message - it adds "()".


> So my question is : wouldn't it possible to use another syntaxt for
> passing parameters, something like :
> 
> <map:match pattern="edit-user">
>   <map:call function="editUser({request:/username})"/>
> </map:match>

Don't think it is desirable...


> with a natural flowscript function like this :
> 
> function editUser(username){...}

So just you know, sitemap parameters passing into the flowscript function 
arguments was supported, but was deprecated and removed some time ago.

Reason? Because such parameter passing depends on arguments positions, rather 
than parameter names. Using cocoon.parameters allows using parameter names, 
reducing chances for mistake.

Vadim