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(setParameter) to the URL we can have setPlid("----") , setWindowState("----"); also.

Comments

  1. Liferay portlet have different lifecycles action render and resource each phase we represend as p_p_lifecycle attribute. 1 for action phase, 0 for render phase and 2 for recourse phase.
    law essay writing service

    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