JSR 286 // Liferay ignores <alias> in <event-definition> of portlet.xml
Description
Environment
Attachments
relates
Activity

Carlos Santos May 22, 2013 at 9:51 AM
I think that the current solution is not valid.
If you have a portlet with one <event-definition>
that has an <alias>
, and another portlet sends an event with the name set in the <alias>
, the event reaches the second portlet (this is was fixed in this bug).
However, the method EventRequest.getEvent()
(invoked from processEvent(...)
), returns the event as defined in the <alias>
, instead of as defined in the <qname>
of the <event-definition>
.
EventRequest.getEvent()
"Returns the event that triggered the call to the processEvent method." so it should return the <qname>
of <event-definition>
, not the <alias>
.
In the example I attached, I have two portlets: PortletSender and PortletReceiver (see the .zip file attached to the bug, but use the portlet.xml files corrected by @Michael Young)
"PortletSender" can send this event:
being ns1="http://www.denodo.com/widget/portlet/portlet-sender"
"PortletReceiver" can receive this event:
After fixing this bug, when "PortletSender" sends the event ns1:event1
, it reaches "PortletReceiver" thanks to the <alias>
defined in the "PortletReceiver"'s portlet.xml.
However, the javax.portlet.Event
, returned by the method {{EventRequest.getEvent() }}(invoked from processEvent(...)
) represents the event x:event1
. But it should represent the event ns2:testEvent
instead.
Tested with "Liferay Portal 6.2.0 CE-Milestone 5" bundled with "Apache Tomcat 7.0.34"

EdG April 19, 2013 at 5:19 PM
Hello everyone! We are in the process of removing component "Portlet" from LPS. Please replace this issue's component, "Portlet", with a new component. There are over 200+ components, in the newly organized component list. Also, make the necessary adjustments to affected filters. Thanks!

Mark Jin March 20, 2013 at 6:27 PM
PASSED Manual Testing following the steps in the description.
Reproduced on:
Tomcat 7.0 + MySQL 5. Portal 6.1.20 EE GA2.
Portlet B does not receive the event.
Fixed on:
Tomcat 7.0 + MySQL 5. Portal 6.1.x EE GIT ID: f6bfdf784b571ea7b692c3b4b2215e5b03b5b32e.
Tomcat 7.0 + MySQL 5. Portal 6.2.x GIT ID: 5df200a1cc8ab505c635c7e1ba6099b754125a5f.
Portlet B able to receive the event.
eg: Event received = '01:20:11 21-03-2013'.

michael young March 20, 2013 at 10:44 AM
These are the plugins I used to test and debug this.

michael young March 8, 2013 at 12:44 PM
I found an error in your portlet.xml. Aliases are supposed to be specified on the receiver, not on the sender. I've attached correct portlet.xml files for your reference.
Details
Assignee
Mark JinMark Jin(Deactivated)Reporter
Carlos SantosCarlos SantosBranch Version/s
6.1.xBackported to Branch
CommittedFix Priority
3Git Pull Request
Story Points
3Components
Fix versions
Affects versions
Priority
Medium
Details
Details
Assignee

Reporter

Branch Version/s
Backported to Branch
Fix Priority
Git Pull Request
Story Points
Components
Fix versions
Affects versions
Priority
Zendesk Support
Linked Tickets
Zendesk Support
Linked Tickets
Zendesk Support

Liferay Portal ignores the <alias> element in the <event-definition> of portlet.xml
According to the JSR-286 spec:
"The portlet can specify additional alias names in order to enable portals performing an automatic wiring between events."
(section "PLT.15.2.4.1 Declaration in the deployment descriptor" of the JSR-286 spec)
According to this I should be able to wire a "supported-publishing-event" of one portlet and a "supported-processing-event" of another by setting an alias in one of them.
In my scenario I have two portlets: PortletSender and PortletReceiver.
PortletSender has a link. When the user clicks it, the portlet sends an event with the current date (a java.lang.String object)
When PortletReceiver receives this event, it shows it in a JSP.
Both portlets are in the same page.
The portlet.xml of PortletSender is:
<portlet-app version="2.0" ... xmlns:ns1="http://www.denodo.com/widget/portlet/portlet-sender">
<portlet>
<portlet-name>PortletSender</portlet-name>
...
<supported-publishing-event>
<qname>ns1:event1</qname>
</supported-publishing-event>
</portlet>
<event-definition>
<qname>ns1:event1</qname>
<alias xmlns:x="http://www.denodo.com/widget/portlet/portlet-receiver">x:testEvent</alias>
<value-type>java.lang.String</value-type>
</event-definition>
</portlet-app>
The portlet.xml of PortletReceiver is:
<portlet-app version="2.0" xmlns:ns2="http://www.denodo.com/widget/portlet/portlet-receiver">
<portlet>
<portlet-name>PortletReceiver</portlet-name>
<display-name>Portlet Receiver</display-name>
<portlet-class>com.denodo.test.PortletReceiver</portlet-class>
...
<supported-processing-event>
<qname>ns2:testEvent</qname>
</supported-processing-event>
</portlet>
<event-definition>
<qname>ns2:testEvent</qname>
<value-type>java.lang.String</value-type>
</event-definition>
</portlet-app>
You can see that the <alias> of "event1" is the same as the "qname" of "testEvent" in PortletReceiver.
However, the events never reach PortletReceiver.
If I change the qname of <event-definition> and <supported-processing-event> in PortletSender to "<qname xmlns:x="http://www.denodo.com/widget/portlet/portlet-receiver">x:testEvent</qname>", PortletReceiver receives the event.
Steps to Reproduce:
---------------------------------------
Unzip the attached file. It creates to directories: PortletReceiver and PortletSender.
Execute "maven war:war" in both directories.
Copy the files PortletSender.war and PortletReceiver.war to %LIFERAY_HOME%/deploy
In Liferay, add these portlets to the same page.
Click on the link " Send event" of "Portlet Sender"
Actual Results:
---------------------------------------
Portlet B does not receive the event.
Expected Results:
---------------------------------------
Portlet B should receive the event.
If Portlet B receives the event, prints the string "Event received: ..." in System.out.