Wednesday, July 08, 2015

Creating Portlet URLs


Listed below are various ways to create portlet action and render phase URLs

Creating URL within/to the current portlet.

1. Using Taglib:

For Render URL

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:renderURL var="myRenderURL1" windowState="<%=LiferayWindowState.NORMAL.toString()%>">
<portlet:param name="mvcPath" value="/html/view/myresponse.jsp"/>
</portlet:renderURL>

Similarly action URL looks like below
<portlet:actionURL var="myActionURL1" windowState="<%=LiferayWindowState.NORMAL.toString()%>">
<portlet:param name="cmd" value="update"/>
</portlet:actionURL>

2. Using Java code

For render URL
PortletURL myRenderURL2=renderResponse.createRenderURL();
myRenderURL2.setWindowState(LiferayWindowState.NORMAL);
myRenderURL2.setParameter("cmd", "view");
Similarly action URL looks like below
PortletURL myActionURL2=renderResponse.createActionURL();
myActionURL2.setWindowState(LiferayWindowState.NORMAL);
myActionURL2.setParameter("cmd", "update");

Creating URL outside the current portlet, that is URL to the other page or portlet.


PortletURL myRenderURL3= PortletURLFactoryUtil.create(request,  themeDisplay.getPortletDisplay().getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

 myRenderURL3.setWindowState(LiferayWindowState.NORMAL);
 myRenderURL3.setPortletMode(LiferayPortletMode.VIEW);
 myRenderURL3.setParameter("jspPage", "/season/rainy.jsp");

Here themeDisplay.getPortletDisplay().getId() is the id of the current portlet to be viewed or it can be the id of the other portlet to be viewed and themeDisplay.getPlid() is the page layout Id of the current page and can point to the plid of some other page on which the portlet is deployed.


5 comments:

  1. Thanks for the excellent blog post! I actually experienced studying it. You’ll be an excellent writer. I love to post a comment that "The content of your post is beautiful".So, please keep on update like this post.
    Engineering Colleges, ECE Engineering Colleges in Chennai

    ReplyDelete
  2. Thank u for your information and get more interested topic to write your page For more Detail:Gounder Matrimony,Devar MatrimonyChettiar Matrimony,Christian Matrimony.

    ReplyDelete
  3. The article that you created is very useful, hopefully thank you also visit my blog ---

    car rental service in bangladesh

    ReplyDelete