Jorg Heymans wrote:

Hi,

I want to pass extra parameters to the function that handles my form

Sitemap:

<map:match pattern="*.action">
 <map:call function="handleForm">
  <map:parameter name="function" value="myfunction"/>
  <map:parameter name="form-definition" value="forms/FormModel.xml"/>
  <map:parameter name="bindingURI" value="forms/FormBinding.xml"/>
<!-- below does not get passed to "myfunction" -->
 <map:parameter name="template" value="{1}"/>
</map:call>

then in flowscript

function myfunction(form, template) {
  //template is undefined here !!
}

is there another way going about this?


Yeah, forget about that clumsy "handleForm" and use a plain old function. IMO, the name of the form definition and binding belong to the controller (i.e. the flowscript) and not to the sitemap.

<map:match pattern="*.action">
 <map:call function="myFunction">
   <map:parameter name="template" value="{1}"/>
 </map:call>
</map:match>


function myFunction() { var form = new Form("forms/fooFormModel.xml"); form.createBinding("forms/fooFormBinding.xml"); ... form.showForm(cocoon.parameters["template"]); ... }

And be very careful with the fact that in <map:call function>, only the *order* of parameters is significant, and not their names. That's why it's safer to have functions with no arguments and use cocoon.parameters.

Also, I personally use the following pattern:

<map:match pattern="do-*">
 <map:call function="public_{1}"/>
</map:match>

This publishes a whole set of flowscript entry points in the URL space, and the use of the "public_" prefix ensures only those functions that we really consider public are accessible from the outside world.

Sylvain

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


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to