Fórum

How to use Liferay javascript ?

sri p, modificado 12 Anos atrás.

How to use Liferay javascript ?

Junior Member Postagens: 85 Data de Entrada: 22/01/11 Postagens Recentes
Hi,

I have requirement where I would like to use liferay javascript functions.
var renderURL = Liferay.PortletURL.createRenderURL();
alert( "renderURL: " + renderURL.toString() );


I tried to use the above code, but I am getting "Liferay.PortletURL is undefined".

Could anybody please help me, Does there any need to include liferay js files or any settings in portal-ext.properties to utilize liferay js.

Any help is really appreciated.

Thank you,
Sri
thumbnail
Jan Gregor, modificado 12 Anos atrás.

RE: How to use Liferay javascript ?

Regular Member Postagens: 224 Data de Entrada: 20/10/10 Postagens Recentes
Hi,

From which context are you trying to access this javascript call ?

Regards,
Jan.
sri p, modificado 12 Anos atrás.

RE: How to use Liferay javascript ?

Junior Member Postagens: 85 Data de Entrada: 22/01/11 Postagens Recentes
Hi Jan,

I am making the call in jsp javascript block like following:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="liferay-aui"%>

<portlet:defineobjects />

<c:set var="namespace"><portlet:namespace /></c:set>

[b]<script type="text/javascript">

 var resourceURL = '<portlet:resourceURL/>';
 var $jq = jQuery.noConflict();
 $jq(document).ready(function(){
 alert ( " liferay url : "+ Liferay.PortletURL.createRenderURL());
  }); // EOF ready function

alert ( " liferay url : "+ Liferay.PortletURL.createRenderURL());
  
</script>[/b]


It seems, in Liferay 6.0.11 in portlet_url.js we should call these functions using AUI() calls,
if it is that so, could you provide me an example.

Thank you in advance,
Sri
Mahesh Narke, modificado 9 Anos atrás.

RE: How to use Liferay javascript ?

Regular Member Postagens: 105 Data de Entrada: 11/10/13 Postagens Recentes
Hi Sri,
Did you get any solution for this?
thumbnail
Pankaj Kathiriya, modificado 9 Anos atrás.

RE: How to use Liferay javascript ?

Liferay Master Postagens: 722 Data de Entrada: 05/08/10 Postagens Recentes
Hi Mahesh,

You have to use aui module liferay-portlet-url' in order to get Liferay.PortletURL, otherwise it will throw undefined error message.


Regards
thumbnail
Meera Prince, modificado 9 Anos atrás.

RE: How to use Liferay javascript ?

Liferay Legend Postagens: 1111 Data de Entrada: 08/02/11 Postagens Recentes
Hi
Try this

<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<aui:script>
AUI().use('aui-base','liferay-portlet-url','aui-node', function(A) {
var myRenderURL =Liferay.PortletURL.createRenderURL();
myRenderURL.setPortletId('47')
myRenderURL.setWindowState('pop_up');

});
</aui:script>

http://www.liferaysavvy.com/2013/11/working-with-liferay-urls.html

Regards,
Meera Prince