You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Johannes Becker <jo...@gmx.net> on 2005/07/01 16:28:07 UTC

Forms and JXTemplate

Hi,

sorry for not following up my own post that was already answered. I was
quite busy and thought I could find some examples to the given answer.

Again my question:
************************************************************************
I've got a form-definition:
 ...
 <fd:validation>
     <fd:range min="5" max="25"/>
 </fd:validation>
 ...

 My aim is to pass parameters into this definition-file. Why? Because the
max-attribute (of  fd:range)  varies (depending whats on some database).

 Is there, for example, a way of mixing Forms-definiton and JXTemplate?
Could I then write something like this?
 ...
 <fd:validation>
     <fd:range min="5" max="#{number/max}"/>
 </fd:validation>
**********************************************************************

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.
Or if there are examples in the web, a link to it.

Thanks

-- 
Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie!
Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Forms and JXTemplate

Posted by Johannes Becker <jo...@gmx.net>.
Thanks for your great help Mark!!!
Performance isn't an issiue. Just some work for my university of applied
sciences.
It only has to run.

cheers
Jonny

> --- Ursprüngliche Nachricht ---
> Von: Mark Lundquist <ml...@comcast.net>
> An: users@cocoon.apache.org
> Betreff: Re: Forms and JXTemplate
> Datum: Fri, 1 Jul 2005 11:30:08 -0700
> 
> On 2005-07-01 07:28:07 -0700, "Johannes Becker" <jo...@gmx.net>
> 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:validation>
>      		<fd:range min="5" max="#{number/max}"/>
>  	</fd:validation>
> 
> In your sitemap:
> 
> 	<match pattern="get-form-definition">
> 		<call function="getFormDefinition"/>		<!-- this would probably have 
> some parameters too, whatev... -->
> 	</match>
>          .
> 	.
> 	.
> 	<match pattern="generate-form-definition">
> 		<generate type="jx" src="form-defintion.jx"/>
> 		<serialize type="xml"/>
> 	</match>
> 
> Add this flowscript:
> 
> 	function getFormDefinition() {
> 		.
> 		.
> 		.
> 		cocoon.sendPage (
> 				'generate-form-definition',
> 				{'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... :-)
> 
> cheers
> —ml—
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Forms and JXTemplate

Posted by Mark Lundquist <ml...@comcast.net>.
On 2005-07-02 02:53:06 -0700, Leszek Gawron <lg...@apache.org> said:

>> EVERY cocoon generator has to produce a well formed markup. 
>> VelocityGenerator is not an exception.

Sure, but... the generator source could be an internal pipeline that 
uses TextGenerator.

In any case, JCK's suggestion is better... :-)

cheers,
—ml—




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Forms and JXTemplate

Posted by Jean-Christophe Kermagoret <jc...@babelobjects.com>.
I follow a pure (and compulsory) xml approach to generate my xquery file 
from xml.

Just use xslt (or jx or whatever you want) to generate your xml xquery, 
then use the text serializer to get your correct xquery.

It's ok for GET calls. I think it should be for POST too.

JC

Leszek Gawron a écrit :
> Mark Lundquist wrote:
> 
>> On 2005-07-01 14:10:06 -0700, Mike Rowse <mi...@mcmastermm.ca> said:
>>
>>> I've been trying to pass form POST information from flowscript to the
>>> eXist XQuery generator.
>>> I'm just starting to work with cforms so I may have gotten the whole
>>> point of the flowscript completely upside down. As I understand it,
>>> generally speaking once the cform information has passed the validation
>>> defined in the form definition then ideally flowscript (i.e. the
>>> controller) decides what to do with these values passing them off to the
>>> sitemap and so on. Again I'm just figuring out Cocoon so I may be
>>> completely off the mark.
>>>
>> No, you're spot on :-)
>>
>> <...snip...>
>>
>>> however it became quickly clear that the JX genny is only happy with
>>> well formed XMl docs. I'm just wondering if there is similar simple way
>>> to write values into the xQuery docs.
>>>
>> VelocityGenerator!
>> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/generation/VelocityGenerator.html 
> 
> 
> EVERY cocoon generator has to produce a well formed markup. 
> VelocityGenerator is not an exception.
> 


-- 

Jean-Christophe Kermagoret
jck@BabelObjects.Com



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Forms and JXTemplate

Posted by Leszek Gawron <lg...@apache.org>.
Mark Lundquist wrote:
> On 2005-07-01 14:10:06 -0700, Mike Rowse <mi...@mcmastermm.ca> said:
> 
>> I've been trying to pass form POST information from flowscript to the
>> eXist XQuery generator.
>> I'm just starting to work with cforms so I may have gotten the whole
>> point of the flowscript completely upside down. As I understand it,
>> generally speaking once the cform information has passed the validation
>> defined in the form definition then ideally flowscript (i.e. the
>> controller) decides what to do with these values passing them off to the
>> sitemap and so on. Again I'm just figuring out Cocoon so I may be
>> completely off the mark.
>>
> No, you're spot on :-)
> 
> <...snip...>
> 
>> however it became quickly clear that the JX genny is only happy with
>> well formed XMl docs. I'm just wondering if there is similar simple way
>> to write values into the xQuery docs.
>>
> VelocityGenerator!
> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/generation/VelocityGenerator.html 
EVERY cocoon generator has to produce a well formed markup. 
VelocityGenerator is not an exception.

-- 
Leszek Gawron                                                 MobileBox
lgawron@apache.org                              http://www.mobilebox.pl

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Forms and JXTemplate

Posted by Mark Lundquist <ml...@comcast.net>.
On 2005-07-01 14:10:06 -0700, Mike Rowse <mi...@mcmastermm.ca> said:

> I've been trying to pass form POST information from flowscript to the
> eXist XQuery generator.
> I'm just starting to work with cforms so I may have gotten the whole
> point of the flowscript completely upside down. As I understand it,
> generally speaking once the cform information has passed the validation
> defined in the form definition then ideally flowscript (i.e. the
> controller) decides what to do with these values passing them off to the
> sitemap and so on. Again I'm just figuring out Cocoon so I may be
> completely off the mark.
> 
No, you're spot on :-)

<...snip...>
> however it became quickly clear that the JX genny is only happy with
> well formed XMl docs. I'm just wondering if there is similar simple way
> to write values into the xQuery docs.
> 
VelocityGenerator!
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/generation/VelocityGenerator.html

HTH,
—ml—

 




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Forms and JXTemplate

Posted by Mike Rowse <mi...@mcmastermm.ca>.
I've been trying to pass form POST information from flowscript to the
eXist XQuery generator. 

I'm just starting to work with cforms so I may have gotten the whole
point of the flowscript completely upside down. As I understand it,
generally speaking once the cform information has passed the validation
defined in the form definition then ideally flowscript (i.e. the
controller) decides what to do with these values passing them off to the
sitemap and so on. Again I'm just figuring out Cocoon so I may be
completely off the mark.

 In my case I need to send the form values to a XQuery generator (that
comes with eXist) to generate a search query on some academic xml
documents. I'm trying to avoid use GET on the .xql request (which I can
use to pass the form values to the genny). At one point I tried using
the JXTemplate generator to write the values into the XQuery document
itself

i.e.

let $a = #{cocoon.request.etc()}

however it became quickly clear that the JX genny is only happy with
well formed XMl docs. I'm just wondering if there is similar simple way
to write values into the xQuery docs. I'm occupied with some other
things at the moment so I haven't had a chance to tinker with the
innards of cocoon nor do I have any idea how to translate the flowscript
requests into POSTs to the xQuery pipeline ( as if the pipeline had be
requested from a form directly).

Thanks for any help,
Mike
 



On Fri, 2005-01-07 at 13:23 -0700, Mark Lundquist wrote:
> Hi Mike,
> 
> On 2005-07-01 11:36:30 -0700, Mike Rowse <mi...@mcmastermm.ca> said:
> 
> > incidentally is there any way to do that for non XML formatted files? I
> > was trying to do it with XQuery files but, because XQuery definitely
> > doesn't look like well formed XML cocoon complained.
> 
> Not sure what you're tryin' to do, can you give more specifics?
> —ml—
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Forms and JXTemplate

Posted by Mark Lundquist <ml...@comcast.net>.
Hi Mike,

On 2005-07-01 11:36:30 -0700, Mike Rowse <mi...@mcmastermm.ca> said:

> incidentally is there any way to do that for non XML formatted files? I
> was trying to do it with XQuery files but, because XQuery definitely
> doesn't look like well formed XML cocoon complained.

Not sure what you're tryin' to do, can you give more specifics?
—ml—



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Forms and JXTemplate

Posted by Mike Rowse <mi...@mcmastermm.ca>.
incidentally is there any way to do that for non XML formatted files? I
was trying to do it with XQuery files but, because XQuery definitely
doesn't look like well formed XML cocoon complained.

Mike


On Fri, 2005-01-07 at 11:30 -0700, Mark Lundquist wrote:
> On 2005-07-01 07:28:07 -0700, "Johannes Becker" <jo...@gmx.net> 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:validation>
>      		<fd:range min="5" max="#{number/max}"/>
>  	</fd:validation>
> 
> In your sitemap:
> 
> 	<match pattern="get-form-definition">
> 		<call function="getFormDefinition"/>		<!-- this would probably have 
> some parameters too, whatev... -->
> 	</match>
>          .
> 	.
> 	.
> 	<match pattern="generate-form-definition">
> 		<generate type="jx" src="form-defintion.jx"/>
> 		<serialize type="xml"/>
> 	</match>
> 
> Add this flowscript:
> 
> 	function getFormDefinition() {
> 		.
> 		.
> 		.
> 		cocoon.sendPage (
> 				'generate-form-definition',
> 				{'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... :-)
> 
> cheers
> —ml—
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Forms and JXTemplate

Posted by Mark Lundquist <ml...@comcast.net>.
On 2005-07-01 07:28:07 -0700, "Johannes Becker" <jo...@gmx.net> 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:validation>
     		<fd:range min="5" max="#{number/max}"/>
 	</fd:validation>

In your sitemap:

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

Add this flowscript:

	function getFormDefinition() {
		.
		.
		.
		cocoon.sendPage (
				'generate-form-definition',
				{'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... :-)

cheers
—ml—



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org