Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
IPC Events - in different pages
I have 2 portlets (lets say Portlet A1 & Portlet A2) which communicates via IPC-Events mechanism. Specifically, Portlet A1 has a form which takes in INPUT from end User and passes the data to Portlet A2 (Portlet A1 fires an event through processAction method), which processes the data and show some result (Portlet A2 processes the event through processEvent method).
Now, if I place the portlet in the same page they are working fine. But when I place the portlets in different pages it is not working anymore.
FYI ...
I have tried
Again, I implemented the same scenario using Ajax (Client side Event - Liferay.fire & Liferay.on), lets say Portlet B1 & B2, but the result was same, worked when both portlets are placed in same page and not when they are placed in different page. When from Page#1 I am trying to trigger the event from Portlet A1 and the Receptor (Portlet A2) is on Page#2, in the console I am getting some thing like:
My 2nd query is, even when the portlets are placed in the same page, when I submit the portlet A1, the complete page refreshes and when it reloads the Portlet A2 shows the result. I want to avoid the complete page refresh. How can I just refresh the Portlet A2 to show the result? (Remember here I am talking about the 1st scenario where the event mechanism is NOT implemented through Ajax)
To sum up:
Query#1: Sender and Receiver Portlet in different pages
Query#2: Refresh Receiver Portlet without refreshing the page (when placed in same page and not with Ajax)
Using: Liferay 6.2 GA6, Tomcat, Java 1.7
Now, if I place the portlet in the same page they are working fine. But when I place the portlets in different pages it is not working anymore.
FYI ...
I have tried
portlet.event.distribution=ALL & portlet.event.distribution=layout-set in portal-ext.properties, but none of that worked.Again, I implemented the same scenario using Ajax (Client side Event - Liferay.fire & Liferay.on), lets say Portlet B1 & B2, but the result was same, worked when both portlets are placed in same page and not when they are placed in different page. When from Page#1 I am trying to trigger the event from Portlet A1 and the Receptor (Portlet A2) is on Page#2, in the console I am getting some thing like:
Reject process action for http://localhost:8080/web/guest/page2 on a1portlet_WAR_a1portletMy 2nd query is, even when the portlets are placed in the same page, when I submit the portlet A1, the complete page refreshes and when it reloads the Portlet A2 shows the result. I want to avoid the complete page refresh. How can I just refresh the Portlet A2 to show the result? (Remember here I am talking about the 1st scenario where the event mechanism is NOT implemented through Ajax)
To sum up:
Query#1: Sender and Receiver Portlet in different pages
Query#2: Refresh Receiver Portlet without refreshing the page (when placed in same page and not with Ajax)
Using: Liferay 6.2 GA6, Tomcat, Java 1.7
Cross page IPC will not work.
Portlets on page 2 are not instantiated/ready unless the user actually goes to the page; an IPC event from portlet 1 on page 1 has no one available to receive the event.
The portlet lifecycle is invoked in the process of handling the current page, I don't even think the receiver on page 2 would ever be delivered.
You might try using the LMB to send a message to the other portlet, this would work across pages, but you still have the issue of the portlet not being ready unless the user has landed on the page. Even then you'd have to figure out how one instance of portlet 1 on page 1 can send a message to just one instance of portlet 2 on page 2.
My suggestion? Instead of messaging you use a friendly URL for portlet 2 that includes parameter values. That way portlet 1 from page 1 can provide links that the user can click on and that's when portlet 2 on page 2 would be rendered and the parameters can be used to make necessary display choices.
Portlets on page 2 are not instantiated/ready unless the user actually goes to the page; an IPC event from portlet 1 on page 1 has no one available to receive the event.
The portlet lifecycle is invoked in the process of handling the current page, I don't even think the receiver on page 2 would ever be delivered.
You might try using the LMB to send a message to the other portlet, this would work across pages, but you still have the issue of the portlet not being ready unless the user has landed on the page. Even then you'd have to figure out how one instance of portlet 1 on page 1 can send a message to just one instance of portlet 2 on page 2.
My suggestion? Instead of messaging you use a friendly URL for portlet 2 that includes parameter values. That way portlet 1 from page 1 can provide links that the user can click on and that's when portlet 2 on page 2 would be rendered and the parameters can be used to make necessary display choices.
Thanks David. Thanks for the suggestion and the insight as well.
Can you throw some light on the second query?
If I keep both the Sender and Receiver Portlets in the same page, is there way I can receive the event in the receiving portlet without refreshing the page and also not using Ajax?
This will be really helpful.
Can you throw some light on the second query?
Query#2: Refresh Receiver Portlet without refreshing the page (when placed in same page and not with Ajax)
If I keep both the Sender and Receiver Portlets in the same page, is there way I can receive the event in the receiving portlet without refreshing the page and also not using Ajax?
This will be really helpful.
No, it's pretty much either/or. You can do the full page refresh or you can use ajax to request the update in that section. There's really no other option...