You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Simeon Penev <si...@web.de> on 2005/04/26 13:59:29 UTC

Interportlet communication

Hi,

I've read  in the 'Event handling' section of the 'Portal engine' documentation that there is a way to pass events between portlets. How can i do that? Could someone provide an example? 

I've seen they are methods in the ManagedCocoonPortlet.java processAction and render, which are used to deliver content to the portal. The problem is i cannot find a way to invoke them by clicking on a link inside other portlet. What i am trying to accomplish is to have the portlets subscribed to a certain type of event, as it is done with the cocoon components using the Subscriber interface.


Thank you for your help in advance!

Best regards,
Simeon 
__________________________________________________________
Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
weltweit telefonieren! http://freephone.web.de/?mc=021201


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


Re: Interportlet communication

Posted by Laurent Trillaud <la...@trillaud.com>.
Hi
I use also portal bookmark feature for coplet (Cocoon Portlet) 
communication.
It easy to use and very flexible.
http://wiki.apache.org/cocoon/PortalEngineBookmarks
Laurent Trillaud

Nick Goupinets wrote:

> Hi Simeon,
>
> That's pretty easy to pass information (not events) between coplets. 
> There is of course default ways of doing it with cl:link stuff. Just 
> check the sample portal, image gallery coplets. I think that this is a 
> bit tedious and not particularly convenient if flow is available.
>
> With flow, that's how info can be passed
>
> 1) get portal service and set portal name there
> 2) get portal component manager
> 3) get profile manager
> 4) get coplet instance data
> 5) set any attributes in this coplet instance data
>
> They can later be used in the sitemap for example by putting something 
> like that:
> <map:parameter name="textID" value="{coplet:attributes/textID}"/>
>
> here is flow code:
>
> 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(copletId);
>   // ADD OR REMOVE ANY ATTRIBUTES HERE
>   // CHECK API FOR CopletInstanceData
> } catch ( e ) {
>   cocoon.log.info("Error");
> }
> finally {
>   cocoon.releaseComponent( service );
> }
>
> Working with events is more complicated. Coplets are not themselves 
> components so it's merely impossible to subscribe them for an event. 
> You will need a cocoon component that implements publisher or 
> subscriber interface. It will perform event processing. Here is what 
> needs to be done:
>
> 1) create a new portal event type (or reuse some of the existing 
> ones). it should hold all the necessary information for the step (2)
> 2) create new cocoon component that will be responsible for 
> publishing/subscribing to the events from (1)
> 3) register component from (2) with the portal event manager (can be 
> done at the run time)
>
> Now you are ready for working with events. Please refer to the cocoon 
> web site for the details how to carry out the actual processing (i.e. 
> fire them off, publish, subscribe, etc.)
>
> General hints are:
> 1) if you need to fire event immediately - just publish it
> 2) if you need to fire event on *any* click in the portal - use link 
> service to add event to the link
> 3) if you need to fire event only in case of a particular link click - 
> that's where it got tricky for me. I use link service to get the event 
> encoded as a string. then I pass this string to a coplet where it's 
> placed into an <a> html tag.
>
> I worked with this stuff quite a bit of time ago (I used cocoon 
> 2.1.5), so chances are that I missed something and something changed 
> in the latest version of cocoon. I also hope that there are better 
> ways of doing the stuff I described. Some feed back is greatly 
> appreciated.
>
> Thank you.
>
> Sincerely,
> Nick Goupinets.
>
> Simeon Penev wrote:
>
>> Hi,
>>
>> I've read  in the 'Event handling' section of the 'Portal engine' 
>> documentation that there is a way to pass 
>
>
> events between portlets. How can i do that? Could someone provide an 
> example?
>
>>
>> I've seen they are methods in the ManagedCocoonPortlet.java 
>> processAction and render, which are used 
>
>
> to deliver content to the portal. The problem is i cannot find a way 
> to invoke them by
>
> clicking on a link inside other portlet. What i am trying to 
> accomplish is to have
>
> the portlets subscribed to a certain type of event, as it is done with 
> the cocoon components using
>
> the Subscriber interface.
>
>>
>>
>> Thank you for your help in advance!
>>
>> Best regards,
>> Simeon __________________________________________________________
>> Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
>> weltweit telefonieren! http://freephone.web.de/?mc=021201
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>


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


Re: Interportlet communication

Posted by Nick Goupinets <ng...@openskysolutions.ca>.
Hi Simeon,

That's pretty easy to pass information (not events) between coplets. 
There is of course default ways of doing it with cl:link stuff. Just 
check the sample portal, image gallery coplets. I think that this is a 
bit tedious and not particularly convenient if flow is available.

With flow, that's how info can be passed

1) get portal service and set portal name there
2) get portal component manager
3) get profile manager
4) get coplet instance data
5) set any attributes in this coplet instance data

They can later be used in the sitemap for example by putting something 
like that:
<map:parameter name="textID" value="{coplet:attributes/textID}"/>

here is flow code:

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(copletId);
   // ADD OR REMOVE ANY ATTRIBUTES HERE
   // CHECK API FOR CopletInstanceData
} catch ( e ) {
   cocoon.log.info("Error");
}
finally {
   cocoon.releaseComponent( service );
}

Working with events is more complicated. Coplets are not themselves 
components so it's merely impossible to subscribe them for an event. You 
will need a cocoon component that implements publisher or subscriber 
interface. It will perform event processing. Here is what needs to be done:

1) create a new portal event type (or reuse some of the existing ones). 
it should hold all the necessary information for the step (2)
2) create new cocoon component that will be responsible for 
publishing/subscribing to the events from (1)
3) register component from (2) with the portal event manager (can be 
done at the run time)

Now you are ready for working with events. Please refer to the cocoon 
web site for the details how to carry out the actual processing (i.e. 
fire them off, publish, subscribe, etc.)

General hints are:
1) if you need to fire event immediately - just publish it
2) if you need to fire event on *any* click in the portal - use link 
service to add event to the link
3) if you need to fire event only in case of a particular link click - 
that's where it got tricky for me. I use link service to get the event 
encoded as a string. then I pass this string to a coplet where it's 
placed into an <a> html tag.

I worked with this stuff quite a bit of time ago (I used cocoon 2.1.5), 
so chances are that I missed something and something changed in the 
latest version of cocoon. I also hope that there are better ways of 
doing the stuff I described. Some feed back is greatly appreciated.

Thank you.

Sincerely,
Nick Goupinets.

Simeon Penev wrote:
> Hi,
> 
> I've read  in the 'Event handling' section of the 'Portal engine' documentation that there is a way to pass 

events between portlets. How can i do that? Could someone provide an 
example?
> 
> I've seen they are methods in the ManagedCocoonPortlet.java processAction and render, which are used 

to deliver content to the portal. The problem is i cannot find a way to 
invoke them by

clicking on a link inside other portlet. What i am trying to accomplish 
is to have

the portlets subscribed to a certain type of event, as it is done with 
the cocoon components using

the Subscriber interface.
> 
> 
> Thank you for your help in advance!
> 
> Best regards,
> Simeon 
> __________________________________________________________
> Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
> weltweit telefonieren! http://freephone.web.de/?mc=021201
> 
> 
> ---------------------------------------------------------------------
> 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