You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Philippe Guillard <pg...@citycita.net> on 2005/05/26 08:26:16 UTC
"Reset" cachingURI coplet
Hi all,
I try there since i get no answer on the user-list. My question is also
the same as this old mail
http://www.mail-archive.com/users@cocoon.apache.org/msg12028.html.
I'm looking for some idea/solution to refresh a cachingURI coplet
content after a form in portal has been submitted. Then a user going to
other tabs and going back would not see the "success" page again.
This may explain better my need:
function show(form) {
populate(form);
form.showForm("display-pipeline");
saveToDB(form);
cocoon.sendPage("success-pipeline");
resetCoplet("instance_name");
}
function resetCoplet() {
// this is pseudo code remember!
thisCoplet.resetTemporaryURI();
thisCoplet.invalidateCache();
// Now next time this coplet will be generated from scratch
}
This is what i have written at the moment. I see no exceptions, but with
no effect at all:
function resetCoplet(instanceName) {
var service = null;
try {
// get portal service
service =
cocoon.getComponent(org.apache.cocoon.portal.PortalService.ROLE);
service.setPortalName("portal");
// get profile manager
var componentManager = service.getComponentManager();
var profileManager = componentManager.getProfileManager();
var cid = profileManager.getCopletInstanceData(instanceName);
var event = null;
var path = "temporaryAttributes/application-uri";
var value = "cocoon://portal/coplets/profiler/profile";
if ( cid != null ) {
// create event
event = new
Packages.org.apache.cocoon.portal.event.impl.CopletJXPathEvent(cid,
path, value);
// subscribe it
service.getComponentManager().getEventManager().getPublisher().publish(event);
// invalidate cache
var cachingURICopletAdapter = new
Packages.org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter();
cachingURICopletAdapter.setCacheInvalid(cid);
}
} catch ( e ) {
cocoon.log.info("Error", e);
}
finally {
cocoon.releaseComponent( service );
}
}
Somebody can help?
PHIL
Re: "Reset" cachingURI coplet
Posted by Philippe Guillard <pg...@citycita.net>.
Thanks a lot!
I finally get i didn't invalidate the coplet cache correctly and used
your way.
Below is what i have all-in-one, if others are interested...
Regards,
Phil
____________________________________
function resetCoplet(copletId, tempURI) {
var service = null;
try {
// get portal service/profile manager/coplet
service =
cocoon.getComponent(org.apache.cocoon.portal.PortalService.ROLE);
service.setPortalName("portal");
var componentManager = service.getComponentManager();
var profileManager = componentManager.getProfileManager();
var coplet = profileManager.getCopletInstanceData(copletId);
var path = "temporaryAttributes/application-uri";
var value = tempURI;
var cachingURICopletAdapter = new
Packages.org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter();
if ( coplet != null ) {
// invalidate cache
coplet.setAttribute(org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter.DO_NOT_CACHE,
"true");
cocoon.log.debug("cache invalidated for coplet="+copletId);
// create event and suscribe it
var event = new
Packages.org.apache.cocoon.portal.event.impl.CopletJXPathEvent(coplet,
path, value);
service.getComponentManager().getEventManager().getPublisher().publish(event);
cocoon.log.debug("tempURI changed for coplet="+copletId);
} else {
cocoon.log.error("This coplet doesn't exist="+copletId);
}
} catch ( e ) {
cocoon.log.info("Error", e);
}
finally {
cocoon.releaseComponent( service );
}
}
Jean-Baptiste Quenot wrote:
>* Philippe Guillard:
>
>
>
>>Looks really good. Unfortunately it does the same for me, no
>>errors and the succes page is still displayed! It seems i do
>>not cache the response, the coplet temporaryURI is still
>>with the continuation, so the response is regenerated because
>>flowscript starts again at the continuation point.
>>
>>
>
>The form action points to a pipeline called
>"invalidateCacheForCoplet", and in turn calling a flowscript
>to invalidate the coplet upon form submission. And finally
>the request is forwarded to "portal". We don't use this
>temporary:application-uri hack.
>
>Here is what it looks like:
>
>function invalidateCacheForCoplet(copletId)
>{
> // Get the coplet
> var service = cocoon.getComponent(org.apache.cocoon.portal.PortalService.ROLE);
> var profileManager = service.getComponentManager().getProfileManager();
> var coplet = profileManager.getCopletInstanceData(copletId);
> // Set the cache of the coplet as invalid
> // Note : this code comes from CachingURICopletAdapter
> coplet.setAttribute(org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter.CACHE_VALIDITY,
> org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter.CACHE_INVALID);
> cocoon.sendPage("portal");
>}
>
>Cheers,
>
>
Re: "Reset" cachingURI coplet
Posted by Jean-Baptiste Quenot <jb...@anyware-tech.com>.
* Philippe Guillard:
> Looks really good. Unfortunately it does the same for me, no
> errors and the succes page is still displayed! It seems i do
> not cache the response, the coplet temporaryURI is still
> with the continuation, so the response is regenerated because
> flowscript starts again at the continuation point.
The form action points to a pipeline called
"invalidateCacheForCoplet", and in turn calling a flowscript
to invalidate the coplet upon form submission. And finally
the request is forwarded to "portal". We don't use this
temporary:application-uri hack.
Here is what it looks like:
function invalidateCacheForCoplet(copletId)
{
// Get the coplet
var service = cocoon.getComponent(org.apache.cocoon.portal.PortalService.ROLE);
var profileManager = service.getComponentManager().getProfileManager();
var coplet = profileManager.getCopletInstanceData(copletId);
// Set the cache of the coplet as invalid
// Note : this code comes from CachingURICopletAdapter
coplet.setAttribute(org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter.CACHE_VALIDITY,
org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter.CACHE_INVALID);
cocoon.sendPage("portal");
}
Cheers,
--
Jean-Baptiste Quenot
Systèmes d'Information
ANYWARE TECHNOLOGIES
Tel : +33 (0)5 61 00 52 90
Fax : +33 (0)5 61 00 51 46
http://www.anyware-tech.com/
Re: "Reset" cachingURI coplet
Posted by Philippe Guillard <pg...@citycita.net>.
Thanks Jean-Baptiste,
Looks really good. Unfortunately it does the same for me, no errors and
the succes page is still displayed!
It seems i do not cache the response, the coplet temporaryURI is still
with the continuation, so the response is regenerated because flowscript
starts again at the continuation point.
(cocoon://portal/coplets/mycoplet/xxxxxxxxxxx.continue)
I suppose you added something else, but can't get what!?
Regards,
Phil
Jean-Baptiste Quenot wrote:
>* Philippe Guillard:
>
>
>
>>I'm looking for some idea/solution to refresh a cachingURI
>>coplet content after a form in portal has been submitted. Then a
>>user going to other tabs and going back would not see the
>>"success" page again.
>>
>>
>
>Here is what we do:
>
>showForm()
>doNotCacheCopletResponse(copletId);
>cocoon.sendPage("success-page");
>
>And here is the magic function:
>
>function doNotCacheCopletResponse(copletId)
>{
> cocoon.log.debug("doNotCacheCopletResponse: coplet="+copletId);
>
> var service = cocoon.getComponent(org.apache.cocoon.portal.PortalService.ROLE);
> var profileManager = service.getComponentManager().getProfileManager();
> var coplet = profileManager.getCopletInstanceData(copletId);
> // tells the coplet not to cache the his content
> // Note : this code comes from CachingURICopletAdapter
> coplet.setAttribute(org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter.DO_NOT_CACHE, "true");
>}
>
>This prevents caching for the success page.
>
>HTH,
>
>
Re: "Reset" cachingURI coplet
Posted by Jean-Baptiste Quenot <jb...@anyware-tech.com>.
* Philippe Guillard:
> I'm looking for some idea/solution to refresh a cachingURI
> coplet content after a form in portal has been submitted. Then a
> user going to other tabs and going back would not see the
> "success" page again.
Here is what we do:
showForm()
doNotCacheCopletResponse(copletId);
cocoon.sendPage("success-page");
And here is the magic function:
function doNotCacheCopletResponse(copletId)
{
cocoon.log.debug("doNotCacheCopletResponse: coplet="+copletId);
var service = cocoon.getComponent(org.apache.cocoon.portal.PortalService.ROLE);
var profileManager = service.getComponentManager().getProfileManager();
var coplet = profileManager.getCopletInstanceData(copletId);
// tells the coplet not to cache the his content
// Note : this code comes from CachingURICopletAdapter
coplet.setAttribute(org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter.DO_NOT_CACHE, "true");
}
This prevents caching for the success page.
HTH,
--
Jean-Baptiste Quenot
Systèmes d'Information
ANYWARE TECHNOLOGIES
Tel : +33 (0)5 61 00 52 90
Fax : +33 (0)5 61 00 51 46
http://www.anyware-tech.com/