liferay 中的 portlet 间通信

发布于 2024-11-26 20:28:30 字数 481 浏览 2 评论 0原文

我是liferay的新手。所以,我只想解释一下我的情况。

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

  • 左侧 portlet 包含两个超链接,如 demo1 和 demo1。演示2。
  • 我还有另外两个 portlet,即 demo1Portlet 和 demo1Portlet。 demo2Portlet。
  • 将显示“demo1Portlet”,而不是右侧 portlet 默认。
  • 现在我要做的是,如果我点击 demo2 链接,那么,右侧 portlet 将发生变化,它将显示“demo2Portlet”,如果我单击 在 demo1 链接上,它将在右侧显示“demo1Portlet”。

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

请尽快回复我。

我是liftray的新手,所以我不知道这是否可以通过IPC或不通过IPC来实现。请解释一下会发生什么。

谢谢。

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

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

  • 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?

Please reply to me as soon as possible.

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.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

带上头具痛哭 2024-12-03 20:28:30

有几种不同的方法可以让 portlet 相互通信。大多数内容都包含在 IPC后代<一个href="http://www.liferay.com/community/wiki/-/wiki/Main/Eventing+and+Shared+Render+Parameters;jsessionid=6CACC5A9C08E957058936D3368E3C24F.node-2" rel="nofollow">页面。

就您而言,您确实应该查看 客户端页面:

根据你的基本结构,

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

你会在“发送器 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”上:

 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.
 });

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:

With your basic structure

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

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; 
      }); 
 });

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.
 });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文