Foren

Inter Portlet Communication (IPC) for Portlets on Different Page

Dawn Yang, geändert vor 15 Jahren.

Inter Portlet Communication (IPC) for Portlets on Different Page

New Member Beiträge: 7 Beitrittsdatum: 13.05.08 Neueste Beiträge
I am trying to do IPC between two portlets on different page. Anyone has any examples or documentation on this topic? Thanks!
thumbnail
Deepak Gothe, geändert vor 15 Jahren.

Re: [Liferay Forums][3. Development] Inter Portlet Communication (IPC) for

Junior Member Beiträge: 44 Beitrittsdatum: 19.05.08 Neueste Beiträge
You can achieve this by adding the following properties to
portal-ext.properties.

portlet.container.impl=sun
portlet.event.distribution=ALL_PORTLETS

Currently it works for only those portlets that are in "Undefined"
category. This will be fixed shortly so that it will work for all
portlets irrespective of its category.
After the above change you may need to deploy the portlets again.

Regards,
Deepak
Dawn Yang, geändert vor 15 Jahren.

RE: Re: [Liferay Forums][3. Development] Inter Portlet Communication (

New Member Beiträge: 7 Beitrittsdatum: 13.05.08 Neueste Beiträge
Hi,

This works for both JSR-286 Shared render parameters and Events? Or just for Liferay's Client-side Inter-Portlet Communication?

Thanks!
thumbnail
Deepak Gothe, geändert vor 15 Jahren.

Re: [Liferay Forums][3. Development] Inter Portlet Communication (

Junior Member Beiträge: 44 Beitrittsdatum: 19.05.08 Neueste Beiträge
The distribution of events and public render parameters works across the
tabs. For public render parameters you need to use the following property.
portlet.public.render.parameter.distribution=ALL_PORTLETS


Regards,
Deepak
thumbnail
Ray Augé, geändert vor 15 Jahren.

Re: [Liferay Forums][3. Development] Inter Portlet Communication (IPC) for

Liferay Legend Beiträge: 1197 Beitrittsdatum: 08.02.05 Neueste Beiträge
I'm not sure I understand the problem of using the OOTB support for
shared render parameters.

These work across pages!

Once they are configured (using the JSR-286 definitions for
configuration) they will work for any portlet on any page as long as the
portlet supports the parameter and the param is in the request (POST|GET
doesn't matter).

I just did some examples for a client, everything worked perfectly.

Is someone seeing an issue?
Alf Høgemark, geändert vor 15 Jahren.

RE: Re: [Liferay Forums][3. Development] Inter Portlet Communication (

Junior Member Beiträge: 34 Beitrittsdatum: 24.05.08 Neueste Beiträge
Hi

I also do not see the need for changing portlet event delivery configurations for this to work.

My only questions is how do I know the name of the parameter to pass in the URL ?

I have one portlet page A, with two portlets that both have defined that they support the "product_id" public render parameter.

Then on page B, I want to construct an URL and print that URL in an <a href""> tag. When the user clicks the tag, he should see the portlet page A, with the two portlets displaying the info for the specified product id.

Currently, I see that I must name my URL parameter "p_r_p_-868126208_product_id",
so the URL I generate look like this <a href="test_view_product?p_r_p_-868126208_product_id=1">Read more</a>

Clearly, I do not want to hardcode this "p_r_p_-868126208_" prefix to my parameter name.
I do not know how that prefix is generated.


How do I construct the proper name of a public render parameter on one page, so that it can be used in an URL pointing to another page, so that the value is readable for portlets on that other page ?

Regards
Alf Hogemark
Alf Høgemark, geändert vor 15 Jahren.

RE: Re: [Liferay Forums][3. Development] Inter Portlet Communication (

Junior Member Beiträge: 34 Beitrittsdatum: 24.05.08 Neueste Beiträge
Hi again

Looking at the Liferay source code itself helped me out this time as well.

I now use the following code in my JSP page:
<%
QName produktIdQName = new QName("http://www.bouvet.no/loop/sortere/params", "produkt_id");
%>
<c:set var="produkt_id_public_param_name" value="<%= QNameUtil.getPublicRenderParameterName(produktIdQName)%>"/>
<p><a href="test_vis_produkt?${produkt_id_public_param_name}=${produktType.produktTypeId}">Read more</a></p>


and my portlet-ext.xml looks like this :
<public-render-parameter>
<description>The ID for a single produkt of type ProduktType</description>
<identifier>produkt_id</identifier>
<qname xmlns:bouvet="http://www.bouvet.no/loop/sortere/params">bouvet:produkt_id</qname>
</public-render-parameter>

This works, and to me it also seems like the correct way of doing this.

But it would be nice to get a confirmation from someone.

Regards
Alf Hogemark
thumbnail
Jens Volgmann, geändert vor 15 Jahren.

RE: Re: [Liferay Forums][3. Development] Inter Portlet Communication (

Junior Member Beiträge: 43 Beitrittsdatum: 01.09.08 Neueste Beiträge
I implemented it different ways with Liferay 5.2.2. Actullay nothing works.. Neither event distribution nor public render parameter. I'm looking for concrete examples. The sample sun jsr 286 portlets doesnot contain sources. Can anybody help me?
thumbnail
Manish Kumar Gupta, geändert vor 15 Jahren.

RE: Re: [Liferay Forums][3. Development] Inter Portlet Communication (

Liferay Master Beiträge: 535 Beitrittsdatum: 16.05.08 Neueste Beiträge
You can see source code as well as binary for eventing and public render parameter portlets here.
thumbnail
domingo l hilario, geändert vor 15 Jahren.

RE: Re: [Liferay Forums][3. Development] Inter Portlet Communication (

Junior Member Beiträge: 46 Beitrittsdatum: 05.02.09 Neueste Beiträge
I did that and now all my portlets says null
Rémi Gauthier, geändert vor 15 Jahren.

RE: Re: [Liferay Forums][3. Development] Inter Portlet Communication (

New Member Beiträge: 9 Beitrittsdatum: 13.02.09 Neueste Beiträge
You just need to undeploy and redeploy your portlets with the new container sun to avoid the "null".
thumbnail
Nicolas Tamayo, geändert vor 11 Jahren.

RE: Re: [Liferay Forums][3. Development] Inter Portlet Communication (IPC)

Junior Member Beiträge: 29 Beitrittsdatum: 03.10.12 Neueste Beiträge
Deepak Gothe:
You can achieve this by adding the following properties to
portal-ext.properties.

portlet.container.impl=sun
portlet.event.distribution=ALL_PORTLETS

Currently it works for only those portlets that are in "Undefined"
category. This will be fixed shortly so that it will work for all
portlets irrespective of its category.
After the above change you may need to deploy the portlets again.

Regards,
Deepak


Thanks Deepak, this code is very very helpful, this code has solved my issue. thanks.
Nicolas, regards.
thumbnail
Ahmed Hasan, geändert vor 14 Jahren.

RE: Inter Portlet Communication (IPC) for Portlets on Different Page

Expert Beiträge: 306 Beitrittsdatum: 13.04.07 Neueste Beiträge
We have done this quite elegantly.

Go to http://www.inikah.com.

On the home page, you give some search criteria (in the quick search portlet) and the results are diplayed in another portlet in another page.

Ok, i am sure that you are excited to see this in action.

Now coming to the implementation part, see the code for the "Quick Search" portlet here.

We have written the URL for the IPC here,

long layoutId = CommonUtil.getLayoutIdByFriendlyURL("qs-result");
PortletURL url = new PortletURLImpl(request, "quicksearchresults", layoutId , PortletRequest.RENDER_PHASE);


You should also notice that we have written a simple method to get the layout Id of the different page that needs to be invoked,

public static long getLayoutIdByFriendlyURL(String friendlyURLSuffix) {

long layoutId = 0l;

DetachedCriteria dCriteria = DetachedCriteria.forClass(Layout.class);
dCriteria.add(Restrictions.eq("friendlyURL", "/" + friendlyURLSuffix));
DynamicQuery dynamicQuery = new DynamicQueryImpl(dCriteria);

try {
List lOutList = LayoutLocalServiceUtil.dynamicQuery(dynamicQuery);

if (!lOutList.isEmpty()) {
layoutId = ((Layout)lOutList.get(0)).getPlid();
}
} catch (SystemException se) {
// ignore
}

return layoutId;
}


Hope this helps. If you find a better approach keep me informed. But this solution works perfectly well for us.

For any help feel free to contact me,

Ahmed Hasan
CTO, TransIT mPower Labs (P) Ltd.
info@mpowerglobal.com
mPower Global
A Liferay expert company.
thumbnail
abdul quddhus, geändert vor 13 Jahren.

RE: Inter Portlet Communication (IPC) for Portlets on Different Page

New Member Beiträge: 6 Beitrittsdatum: 19.01.10 Neueste Beiträge
Dears, we are using JSF porlet - Myfaces, how to submit form which is in pageA (with portlet A1) to another pageB (having portlet B1).
thumbnail
ankit yakkundi, geändert vor 13 Jahren.

RE: Inter Portlet Communication (IPC) for Portlets on Different Page

Regular Member Beiträge: 221 Beitrittsdatum: 05.03.10 Neueste Beiträge
hi..
I am using liferay 5.2.3 with tomcat 6.
I am able to achieve IPC when both the portlets are on the same page,but when it is on different page,then it does not work.
I am attaching the source code of the portlet(built using plug in sdk) as well as the war file.

I wanted to know whether there is any change in creation of IPC in Liferay 6 from 5??

Please tell me what i need to do ,so that portlets can communication when they are on different pages..

Any idea or suggestions are welcome..

Thanks in advance...
thumbnail
Thiago Leão Moreira, geändert vor 13 Jahren.

RE: Inter Portlet Communication (IPC) for Portlets on Different Page

Liferay Legend Beiträge: 1449 Beitrittsdatum: 10.10.07 Neueste Beiträge
Hi Ankit,

You can use public render parameters feature to achieve that.
thumbnail
ankit yakkundi, geändert vor 13 Jahren.

RE: Inter Portlet Communication (IPC) for Portlets on Different Page

Regular Member Beiträge: 221 Beitrittsdatum: 05.03.10 Neueste Beiträge
hi..
thanks for the reply.
I would be using struts portlet ie 168JSR.
can you help me on this???

any idea or suggestions are welcome..
thanks in advance..
Montej Shah, geändert vor 3 Jahren.

RE: Inter Portlet Communication (IPC) for Portlets on Different Page

Junior Member Beiträge: 48 Beitrittsdatum: 18.02.15 Neueste Beiträge
This is work for me on liferay 7.1
For event fire on different page

1) Setup the portal-ext.properties
portlet.event.distribution=layout-set # For Liferay 7.1 and also i think for 6.2, you can check property description for specific version on google

2) Setup the configuration for Event Producer

in annotation based on top of the class like below properties"com.liferay.portlet.action-url-redirect=true",
"javax.portlet.supported-publishing-event=selectedReport;https://my-liferay-namespace.com/events"

in xml based, in liferay-portlet.xml, this is must require to work the event on different page
<action-url-redirect>true</action-url-redirect> 
        
in portlet.xml    

<portlet>
...
...
        <supported-publishing-event>
                <qname xmlns:x="https://my-liferay-namespace.com/events">x:selectedReport</qname>
        </supported-publishing-event>
        
    </portlet>
    
    <event-definition>
        <qname xmlns:x="https://my-liferay-namespace.com/events">x:selectedReport</qname>
        <value-type>java.util.HashMap</value-type>
    </event-definition>

....

3) Setup the configuration for Event Receiver    
in annotation based on top of the class like below properties

"javax.portlet.supported-processing-event=selectedReport;https://my-liferay-namespace.com/events"

in xml based, in portlet.xml    

<portlet>
...
...
        <supported-processing-event>
                <qname xmlns:x="https://my-liferay-namespace.com/events">x:selectedReport</qname>
        <supported-processing-event>
        
    </portlet>
    
    <event-definition>
        <qname xmlns:x="https://my-liferay-namespace.com/events">x:selectedReport</qname>
        <value-type>java.util.HashMap</value-type>
    </event-definition>

4) Event Producer Code: Generate event and redirect the page

public void fireEventAction(ActionRequest actionRequest, ActionResponse actionResponse) {
        QName qName = new QName("https://my-liferay-namespace.com/events", "selectedReport");
        ThemeDisplay themeDisp = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);      
 HashMap<String, Object> responseDataMap = new HashMap<String, Object>();
        responseDataMap.put("myData", "My Test Data");
        actionResponse.setEvent(qName, responseDataMap);        

long plid = 0;
        try {
            plid = PortalUtil.getPlidFromPortletId(themeDisp.getScopeGroupId(), "com_EventReceiverPortlet");
        } catch (PortalException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        PortletURL url = PortletURLFactoryUtil.create(actionRequest, "com_EventReceiverPortlet", plid,
                PortletRequest.RENDER_PHASE);      
 try {
            actionResponse.sendRedirect(url.toString());
        } catch (IOException e1) {
            e1.printStackTrace();      
 }  
 }

5) Event Receiver Code: Receive event and check by the name
@Override
    public void processEvent(EventRequest request, EventResponse response) throws PortletException, IOException {
        Event event = request.getEvent();
        System.out.println("==Get Respsoe========================================================");        if (event.getName().equals("selectedReport")) {
            System.out.println("selectedReport Event found!");
            HashMap<String, Object> eventValue = (HashMap<String, Object>) event.getValue();
            System.out.println("===========show value of event " + eventValue.get("myData"));
        }
        super.processEvent(request, response);
    }    

or else for specific event seprate method
    @EventMapping(value = "{https://my-liferay-namespace.com/events}selectedReport")
    public void myEvent(EventRequest request, EventResponse response) throws PortletException, IOException {
        _logger.info("Enter into myEvent========================");
                Event event = request.getEvent();
        HashMap receivedParamMap = (HashMap) event.getValue();
    }