You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jon Evans <jo...@misgl.com> on 2004/03/23 11:54:04 UTC

CachingURICoplet and Flowscript / CForms

Hi everyone,

I'm still having problems implementing a cforms-based coplet in 
flowscript, and I think maybe in previous messages to this list I've 
not been very clear as to what my problem is, so I'm going to try 
again. :-)

Lets say I have a form that lets the user update their details.  
Pseudo-flow-code would be:

function show(form) {
   populate(form);
   form.showForm("display-pipeline");
   saveToDB(form);

   cocoon.sendPage("success-pipeline");
}

So the coplet starts off by displaying an "update your details" form, 
then when you click submit it says "updates saved" or something.

In order for it to work properly with the portal engine, it is a 
CachingURICoplet.  This means that if you switch away to a different 
tab in the site, then back again, the coplet will load from the cache.  
This is normally what you want, except after you've displayed the final 
page ("Your updates have been saved to the database") you actually want 
it to reset itself, so that the next time the portal needs to render 
the coplet it regenerates itself from scratch.  Otherwise you update 
your details once, and after that you always get the "success" page.

I can fudge it by changing the flowscript to a while(true){} loop, and 
rendering the success page with sendPageAndWait, and putting a "Make 
another change" button on the success page.  But that user interface 
needs taking out and shooting. :-)  What I want to be able to do is:

function show(form) {
   populate(form);
   form.showForm("display-pipeline");
   saveToDB(form);

   cocoon.sendPage("success-pipeline");
   reset();
}

function reset() {
   // this is pseudo code remember!
   thisCoplet.reset();
   thisCoplet.clearCache();
   // Now the next time this coplet is displayed,
   // it will be generated from scratch as if it
   // had never been displayed before
}


Also, I'm still looking for a code snippet that would let me do this 
from my flowscript:

var myValue = thisCoplet.get("attributes/myValue");
// where myValue is defined in my copletdata/portal.xml file

Thanks,

Jon


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


Re: CachingURICoplet and Flowscript / CForms

Posted by Jon Evans <jo...@misgl.com>.
Hi Carsten,

On 26 Mar 2004, at 09:23, Carsten Ziegeler wrote:

> This requires a little bit of code, have a look at the
>  AbstractCopletTransformer,
> there you'll find the getCopletInstanceData(String) method. If you 
> pass in
>  null as the id into this method, you get the current coplet instance 
> data
> (= this.coplet). So you simply have to copy that code to your flow 
> script.

Not being overly familiar with the internal workings of cocoon, I'm 
having a severe case of can't-get-there-from-here.

AbstractCopletTransformer. getCopletInstanceData() starts off with:

final Map context = 
(Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);

So, I need the objectModel in my flowscript.

FOM_Cocoon does have a getObjectModel() method, but it's not available 
from flow.  I added a jsGet version of it:

     public Map jsGet_objectmodel() {
         return getObjectModel();
     }

So now in my flowscript I can call 
cocoon.objectmodel.get(ObjectModelHelper.PARENT_CONTEXT);

However that just returns null.

The code in AbstractCopletTransformer catches the case where the Map is 
null, and looks for the coplet id as a parameter.  But I wanted to 
avoid hard-coding the coplet id because I wanted some generic flow code 
that would work whatever the current coplet happens to be.

I started writing a subclass of FOM_Cocoon that would also have a 
coplet method returning the CopletInstanceData for the current coplet, 
but it wasn't clear to me how to do it.  I can't extend the internal 
class CallContext, so I can't add anything in there.

So again I am out of ideas. :-(

Thanks for your help so far,

Jon


RE: CachingURICoplet and Flowscript / CForms

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Jon Evans wrote: 
> 
> Hi Carsten,
> 
> On 25 Mar 2004, at 08:43, Carsten Ziegeler wrote:
> 
> > If the cache entry for a coplet is valid or not is stored as an  
> > attribute on the coplet. If you set the attribute "cacheValidity"
> > to "0", the cache becomes invalid.
> >  So, all you have to do is:
> >  function reset() {
> >      this.coplet.setAttribute("cacheValidity", "0");  }  
> and hopefully 
> > this should work :)
> 
> You tease me with pseudo-code! :-)  How do I get the coplet 
> reference in my flowscript?
> 
Yeah :) The rest is left to the reader...

This requires a little bit of code, have a look at the
AbstractCopletTransformer,
there you'll find the getCopletInstanceData(String) method. If you pass in
null as the id into this method, you get the current coplet instance data 
(= this.coplet). So you simply have to copy that code to your flow script.


> this.coplet just returns null. :-(
> 
HTH
Carsten


Re: CachingURICoplet and Flowscript / CForms

Posted by Jon Evans <jo...@misgl.com>.
Hi Carsten,

On 25 Mar 2004, at 08:43, Carsten Ziegeler wrote:

> If the cache entry for a coplet is valid or not is stored as an
>  attribute on the coplet. If you set the attribute "cacheValidity"
> to "0", the cache becomes invalid.
>  So, all you have to do is:
>  function reset() {
>      this.coplet.setAttribute("cacheValidity", "0");
>  }
>  and hopefully this should work :)

You tease me with pseudo-code! :-)  How do I get the coplet reference 
in my flowscript?

this.coplet just returns null. :-(

Thanks,

Jon

RE: CachingURICoplet and Flowscript / CForms

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Jon Evans wrote:
> 
> function show(form) {
>      populate(form);
>      form.showForm("display-pipeline");
>      saveToDB(form);
> 
>    cocoon.sendPage("success-pipeline");
>      reset();
>   }
> 
> function reset() {
>      // this is pseudo code remember!
>      thisCoplet.reset();
>      thisCoplet.clearCache();
>      // Now the next time this coplet is displayed,
>      // it will be generated from scratch as if it
>      // had never been displayed before
>   }
> 
If the cache entry for a coplet is valid or not is stored as an
attribute on the coplet. If you set the attribute "cacheValidity"
to "0", the cache becomes invalid.
So, all you have to do is:
function reset() {
    this.coplet.setAttribute("cacheValidity", "0");
}
and hopefully this should work :)

> 
> 
> Also, I'm still looking for a code snippet that would let me 
> do this from my flowscript:
> 
> var myValue = thisCoplet.get("attributes/myValue");
>   // where myValue is defined in my copletdata/portal.xml file
> 
I think you have two choices, you can use the coplet input module
in flow script or you can go the "long way home" and get the
profile manager and from the profile manager the coplet instance.
You can have a look at the AbstractCopletTransformer that exactly
does this in Java.

HTH
Carsten


Re: CachingURICoplet and Flowscript / CForms

Posted by Jon Evans <jo...@misgl.com>.
Hi,

On 24 Mar 2004, at 03:54, Alex Romayev wrote:

> I do remember your first post on this and I think you
>  are phrasing it very clear now.  Having said this, I
>  don't know if anyone here really has the answer, given
>  that the CachingURICoplet is fairly new.  I would like
>  to know the answer as well, as I can see myself having
>  to solve the same problem shortly.
>
> It is highly possible that no one except for Carsten
>  really has the answer.  Have you tried posting on the
> dev list, as he is more likely to take a notice of it
>  there.

Thanks, you are probably right, I'll give the dev list a try.

Devs, my original message is below, here's hoping someone can point me 
in the right direction. :-)

Thanks.

Jon

Hi everyone,

I'm still having problems implementing a cforms-based coplet in
flowscript, and I think maybe in previous messages to this list I've
not been very clear as to what my problem is, so I'm going to try
again. :-)

Lets say I have a form that lets the user update their details. 
Pseudo-flow-code would be:

function show(form) {
     populate(form);
     form.showForm("display-pipeline");
     saveToDB(form);

   cocoon.sendPage("success-pipeline");
  }

So the coplet starts off by displaying an "update your details" form,
then when you click submit it says "updates saved" or something.

In order for it to work properly with the portal engine, it is a
CachingURICoplet.  This means that if you switch away to a different
tab in the site, then back again, the coplet will load from the cache. 
This is normally what you want, except after you've displayed the final
page ("Your updates have been saved to the database") you actually want
it to reset itself, so that the next time the portal needs to render
the coplet it regenerates itself from scratch.  Otherwise you update
your details once, and after that you always get the "success" page.

I can fudge it by changing the flowscript to a while(true){} loop, and
rendering the success page with sendPageAndWait, and putting a "Make
another change" button on the success page.  But that user interface
needs taking out and shooting. :-)  What I want to be able to do is:

function show(form) {
     populate(form);
     form.showForm("display-pipeline");
     saveToDB(form);

   cocoon.sendPage("success-pipeline");
     reset();
  }

function reset() {
     // this is pseudo code remember!
     thisCoplet.reset();
     thisCoplet.clearCache();
     // Now the next time this coplet is displayed,
     // it will be generated from scratch as if it
     // had never been displayed before
  }



Also, I'm still looking for a code snippet that would let me do this
from my flowscript:

var myValue = thisCoplet.get("attributes/myValue");
  // where myValue is defined in my copletdata/portal.xml file

Thanks,

Jon


Re: CachingURICoplet and Flowscript / CForms

Posted by Jon Evans <jo...@misgl.com>.
Hi Jean-Christophe,

On 24 Mar 2004, at 18:52, Jean-Christophe Kermagoret wrote:

> So in your success pipeline you just need to redirect the user to
> ..bookmark?screen=success
> where screen is an attribute value of your coplet.
>


I did some experimentation along those lines, but it brought me back to 
the other request I posted earlier: how do you retrieve coplet 
attributes from flowscript?

Cheers,

Jon


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


Re: CachingURICoplet and Flowscript / CForms

Posted by Jean-Christophe Kermagoret <jc...@babelobjects.com>.
Hello,
you could use the boomark feature to set an attribute (screen for 
example) to a value that displays the screen you want (success for example).

That way, when you come back from another tab, your portal displays the 
right screen bases on the attribute value you set.

So in your success pipeline you just need to redirect the user to 
..bookmark?screen=success
where screen is an attribute value of your coplet.

HTH

Alex Romayev wrote:

>Jon,
>
>I do remember your first post on this and I think you
>are phrasing it very clear now.  Having said this, I
>don't know if anyone here really has the answer, given
>that the CachingURICoplet is fairly new.  I would like
>to know the answer as well, as I can see myself having
>to solve the same problem shortly.
>
>It is highly possible that no one except for Carsten
>really has the answer.  Have you tried posting on the
>dev list, as he is more likely to take a notice of it
>there.
>
>Sorry I couldn't help.
>
>-Alex
>
>
>--- Jon Evans <jo...@misgl.com> wrote:
>  
>
>>Hi everyone,
>>
>>I'm still having problems implementing a
>>cforms-based coplet in 
>>flowscript, and I think maybe in previous messages
>>to this list I've 
>>not been very clear as to what my problem is, so I'm
>>going to try 
>>again. :-)
>>
>>Lets say I have a form that lets the user update
>>their details.  
>>Pseudo-flow-code would be:
>>
>>function show(form) {
>>   populate(form);
>>   form.showForm("display-pipeline");
>>   saveToDB(form);
>>
>>   cocoon.sendPage("success-pipeline");
>>}
>>
>>So the coplet starts off by displaying an "update
>>your details" form, 
>>then when you click submit it says "updates saved"
>>or something.
>>
>>In order for it to work properly with the portal
>>engine, it is a 
>>CachingURICoplet.  This means that if you switch
>>away to a different 
>>tab in the site, then back again, the coplet will
>>load from the cache.  
>>This is normally what you want, except after you've
>>displayed the final 
>>page ("Your updates have been saved to the
>>database") you actually want 
>>it to reset itself, so that the next time the portal
>>needs to render 
>>the coplet it regenerates itself from scratch. 
>>Otherwise you update 
>>your details once, and after that you always get the
>>"success" page.
>>
>>I can fudge it by changing the flowscript to a
>>while(true){} loop, and 
>>rendering the success page with sendPageAndWait, and
>>putting a "Make 
>>another change" button on the success page.  But
>>that user interface 
>>needs taking out and shooting. :-)  What I want to
>>be able to do is:
>>
>>function show(form) {
>>   populate(form);
>>   form.showForm("display-pipeline");
>>   saveToDB(form);
>>
>>   cocoon.sendPage("success-pipeline");
>>   reset();
>>}
>>
>>function reset() {
>>   // this is pseudo code remember!
>>   thisCoplet.reset();
>>   thisCoplet.clearCache();
>>   // Now the next time this coplet is displayed,
>>   // it will be generated from scratch as if it
>>   // had never been displayed before
>>}
>>
>>
>>Also, I'm still looking for a code snippet that
>>would let me do this 
>>from my flowscript:
>>
>>var myValue = thisCoplet.get("attributes/myValue");
>>// where myValue is defined in my
>>copletdata/portal.xml file
>>
>>Thanks,
>>
>>Jon
>>
>>
>>
>>    
>>
>---------------------------------------------------------------------
>  
>
>>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
>
>
>  
>


-- 

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: CachingURICoplet and Flowscript / CForms

Posted by Jon Evans <jo...@misgl.com>.
Hi,

On 24 Mar 2004, at 03:54, Alex Romayev wrote:

> I do remember your first post on this and I think you
>  are phrasing it very clear now.  Having said this, I
>  don't know if anyone here really has the answer, given
>  that the CachingURICoplet is fairly new.  I would like
>  to know the answer as well, as I can see myself having
>  to solve the same problem shortly.
>
> It is highly possible that no one except for Carsten
>  really has the answer.  Have you tried posting on the
> dev list, as he is more likely to take a notice of it
>  there.

Thanks, you are probably right, I'll give the dev list a try.

Devs, my original message is below, here's hoping someone can point me 
in the right direction. :-)

Thanks.

Jon

Hi everyone,

I'm still having problems implementing a cforms-based coplet in
flowscript, and I think maybe in previous messages to this list I've
not been very clear as to what my problem is, so I'm going to try
again. :-)

Lets say I have a form that lets the user update their details. 
Pseudo-flow-code would be:

function show(form) {
     populate(form);
     form.showForm("display-pipeline");
     saveToDB(form);

   cocoon.sendPage("success-pipeline");
  }

So the coplet starts off by displaying an "update your details" form,
then when you click submit it says "updates saved" or something.

In order for it to work properly with the portal engine, it is a
CachingURICoplet.  This means that if you switch away to a different
tab in the site, then back again, the coplet will load from the cache. 
This is normally what you want, except after you've displayed the final
page ("Your updates have been saved to the database") you actually want
it to reset itself, so that the next time the portal needs to render
the coplet it regenerates itself from scratch.  Otherwise you update
your details once, and after that you always get the "success" page.

I can fudge it by changing the flowscript to a while(true){} loop, and
rendering the success page with sendPageAndWait, and putting a "Make
another change" button on the success page.  But that user interface
needs taking out and shooting. :-)  What I want to be able to do is:

function show(form) {
     populate(form);
     form.showForm("display-pipeline");
     saveToDB(form);

   cocoon.sendPage("success-pipeline");
     reset();
  }

function reset() {
     // this is pseudo code remember!
     thisCoplet.reset();
     thisCoplet.clearCache();
     // Now the next time this coplet is displayed,
     // it will be generated from scratch as if it
     // had never been displayed before
  }



Also, I'm still looking for a code snippet that would let me do this
from my flowscript:

var myValue = thisCoplet.get("attributes/myValue");
  // where myValue is defined in my copletdata/portal.xml file

Thanks,

Jon


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


Re: CachingURICoplet and Flowscript / CForms

Posted by Alex Romayev <ro...@yahoo.com>.
Jon,

I do remember your first post on this and I think you
are phrasing it very clear now.  Having said this, I
don't know if anyone here really has the answer, given
that the CachingURICoplet is fairly new.  I would like
to know the answer as well, as I can see myself having
to solve the same problem shortly.

It is highly possible that no one except for Carsten
really has the answer.  Have you tried posting on the
dev list, as he is more likely to take a notice of it
there.

Sorry I couldn't help.

-Alex


--- Jon Evans <jo...@misgl.com> wrote:
> Hi everyone,
> 
> I'm still having problems implementing a
> cforms-based coplet in 
> flowscript, and I think maybe in previous messages
> to this list I've 
> not been very clear as to what my problem is, so I'm
> going to try 
> again. :-)
> 
> Lets say I have a form that lets the user update
> their details.  
> Pseudo-flow-code would be:
> 
> function show(form) {
>    populate(form);
>    form.showForm("display-pipeline");
>    saveToDB(form);
> 
>    cocoon.sendPage("success-pipeline");
> }
> 
> So the coplet starts off by displaying an "update
> your details" form, 
> then when you click submit it says "updates saved"
> or something.
> 
> In order for it to work properly with the portal
> engine, it is a 
> CachingURICoplet.  This means that if you switch
> away to a different 
> tab in the site, then back again, the coplet will
> load from the cache.  
> This is normally what you want, except after you've
> displayed the final 
> page ("Your updates have been saved to the
> database") you actually want 
> it to reset itself, so that the next time the portal
> needs to render 
> the coplet it regenerates itself from scratch. 
> Otherwise you update 
> your details once, and after that you always get the
> "success" page.
> 
> I can fudge it by changing the flowscript to a
> while(true){} loop, and 
> rendering the success page with sendPageAndWait, and
> putting a "Make 
> another change" button on the success page.  But
> that user interface 
> needs taking out and shooting. :-)  What I want to
> be able to do is:
> 
> function show(form) {
>    populate(form);
>    form.showForm("display-pipeline");
>    saveToDB(form);
> 
>    cocoon.sendPage("success-pipeline");
>    reset();
> }
> 
> function reset() {
>    // this is pseudo code remember!
>    thisCoplet.reset();
>    thisCoplet.clearCache();
>    // Now the next time this coplet is displayed,
>    // it will be generated from scratch as if it
>    // had never been displayed before
> }
> 
> 
> Also, I'm still looking for a code snippet that
> would let me do this 
> from my flowscript:
> 
> var myValue = thisCoplet.get("attributes/myValue");
> // where myValue is defined in my
> copletdata/portal.xml file
> 
> Thanks,
> 
> Jon
> 
> 
>
---------------------------------------------------------------------
> 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