You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Samuel Tribehou <s....@edenweb.Fr> on 2004/05/07 14:18:38 UTC

Flowscript, continuations, reloading

Hello there.
I'm a new cocoon user, so please bear with my ignorance ;)

Here is my problem :

Say I have page which contains a main form. This form contains not only 
traditionnal form elements, but also some data displayed as lists which 
is gathered form a database.
To add/remove items from those lists, there are links which opens little 
forms in a popup window. Once those forms are submitted, the popup 
closes and the user does things with the main form again.
My problem is, how can I redisplay the main form with the actualized data ?

What I'd need to do is first gather the main form data and put it in a 
bean, then display the popup, add the data to the bean once this form is 
sumbmited,
and redisplay the main form with the actualized data.

So, when the user opens a popup, a flowscript function is called to 
display and process this form.
- First problem : it seems I can't gather the main form data from here 
with cocoon.request.get() because it's not the same request.
- Second problem : How can i reload the main form with actualized data 
from here ?
If i try to call the flowscript function which displays the main form, i 
get an error : "Pipeline has already been processed for this request"
So i thought maybe i could invalidate the continuation started the first 
time the form is displayed, then be able to redisplay the main form 
without error. But I can't get that to work either..
(third problem)
I tried to to it like that :

 var continuation = cocoon.sendPageAndWait ("mainform");
cocoon.session.setAttribute ("continuation", continuation);  

Then in the flowscript function which displays the popup:
var continuation = cocoon.session.getAttribute("continuation");
print ("continuation = " + continuation); // displays "continuation = 
[object FOM_WebContinuation]"
continuation.invalidate(); //NPE  ??

So, what do you guys suggest ?
The third problem probably shows that i don't really understand how 
continuations work and how they should be used ;)
But how would you solve my first two problems ? There must be a way to 
do it i suppose ?

 



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


Re: Flowscript, continuations, reloading

Posted by Joerg Heinicke <jo...@gmx.de>.
On 12.05.2004 20:06, Mark Lundquist wrote:

>         <script language="javascript">
>                 if (!self.opener.closed) {
>                         self.opener.document.location.reload();
>                 }
>                 self.close();
>         </script>

I only would not do it with self.opener.document.location.reload(), but 
by submitting the form with a special refresh submit. The above causes 
problems when doing POST requests as it needs user interaction in most 
browsers and so on.

Joerg

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


Re: Flowscript, continuations, reloading

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On May 7, 2004, at 5:18 AM, Samuel Tribehou wrote:

> Hello there.
> I'm a new cocoon user, so please bear with my ignorance ;)

Par for the course, as they say :-)

>
> Here is my problem :
>
> Say I have page which contains a main form. This form contains not 
> only traditionnal form elements, but also some data displayed as lists 
> which is gathered form a database.
> To add/remove items from those lists, there are links which opens 
> little forms in a popup window. Once those forms are submitted, the 
> popup closes and the user does things with the main form again.
> My problem is, how can I redisplay the main form with the actualized 
> data ?
>

Here's how I do it...

You have a "main" page with a list of items, right?  And a "details" 
page that lets you add/edit/delete on a per-item basis, right?

OK, first of all... flow is great, but it's not automatically the 
solution to everything :-).  In particular, I think you should not be 
trying to think of the "details" popup as being in the same flow as the 
display of the main page.  I could be wrong, and maybe someone knows 
more flow tricks will be able to show you how to do it more along the 
lines of what you have suggested.

But I would recommend that you first change the sitemap for the details 
to make it a per-item resource, i.e. embed the item ID in the URN 
somewhere, and pass that ID to the flowscript for your details page:

	<map:match "details/*">
		<map:call function="details">
			<map:parameter name="item" value="{1}" />
		</map:call>
	</map:match>

Then, in the main page, display your list items as links that call up 
the details page for the respective items (using client-side Javascript 
to get the popup effect... you can also make them buttons instead of 
links if you want).

To get the redisplay part working, here's what ya do...

In the flowscript for the details page, after you have processed the 
form, do this:

	cocoon.sendPage ("finished");

Have that match in your sitemap to send this page:

<html>
         <head>
         <script language="javascript">
                 if (!self.opener.closed) {
                         self.opener.document.location.reload();
                 }
                 self.close();
         </script>
         </head>
<body/>
</html>

I think that's about all there is to it.  Does this solve your problem?

~mark


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


Re: Flowscript, continuations, reloading

Posted by Joerg Heinicke <jo...@gmx.de>.
Your error description is really confusing. It might help if you can 
re-read and re-phrase it.

Just some comments:
The call of the flowscript function can not work as it would not lead to 
a reload on client side - simply the client's request would be missing. 
The reason that it ends with an exception "Pipeline has already been 
processed for this request" is due to the fact that you have already 
handled the request of "save data in popup" and so sent a response and 
now you try to send a second response. What you need to do is a bit more 
client side javascript. onclose() in the popup you need to do a refresh 
in the main window. Instead of most simple parent.location.reload() it 
would be better to submit the form in the main window. I would add a 
refresh button for this.

Joerg

On 07.05.2004 14:18, Samuel Tribehou wrote:

> Hello there.
> I'm a new cocoon user, so please bear with my ignorance ;)
> 
> Here is my problem :
> 
> Say I have page which contains a main form. This form contains not only 
> traditionnal form elements, but also some data displayed as lists which 
> is gathered form a database.
> To add/remove items from those lists, there are links which opens little 
> forms in a popup window. Once those forms are submitted, the popup 
> closes and the user does things with the main form again.
> My problem is, how can I redisplay the main form with the actualized data ?
> 
> What I'd need to do is first gather the main form data and put it in a 
> bean, then display the popup, add the data to the bean once this form is 
> sumbmited,
> and redisplay the main form with the actualized data.
> 
> So, when the user opens a popup, a flowscript function is called to 
> display and process this form.
> - First problem : it seems I can't gather the main form data from here 
> with cocoon.request.get() because it's not the same request.
> - Second problem : How can i reload the main form with actualized data 
> from here ?
> If i try to call the flowscript function which displays the main form, i 
> get an error : "Pipeline has already been processed for this request"
> So i thought maybe i could invalidate the continuation started the first 
> time the form is displayed, then be able to redisplay the main form 
> without error. But I can't get that to work either..
> (third problem)
> I tried to to it like that :
> 
> var continuation = cocoon.sendPageAndWait ("mainform");
> cocoon.session.setAttribute ("continuation", continuation); 
> Then in the flowscript function which displays the popup:
> var continuation = cocoon.session.getAttribute("continuation");
> print ("continuation = " + continuation); // displays "continuation = 
> [object FOM_WebContinuation]"
> continuation.invalidate(); //NPE  ??
> 
> So, what do you guys suggest ?
> The third problem probably shows that i don't really understand how 
> continuations work and how they should be used ;)
> But how would you solve my first two problems ? There must be a way to 
> do it i suppose ?

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