cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Goupinets <ngoupin...@openskysolutions.ca>
Subject Re: Interportlet communication
Date Tue, 26 Apr 2005 18:43:51 GMT
Hi Simeon,

> when the component (the subscriber) is instantiated. 

Sorry, I don't know what's the proper "subscribing" pattern. I tried 
subscribing every time I create an event and it worked ok. However, I am 
not sure how it's implemented, so chances are that there can be memory 
leaks because of that (i.e. some components will not be released, 
especially the not ThreadSafe components).

Here is the flow that I use:

var eventManager = null;
var myComponent = null;
var portalService = null;
try {
   // initialize components
   eventManager = cocoon.getComponent(
	org.apache.cocoon.portal.event.EventManager.ROLE);

   myComponent = cocoon.getComponent(
	Packages.test.myComponent.ROLE);

   portalService = cocoon.getComponent(
	org.apache.cocoon.portal.PortalService.ROLE);
			
   portalService.setPortalName("portal");
			
   // register custom component for processing add coplet events
   // it's ok to do that multiple times, as component is thread safe
   // and there is a check in the eventManager if a component
   // has already been subscribed
   eventManager.getRegister().subscribe( myComponent );
}	

Again, I didn't have time to investigate further, but I am sure that 
there should be a way to subscribe a component in portal configuration 
in cocoon.xconf.

BTW, all flow code will look almost the same in a Java class. Pretty 
much the only thing that needs to be done is adding proper types to the 
variables.

Thank you.
Sincerely,

Nick Goupinets

> users@cocoon.apache.org schrieb am 26.04.05 17:17:56:
> 
>>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
>>
> 
> 
> 
> ______________________________________________________________
> Verschicken Sie romantische, coole und witzige Bilder per SMS!
> Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message