cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lundquist <>
Subject Re: Forms and JXTemplate
Date Fri, 01 Jul 2005 18:30:08 GMT
On 2005-07-01 07:28:07 -0700, "Johannes Becker" <> said:

> One answer that was posted by Mark:
> You can generate your form definition files using jxtemplate (in a cocoon
> pipeline). Then when you want to reference your definition file, use
> cocoon:// to access it.
> My problem: I don't know how to implement this. I was looking for 
> samples, but I
> couldn't find any.
> Could anyone please post me a simple example how to implement this.

Make a template file to generate your form definition, e.g. 
"form-definition.jx".  In there you write the markup just exactly like 
in your original post, e.g.:

     		<fd:range min="5" max="#{number/max}"/>

In your sitemap:

	<match pattern="get-form-definition">
		<call function="getFormDefinition"/>		<!-- this would probably have 
some parameters too, whatev... -->
	<match pattern="generate-form-definition">
		<generate type="jx" src="form-defintion.jx"/>
		<serialize type="xml"/>

Add this flowscript:

	function getFormDefinition() {
		cocoon.sendPage (
				{'number':  {'max': 42}}	// or any bean or JS object w/ these properties...

...and finally in your form controller flowscript:

	var form = new Form ('cocoon:/get-form-definition);


That should get you going.  Although as i said before, I don't feel 
that this is a great approach.  It just smells funny to me.  Too 
complicated for the problem you're trying to solve.  And performance 
will not be great, because a dynamically-generated form definition 
can't be cached.  Doing this validation by hand is not hard, and if you 
do then the form definition itself is static, and will be cached once 
it's been parsed the first time.

But, suit yourself... :-)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message