Adding eventlistener to a portlet through configuration file

View: New views
1 Messages — Rating Filter:   Alert me  

Adding eventlistener to a portlet through configuration file

by cedric.tran-xuan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,
I've got a problem. I wanted to attach an event and its listener to the
BannerPortlet of the portal. I thus modified the configuration file to
get this one:

<webui-configuration>
 <ui-component-config id="UIBannerPortlet">
   <type>org.exoplatform.portal.webui.application.UIGroovyPortlet</type>
   
<lifecycle>org.exoplatform.groovy.webui.component.lifecycle.UIGroovyPortletLifecycle</lifecycle>

   <events>
     <event>
       <event-name>show.account.event</event-name>
       <listener>org.mycompany.ShowAccountSettingsListener</listener>
     </event>
   </events>
 </ui-component-config>

 <application>
   
<ui-component-root>org.exoplatform.portal.webui.application.UIGroovyPortlet</ui-component-root>

   
<state-manager>org.exoplatform.webui.application.portlet.ParentAppStateManager</state-manager>

 </application>
</webui-configuration>

My aims was to modify the associated groovy template to create link on
the event. Something like:
String myEvent = uicomponent.event( "show.account.event" );
<a href="$myEvent">blabbla</a>

But it doesn't work. I get: myEvent=??config??.

 From what I have seen:
1) the ConfigurationManager of the portlet is correctly fed with the
objects declared in the configuration file. Especially, its map
"configs_" has a Component object instanciated with my event and its
listener but its associated key is
"org.exoplatform.portal.webui.application.UIGroovyPortlet:UIBannerPortlet".
(seen in org.exoplatform.webui.application.WebuiApplication.onInit())
 From what I understood, this Component object that holds my event and
its listener should be then associated to my portlet (meaning my webui
root component i.e. UIGroovyPortlet)
2) but when org.exoplatform.portal.application.PortalStateManager is
creating the uiroot component (UIGroovyPortlet), it calls:

   restoreUIRootComponent(WebuiRequestContext)
   ->
org.exoplatform.webui.application.WebuiApplication.createUIComponent(org.exoplatform.portal.webui.application.UIGroovyPortlet.class,
null, null, requestContext)
   ->
org.exoplatform.webui.application.ConfigurationManager.getComponentConfig(org.exoplatform.portal.webui.application.UIGroovyPortlet.class,
null)

at this stage, the latter method is looking for a key
"org.exoplatform.portal.webui.application.UIGroovyPortlet" to the
ConfigurationManager. Since not such key exists (indeed the original key
was
"org.exoplatform.portal.webui.application.UIGroovyPortlet:UIBannerPortlet"),
no Component is returned and thus my portlet gets a new brand default
one. As matter of fact, I've lost my event and its listener...
OK, my explanation seems a bit tedious, but add breakpoints to the above
methods, and you will understand straight (if not yet :-) ).
I tried to remove the id="UIBannerPortlet" as workaround but I lost the
banner itself... worse then... :-(

I would appreciate any feedback about best practices to attach event to
webuicomponent.

Thanks in advance,

Cédric.


--
You receive this message as a subscriber of the exoplatform@... mailing list.
To unsubscribe: mailto:exoplatform-unsubscribe@...
For general help: mailto:sympa@...?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
LightInTheBox - Buy quality products at wholesale price!