Forums de discussion

How to use Liferay javascript ?

sri p, modifié il y a 12 années.

How to use Liferay javascript ?

Junior Member Publications: 85 Date d'inscription: 22/01/11 Publications récentes
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, modifié il y a 12 années.

RE: How to use Liferay javascript ?

Regular Member Publications: 224 Date d'inscription: 20/10/10 Publications récentes
Hi,

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

Regards,
Jan.
sri p, modifié il y a 12 années.

RE: How to use Liferay javascript ?

Junior Member Publications: 85 Date d'inscription: 22/01/11 Publications récentes
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, modifié il y a 9 années.

RE: How to use Liferay javascript ?

Regular Member Publications: 105 Date d'inscription: 11/10/13 Publications récentes
Hi Sri,
Did you get any solution for this?
thumbnail
Pankaj Kathiriya, modifié il y a 9 années.

RE: How to use Liferay javascript ?

Liferay Master Publications: 722 Date d'inscription: 05/08/10 Publications récentes
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, modifié il y a 9 années.

RE: How to use Liferay javascript ?

Liferay Legend Publications: 1111 Date d'inscription: 08/02/11 Publications récentes
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