Liferay portlet: redirect to an other jsp page from javascript

后端 未结 2 1781
猫巷女王i
猫巷女王i 2021-01-22 19:29

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

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-22 20:08

    Try this:

    In your JSP ->

    
      
    
    
    
    
    
      A.one('.myLink').on('click', function () {
        window.location.href = '${myRenderURL}';
      });
    
    

    Then in your java portlet class ->

    @Override
    public void doView(RenderRequest request, RenderResponse response) 
        throws IOException, PortletException {
    
      String jspName = ParamUtil.getString("jspName", "view.jsp");
      include("path/to/your/jsp/" + jspName, request, response);
    
    }
    

    One last note: Starting with Liferay 6.2, portlet urls created with javascript methods mentioned in the OP above will

    • not include authentication tokens (p_auth, p_p_auth)
    • not be converted to friendly urls by the portal.

    Also see the Liferay Documentation on this.

提交回复
热议问题