我有一个钩子create_account.jsp
。 在这个jsp我有一个javascript代码,我尝试在iframe弹出窗口或Liferay的一些弹出窗口中打开一个portlet。PortletURL在弹出框中打开另一个portlet
问题是:
如何给portlet URL?
我该如何访问它?
在该portlet中,我只想用YES或NO提出问题,并根据用户的答案重定向到其他页面。
我有一个钩子create_account.jsp
。 在这个jsp我有一个javascript代码,我尝试在iframe弹出窗口或Liferay的一些弹出窗口中打开一个portlet。PortletURL在弹出框中打开另一个portlet
问题是:
如何给portlet URL?
我该如何访问它?
在该portlet中,我只想用YES或NO提出问题,并根据用户的答案重定向到其他页面。
您可以使用renderURL标记。在JSP中,只需放置一个表单并使用您的MVCPortlet类创建所需的treatemnet。
<portlet:renderURL var="myPopuURL"windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>">
<portlet:param name="mvcPath" value="/myJspWithYesOrNo.jsp" />
</portlet:renderURL>
<script>
my_function_to_open_popup_with_url('<%=myPopuURL%>');
</sricpt>
注意的Liferay提供一种方式来创建弹出与AUI: http://www.liferay.com/community/liferay-projects/alloy-ui/demo?title=community-liferay-projects-alloy-ui-demos-dialog
要创建一个URL,您可以使用<portlet:renderURL>
或<liferay-portlet:renderURL>
<liferay-portlet:renderURL
var="testPopupURL"
portletName="testPopup_WAR_testPopupportlet"
windowState="<%=LiferayWindowState.POP_UP.toString() %>">
<liferay-portlet:param name="paramToPopup" value="customParameterToThePortlet" />
</liferay-portlet:renderURL>
portletName="testPopup_WAR_testPopupportlet"
这是您想要的portlet的portletId 打开。
windowState="<%=LiferayWindowState.POP_UP.toString() %>"
这对于在弹出窗口中显示portlet非常重要,否则它将打开带有导航和全部的完整liferay页面。
,你可以在你的JSP编写使用上述网址,并打开弹出式和内portlet中的javascript:
// this is one of creating function
function <portlet:namespace />showPopup(url) {
var url = url;
// this is one way of calling a pop-up in liferay
// this way is specific to liferay
Liferay.Util.openWindow(
{
dialog: {
cache: false,
width:800,
modal: true
},
id: 'testPopupIdUnique',
uri: url
}
);
}
// this is another way of creating a function in liferay
Liferay.provide(
window,
'<portlet:namespace />showAUIPopUP',
function(url) {
var A = AUI();
// this is another way of calling a iframe pop-up
// this way is not specific to liferay
popupDialog = new A.Dialog(
{
id: 'testPopupIdUnique',
centered: true,
draggable: true,
resizable: true,
width: 800,
stack: true
}
).plug(
A.Plugin.DialogIframe,
{
uri: url,
iframeCssClass: 'ogilvy-dialog-iframe'
}
);
popupDialog.render();
},
['aui-dialog','aui-dialog-iframe']
);
您可以直接调用这些JavaScript函数是这样的:
<a href="javascript: <portlet:namespace />showPopup('<%=testPopupURL%>')">
Popup using Liferay open-window
</a>
<a href="javascript: <portlet:namespace />showAUIPopUP('<%=testPopupURL%>')">
Pop-up using Alloy UI dialog
</a>
这将弹出的iframe
内展示的门户要么应该有<add-default-resource>true</add-default-resource>
在liferay-portlet.xml
为:
<portlet>
<portlet-name>testPopup</portlet-name>
<icon>/icon.png</icon>
<instanceable>false</instanceable>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
<css-class-wrapper>testPopup-portlet</css-class-wrapper>
<!-- This property is necessary otherwise you would see a "Access denied for portlet" message when you try to open this portlet dynamically -->
<add-default-resource>true</add-default-resource>
</portlet>
还是应当具备的使用性能portlet.add.default.resource.check.whitelist
在portal-ext.properties
为:
portlet.add.default.resource.check.whitelist=3,56_INSTANCE_0000,58,82,86,87,88,103,113,145,164,166,170,177,testPopup_WAR_testPopupportlet
看看这个代码在行动,你可以从这里下载2个portlet和参考说明书中this liferay forum。
希望这有助于更好地理解liferay。