Creating the URL programmtically


Hi,

Below is the code ,to create the different types of request URL.

As we know in Liferay we have 3 types of URL

1.ActionRequest
2.RenderRequest
3.ResourceRequest.

//Create Render URL

PortletURL renderURL = PortletURLFactoryUtil.create( actionRequest,PortalUtil.getPortletId(actionRequest), themeDisplay.getLayout().getPlid(), "0");
renderURL.setParameter("customparam","customvalue");

actionResponse.sendRedirect(renderURL.toString());


If you want to create the ActionRequest put 1 instead of 0 in the last argument.

We can check the code in the PortletURLImpl class of liferay

if (_lifecycle.equals(PortletRequest.ACTION_PHASE)) {
_reservedParameters.put("p_p_lifecycle", "1");
}
else if (_lifecycle.equals(PortletRequest.RENDER_PHASE)) {
<_reservedparameters .put="" _reservedparameters.put="" else="" if="" lifecycle.equals="" ortletrequest.resource_phase="" p_p_lifecycle="" pre="">


Comments

  1. Good blog. I found this as really informative. I think the easiest way to create a URL object is to create it from a String that represents the "human-readable" form of the URL address. This is typically the form that another person will use to tell you about a URL.

    ReplyDelete

Post a Comment

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate