Posts

Showing posts with the label resourceurl

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)) {

Ajax Implementation in the Liferay

Creating the Resource URL Liferay's default uses the resource url for ajax requests          <portlet:resourceURL id="addResource" var="addResourceURL">         </portlet:resourceURL> Creating the Ajax function creating the Jquery  ajax function function <portlet:namespace/>getEntries(){                 var url = "${addResourceURL}";                         $.ajax({                                 type : "POST",                                 url : url,                                 dataType : "JSON",                 ...

Creating URL in Javascript in Liferay

Sometimes it may requires to create URL in Javascript. In Liferay we can create any URL in Javascript.  In Normal Case we can create Action URL as            < portlet:actionURL var="testURL" name="update" /> In Javascript we create as           <aui:script>            AUI().ready('liferay-portlet-url', function(A){           var actionURL = Liferay.PortletURL. createActionURL ();          actionURL .setParameter("cmd", "test");            });          </aui:script>    To create renderURL we put as Liferay.PortletURL. createRenderURL() ; in above script.    To Create resourceURL we put as Liferay.PortletURL. createResourceURL() ; Refer "LiferayPortletURL" interface to get more idea. Apart from the setting the parameter(...