2017-04-09 91 views
0

我使用Liferay 6.2作爲我的門戶平臺。我的問題是,如果有一種方法通過ajax加載portlet?只提供portlet id。Liferay 6.2 - 從客戶端加載portlet

例如

這是portlet信息:

<portlet> 
    <portlet-name>my_portlet</portlet-name> 
    <instanceable>false</instanceable> 
    <private-session-attributes>false</private-session-attributes> 
    <header-portlet-javascript>/js/my_portlet/app.js</header-portlet- 
</portlet> 

<portlet> 
    <portlet-name>my_portlet</portlet-name> 
    <display-name>My Portlet</display-name> 
    <portlet-class>com.ui.portlets.generic.GenericPortlet</portlet-class> 
    <init-param> 
     <name>view-template</name> 
     <value>/view.jsp</value> 
    </init-param> 
    <expiration-cache>0</expiration-cache> 
    <supports> 
     <mime-type>text/html</mime-type> 
    </supports> 
    <portlet-info> 
     <title>myportlet</title> 
    </portlet-info> 
</portlet> 

我從客戶端(由JavaScript)想要得到的渲染HTML組件以及所有它的PARAMS和包含的文件?

回答

1

不是一個乾淨的方式,但我不知道其他任何東西。

有一些東西叫做小部件網址。

您可以通過任何portlet的配置獲取它。

enter image description here

現在的iframe中加載此URL。您將實現加載小程序而不刷新頁面的目標。

這是一些樣本片段。

window.Liferay = window.Liferay || {}; 

Liferay.Widget = function(options) { 
    options = options || {}; 

    var id = options.id || '_Liferay_widget' 
      + (Math.ceil(Math.random() * (new Date).getTime())); 
    var height = options.height || '100%'; 
    var url = options.url 
      || 'http://www.liferay.com/widget/web/guest/community/forums/-/message_boards'; 
    var width = options.width || '100%'; 

    var html = '<iframe frameborder="0" height="' + height + '" id="' + id 
      + '" src="' + url + '" width="' + width + '"></iframe>'; 
    return html; 
} 
相關問題