Liferay portlet:从javascript重定向到其他jsp页面 [英] Liferay portlet: redirect to an other jsp page from javascript

查看:159
本文介绍了Liferay portlet:从javascript重定向到其他jsp页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从js重定向到liferay portlet中的另一个jsp页面。我发现的想法是使用renderurl。我找到的最好的代码可以帮助我作为第一步:

I want to redirect to an other jsp page in a liferay portlet from js. The idea that I found is using a renderurl. The best code that I found that can help me as a first step is this one:

<a id="renderURLWithJS" href=""> This render URL link is created with Javascript</a>
<aui:script>
    AUI().use('liferay-portlet-url', function(A) {
    var param="Hello new jsp"; 
    var renderUrl1 = Liferay.PortletURL.createRenderURL();
    renderUrl1.setWindowState("<%=LiferayWindowState.NORMAL.toString() %>");
    renderUrl1.setParameter("param",param);
    renderUrl1.setParameter('mvcPath', 'display.jsp'); /* is this correct???*/
    renderUrl1.setPortletMode("<%=LiferayPortletMode.VIEW %>");
    A.one("#renderURLWithJS").set('href',renderUrl1.toString());
    });
</aui:script>

但问题是我总是被重定向到同一个实际页面(view.jsp)而不是到我想要的jsp页面display.jsp。

But the problem is that I'm always redirected to the same actual page (view.jsp) not to the jsp page that I want display.jsp.

有人知道我的代码有什么问题吗?

Does someone have an idea what's wrong with my code?

推荐答案

Liferay需要知道您添加到URL的任何请求参数的目标portlet - 否则它会忽略任何未知参数。目标portlet的ID定义为 p_p_id ,或者它是参数的前缀(在这种情况下,您可以在一个URL中为多个portlet定义参数)。

Liferay needs to know the target portlet for any request parameter that you add to an URL - otherwise it ignores any unknown parameter. The ID of the target portlet is either defined as p_p_id or it is a prefix of the parameter (in which case you can define parameters for more than one portlet in one URL).

所以在你的情况下你必须设置 renderUrl1.setPortletId('...你的portlet id'); 让你的portlet看到 mvcPath param

So in your case you will have to set renderUrl1.setPortletId('...your portlet id'); to let your portlet see mvcPath and param.

此外, mvcPath 必须是绝对的(以 / 开头)并低于配置的 templatePath (默认为 / )。

In addition the mvcPath must be absolute (start with a /) and below the configured templatePath (defaults to /).

这篇关于Liferay portlet:从javascript重定向到其他jsp页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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