Sunday, August 4, 2013

Redirecting from the Render Method in Liferay

Redirecting from the Action method is easy when compare with the Redirecting from the Render Method.To Redirect from the Action method we simply use the below code.

" actionResponse.sendRedirect(PortalUtil.getLayoutURL(themeDisplay)); "

PortalUtil.getLayoutURL(themeDisplay)  : example URL where you want to redirect the after the performing some action 

To Redirect From the Render method the below code can be Used :-

viewTemplate="/particular page URL";

                           or

try {
HttpServletResponse servletResponse = PortalUtil.getHttpServletResponse(actionResponse);
PrintWriter pw;
           try {
               pw = servletResponse.getWriter();
               pw.write(PortalUtil.getLayoutURL(themeDisplay).toString());
       pw.close();
           } catch (IOException e) {
               e.printStackTrace();
   }
}catch(Exception e) {
        e.printStackTrace();
}

No comments:

Liferay DXP JNDI Data Source Cofiguration

 This Blog will help us to learn about the JNDI Data Source Configuration in Liferay DXP. We have tested this with Liferay 7.3 with Tomcat. ...