You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Daniel McOrmond <dm...@gmail.com> on 2005/03/03 23:37:16 UTC

Remembering original request parameters when using flow

Is it better to 'remember' original request parameters as variables in
flowscript, or to pass them via hidden form fields through the
pipeline? The goal is for the next pipeline to have access to them.

Below are two examples. I've tried to be as succinct as possible. So,
you'll just have to use your imagination for the missing pieces. :)


Here's the first example, if I use variables within flow:

var foo = cocoon.request.getParameter("foo");
cocoon.sendPageAndWait("getUserInput");
cocoon.sendPage("displayResults", { foo: foo } );

<map:match pattern="getUserInput"/>
 <map:generate type="file" src="foo.xml"/>
 <map:transform type="xslt" src="bar.xsl"/>
 <map:serialize type="html"/>
</map:match>

/* HTML generated by the getUserInput pipeline */
<form action="68546a264d336f0b313a58595a704b024a2e7e8b.continuation">
 <input type="text" name="textField"/>
 <input type="submit"/>
</form>

/* After the user submits the form, the continuation picks up with
this final pipeline */
<map:match pattern="displayResults">
 <map:generate type="file" src="bar.xml"/>
 <map:transform type="xslt" src="baz.xsl">
  <map:parameter name="originalValueOfFooParameter"
value="{flow-attribute:foo}"/>
 </map:transform>
 <map:serialize type="html"/>
</map:match>

Of course, the JXTemplateGenerator, or any number of methods could be
used to inject the value of foo into the displayResults pipeline..




Here's the second example, if I use hidden form fields:

cocoon.sendPageAndWait("getUserInput");
cocoon.sendPage("displayResults");

/* The request generator provides the original value of the foo
parameter to the stylesheet */
<map:match pattern="getUserInput">
 <map:generate type="request"/>
 <map:transform type="xslt" src="foo.xsl"/>
 <map:serialize type="html"/>
</map:match>

/* HTML generated by the getUserInput pipeline */
<form action="32434378822575115d252d213251313e0f2d4e14.continuation">
 <input type="hidden" name="foo" value="whatever"/>
 <input type="text" name="textField"/>
 <input type="submit"/>
</form>

/* After the user submits the form, the continuation picks up with
this final pipeline */
<map:match pattern="displayResults">
 <map:generate type="request"/>
 <map:transform type="xslt" src="bar.xsl"/>
 <map:serialize type="html"/>
</map:match>





Now, I expect that the answer will be that I should use variables
within flowscript. I've seen that the flow tutorial and examples do
things this way.

The only thing I don't like about using flow variables, is that I have
to pass them all through when I call a sendPage or sendPageAndWait. In
this example, I only had one original parameter, but suppose I had 50?
Even worse, suppose that I don't know the names of each parameter, or
that the potential set of provided parameters is highly volitile.

The advantage to using hidden form fields, is that I can handle any
number of original parameters, and don't have to worry about what
they're named. The request generator gives me all that information for
free, and my stylesheet can transform them easily. The downsides of
this method is that all that data goes back and forth between client
and server, not to mention that it's cheesy and old-school.


What do you guys think?  ( Let me know if anything is not clear. )

-Daniel

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


Re: Remembering original request parameters when using flow

Posted by Daniel McOrmond <dm...@gmail.com>.
On Thu, 03 Mar 2005 22:41:50 +0000, Upayavira <uv...@upaya.co.uk> wrote:
> > Now, I expect that the answer will be that I should use variables
> > within flowscript. I've seen that the flow tutorial and examples do
> > things this way.
> 
> It is up to you. However, I think you'll find the flow route easier.
> Really it is a matter of personal programming choice.
> 
> > The only thing I don't like about using flow variables, is that I have
> > to pass them all through when I call a sendPage or sendPageAndWait.
> 
> No you don't. You only need to pass them if you want to display them in
> your page.

True. :) In addition, I suppose I could do some 'magic' to build an
array, and just pass that, instead of naming each one within the curly
braces.


> > In
> > this example, I only had one original parameter, but suppose I had 50?
> > Even worse, suppose that I don't know the names of each parameter, or
> > that the potential set of provided parameters is highly volitile.
> >
> > The advantage to using hidden form fields, is that I can handle any
> > number of original parameters, and don't have to worry about what
> > they're named. The request generator gives me all that information for
> > free, and my stylesheet can transform them easily. The downsides of
> > this method is that all that data goes back and forth between client
> > and server, not to mention that it's cheesy and old-school.
> 
> Just saying:
> var a = "foo";
> cocoon.sendPageAndWait("my-second-url");
> var b = a + "bar";
> 
> Surely that is pretty easy?

Of course. :)


> Certainly easier than having to construct a form to pass it back and
> forwards.

Ah, but in my case I need the forms to gather user input anyhow. Time
contraints dictate that I wait to move everything to CForms.


> > What do you guys think?  ( Let me know if anything is not clear. )
> 
> Well, there's my thoughts.

Thanks, Upayavira!

Anyone else care to weigh in on the subject? I'm leaning towards the
flow approach..

-Daniel

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


Re: Remembering original request parameters when using flow

Posted by Upayavira <uv...@upaya.co.uk>.
Daniel McOrmond wrote:
> Is it better to 'remember' original request parameters as variables in
> flowscript, or to pass them via hidden form fields through the
> pipeline? The goal is for the next pipeline to have access to them.
> 
> Below are two examples. I've tried to be as succinct as possible. So,
> you'll just have to use your imagination for the missing pieces. :)
> 
> 
> Here's the first example, if I use variables within flow:
> 
> var foo = cocoon.request.getParameter("foo");
> cocoon.sendPageAndWait("getUserInput");
> cocoon.sendPage("displayResults", { foo: foo } );
> 
> <map:match pattern="getUserInput"/>
>  <map:generate type="file" src="foo.xml"/>
>  <map:transform type="xslt" src="bar.xsl"/>
>  <map:serialize type="html"/>
> </map:match>
> 
> /* HTML generated by the getUserInput pipeline */
> <form action="68546a264d336f0b313a58595a704b024a2e7e8b.continuation">
>  <input type="text" name="textField"/>
>  <input type="submit"/>
> </form>
> 
> /* After the user submits the form, the continuation picks up with
> this final pipeline */
> <map:match pattern="displayResults">
>  <map:generate type="file" src="bar.xml"/>
>  <map:transform type="xslt" src="baz.xsl">
>   <map:parameter name="originalValueOfFooParameter"
> value="{flow-attribute:foo}"/>
>  </map:transform>
>  <map:serialize type="html"/>
> </map:match>
> 
> Of course, the JXTemplateGenerator, or any number of methods could be
> used to inject the value of foo into the displayResults pipeline..
> 
> 
> 
> 
> Here's the second example, if I use hidden form fields:
> 
> cocoon.sendPageAndWait("getUserInput");
> cocoon.sendPage("displayResults");
> 
> /* The request generator provides the original value of the foo
> parameter to the stylesheet */
> <map:match pattern="getUserInput">
>  <map:generate type="request"/>
>  <map:transform type="xslt" src="foo.xsl"/>
>  <map:serialize type="html"/>
> </map:match>
> 
> /* HTML generated by the getUserInput pipeline */
> <form action="32434378822575115d252d213251313e0f2d4e14.continuation">
>  <input type="hidden" name="foo" value="whatever"/>
>  <input type="text" name="textField"/>
>  <input type="submit"/>
> </form>
> 
> /* After the user submits the form, the continuation picks up with
> this final pipeline */
> <map:match pattern="displayResults">
>  <map:generate type="request"/>
>  <map:transform type="xslt" src="bar.xsl"/>
>  <map:serialize type="html"/>
> </map:match>
> 
> 
> 
> 
> 
> Now, I expect that the answer will be that I should use variables
> within flowscript. I've seen that the flow tutorial and examples do
> things this way.

It is up to you. However, I think you'll find the flow route easier. 
Really it is a matter of personal programming choice.

> The only thing I don't like about using flow variables, is that I have
> to pass them all through when I call a sendPage or sendPageAndWait.

No you don't. You only need to pass them if you want to display them in 
your page.
> In
> this example, I only had one original parameter, but suppose I had 50?
> Even worse, suppose that I don't know the names of each parameter, or
> that the potential set of provided parameters is highly volitile.
> 
> The advantage to using hidden form fields, is that I can handle any
> number of original parameters, and don't have to worry about what
> they're named. The request generator gives me all that information for
> free, and my stylesheet can transform them easily. The downsides of
> this method is that all that data goes back and forth between client
> and server, not to mention that it's cheesy and old-school.

Just saying:
var a = "foo";
cocoon.sendPageAndWait("my-second-url");
var b = a + "bar";

Surely that is pretty easy?

Certainly easier than having to construct a form to pass it back and 
forwards.

> What do you guys think?  ( Let me know if anything is not clear. )

Well, there's my thoughts.

Regards, Upayavira

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


Re: Remembering original request parameters when using flow

Posted by Daniel McOrmond <dm...@gmail.com>.
On Fri, 04 Mar 2005 00:11:29 +0100, Sylvain Wallez <sy...@apache.org> wrote:
> Hehe, during Cocoon trainings, I tell people "untwist your mind, things
> are simple again". Flowscript keeps the execution state between
> requests, so you really don't need some hidden inputs hacks if you go
> from screen to screen using continuations.

Ah yes, do you hear that? It's the sound of chains clanking to the
floor as my mind is freed from the shackles of traditional web
programming, thanks to Cocoon! ;)


> You can use a single JS object variable and add any number of properties
> to this object.

Cool! I'll definitely take advantage of that.

Thanks everyone.

-Daniel

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


Re: Remembering original request parameters when using flow

Posted by Sylvain Wallez <sy...@apache.org>.
Daniel McOrmond wrote:

>Is it better to 'remember' original request parameters as variables in
>flowscript, or to pass them via hidden form fields through the
>pipeline? The goal is for the next pipeline to have access to them.
>  
>

Hehe, during Cocoon trainings, I tell people "untwist your mind, things 
are simple again". Flowscript keeps the execution state between 
requests, so you really don't need some hidden inputs hacks if you go 
from screen to screen using continuations.

>Now, I expect that the answer will be that I should use variables
>within flowscript. I've seen that the flow tutorial and examples do
>things this way.
>
>The only thing I don't like about using flow variables, is that I have
>to pass them all through when I call a sendPage or sendPageAndWait. In
>this example, I only had one original parameter, but suppose I had 50?
>Even worse, suppose that I don't know the names of each parameter, or
>that the potential set of provided parameters is highly volitile.
>  
>

You can use a single JS object variable and add any number of properties 
to this object.

>The advantage to using hidden form fields, is that I can handle any
>number of original parameters, and don't have to worry about what
>they're named. The request generator gives me all that information for
>free, and my stylesheet can transform them easily. The downsides of
>this method is that all that data goes back and forth between client
>and server, not to mention that it's cheesy and old-school.
>  
>

Yep. And using flowscript variables doesn't force you to use the request 
generator.

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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org