Liferay中的Portlet间通信 [英] Inter portlet communication in liferay

查看:75
本文介绍了Liferay中的Portlet间通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Liferay.所以,我只想解释一下我的情况.

I am new in liferay. So, I just want to explain my scenario.

实际上,我的网页上有两个portlet-一个在左侧,另一个在右侧:

Actually I have two portlet on my web page - one is in left side and other is on right side:

  • 左侧portlet包含两个超链接,例如demo1&演示2.
  • 我还有另外两个portlet,例如demo1Portlet& demo2Portlet.
  • 将通过以下方式而不是右侧portlet显示"demo1Portlet" 默认.
  • 现在我要做的是,如果我单击demo2链接,则在右侧 portlet将更改,并且将显示"demo2Portlet",如果我单击 在demo1链接上,然后它将在右侧显示"demo1Portlet".
  • he left side portlet contains two hyperlink say demo1 & demo2.
  • And I have another two portlet say demo1Portlet & demo2Portlet.
  • Instead of right side portlet "demo1Portlet" will be displayed by default.
  • Now what I have to do is, if I click on demo2 link then, right side portlet will change and it will display "demo2Portlet" and if I click on demo1 link then it will display "demo1Portlet" on right side.

谁能知道我该如何完成这项任务?

Can any one know how I can achieve this task?

请尽快回复我.

我不熟悉liftray,所以我不知道这可以通过IPC来实现,也可以不用它来实现.请说明将采用何种方式.

I am new to liftray, so I don't know whther this can be achieved through IPC or without it. Please explain whatever will be the way.

谢谢.

推荐答案

有几种不同的方法可以使Portlet相互通信.大多数文档都包含在页面.

There are a couple of different ways to have portlets talk with each other. Most are covered under the documentation of IPC's and the descendant pages.

对于您而言,您应该真正查看

In your case, you should really look at the client-side page:

具有基本结构

<a href="javascript:void(0)" class="comm-demo">demo[number]</a>

您将在发送器portlet"上使用此JS:

You would have this JS on the "transmitter portlet":

// you may need to have jQuery instead of $. Liferay may have its own 
// $ function which jQuery shouldn't mess with.
$( function () { 
      $('a.comm-demo').click( function(event) { 
           var txt = $(this).next().val(); // demo<number> 
           Liferay.trigger('click', {text: txt}); 
           return false; 
      }); 
 });

然后在接收portlet"上:

Then on the "receiving portlet(s)":

 Liferay.bind( 
      'click', 
      function(event, data) { 
           var txt = data.text;
           // this will set all class-of-fields to have the text 
           // "demo<number from above>Portlet"
           $('.class-of-fields')[0].html(txt + "Portlet"); 
           // I believe there is a way to minimize/maximize a portlet by 
           // simulating a mouse click, but research would be needed to 
           // confirm.
 });

这篇关于Liferay中的Portlet间通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆