0

I'm working on a Liferay portlet with spring MVC portlet.

Is it possible to open new Jsp file or call render mapping method from resource mapping method?

Kallel Omar
  • 1,208
  • 2
  • 17
  • 51

1 Answers1

0

If you don't bother changing AJAX call to regular call, you can handle it nicely through processAction mapping, as after each action render mapping is automatically called. You can set render parameter(s) in action mapping and get in render mapping for conditional inclusion of view.

However, if you want to do it through AJAX call, you can handle redirection using javascript once the AJAX call is completed / failed. Liferay has provided javascript API to create dynamic URLs. You can create renderURL, set required parameters for it and change location of page as per your requirement.

For reference, you can see:
https://www.liferay.com/community/forums/-/message_boards/message/32061619 http://www.liferay.com/community/forums/-/message_boards/message/45486103 http://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/creating-portlet-urls-in-javascript-liferay-portal-6-2-dev-guide-07-en

Parkash Kumar
  • 4,710
  • 3
  • 23
  • 39
  • My final want is that I have to pass a a parameter from js to an other JSP. I tried to build a render url in JS and set this value as an url parameter and then redirect. But I wasn't able. So I thought that I send via ajax the parameter to the Liferay server. And then I redirect to the new jsp. I found that I can do it via resource URL. But I'm now thinking about is send it to a servlet. And from this servlet I redirect to the new JSP. – Kallel Omar Sep 17 '15 at 08:57
  • You can set parameter var portletURL = Liferay.PortletURL.createRenderURL(); portletURL.setParameter('groupId', '<%= scopeGroupId %>'); if you are creating it using javascript. – Parkash Kumar Sep 17 '15 at 08:57
  • but I wasn't able to create the URL: http://stackoverflow.com/questions/32520452/liferay-portlet-redirect-to-an-other-jsp-page-from-javascript – Kallel Omar Sep 17 '15 at 09:06
  • Don't do like this, send a parameter like view = edit / list as parameter then in render mapping method, filter your includes using request parameter. – Parkash Kumar Sep 17 '15 at 09:09
  • String view = ParamUtil.getString(renderRequest, "view"); if(view != null && view.equals("edit")){ // Perform pre-operations, set render parameters include(editJSP, renderRequest, renderResponse); }else{ include(viewJSP, renderRequest, renderResponse); } – Parkash Kumar Sep 17 '15 at 09:13