掲示板

Inter Portlet Communication (IPC) for Portlets on Different Page

15年前 に Dawn Yang によって更新されました。

Inter Portlet Communication (IPC) for Portlets on Different Page

New Member 投稿: 7 参加年月日: 08/05/13 最新の投稿
I am trying to do IPC between two portlets on different page. Anyone has any examples or documentation on this topic? Thanks!
thumbnail
15年前 に Deepak Gothe によって更新されました。

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

Junior Member 投稿: 44 参加年月日: 08/05/19 最新の投稿
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
15年前 に Dawn Yang によって更新されました。

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

New Member 投稿: 7 参加年月日: 08/05/13 最新の投稿
Hi,

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

Thanks!
thumbnail
15年前 に Deepak Gothe によって更新されました。

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

Junior Member 投稿: 44 参加年月日: 08/05/19 最新の投稿
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
15年前 に Ray Augé によって更新されました。

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

Liferay Legend 投稿: 1197 参加年月日: 05/02/08 最新の投稿
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?
15年前 に Alf Høgemark によって更新されました。

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

Junior Member 投稿: 34 参加年月日: 08/05/24 最新の投稿
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
15年前 に Alf Høgemark によって更新されました。

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

Junior Member 投稿: 34 参加年月日: 08/05/24 最新の投稿
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
15年前 に Jens Volgmann によって更新されました。

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

Junior Member 投稿: 43 参加年月日: 08/09/01 最新の投稿
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
15年前 に Manish Kumar Gupta によって更新されました。

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

Liferay Master 投稿: 535 参加年月日: 08/05/16 最新の投稿
You can see source code as well as binary for eventing and public render parameter portlets here.
thumbnail
15年前 に domingo l hilario によって更新されました。

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

Junior Member 投稿: 46 参加年月日: 09/02/05 最新の投稿
I did that and now all my portlets says null
14年前 に Rémi Gauthier によって更新されました。

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

New Member 投稿: 9 参加年月日: 09/02/13 最新の投稿
You just need to undeploy and redeploy your portlets with the new container sun to avoid the "null".
thumbnail
11年前 に Nicolas Tamayo によって更新されました。

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

Junior Member 投稿: 29 参加年月日: 12/10/03 最新の投稿
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
14年前 に Ahmed Hasan によって更新されました。

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

Expert 投稿: 306 参加年月日: 07/04/13 最新の投稿
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
13年前 に abdul quddhus によって更新されました。

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

New Member 投稿: 6 参加年月日: 10/01/19 最新の投稿
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
13年前 に ankit yakkundi によって更新されました。

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

Regular Member 投稿: 221 参加年月日: 10/03/05 最新の投稿
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
13年前 に Thiago Leão Moreira によって更新されました。

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

Liferay Legend 投稿: 1449 参加年月日: 07/10/10 最新の投稿
Hi Ankit,

You can use public render parameters feature to achieve that.
thumbnail
13年前 に ankit yakkundi によって更新されました。

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

Regular Member 投稿: 221 参加年月日: 10/03/05 最新の投稿
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..
3年前 に Montej Shah によって更新されました。

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

Junior Member 投稿: 48 参加年月日: 15/02/18 最新の投稿
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();
    }