Fórumok

How to use Liferay javascript ?

sri p, módosítva 12 év-val korábban

How to use Liferay javascript ?

Junior Member Bejegyzések: 85 Csatlakozás dátuma: 2011.01.22. Legújabb bejegyzések
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, módosítva 12 év-val korábban

RE: How to use Liferay javascript ?

Regular Member Bejegyzések: 224 Csatlakozás dátuma: 2010.10.20. Legújabb bejegyzések
Hi,

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

Regards,
Jan.
sri p, módosítva 12 év-val korábban

RE: How to use Liferay javascript ?

Junior Member Bejegyzések: 85 Csatlakozás dátuma: 2011.01.22. Legújabb bejegyzések
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, módosítva 9 év-val korábban

RE: How to use Liferay javascript ?

Regular Member Bejegyzések: 105 Csatlakozás dátuma: 2013.10.11. Legújabb bejegyzések
Hi Sri,
Did you get any solution for this?
thumbnail
Pankaj Kathiriya, módosítva 9 év-val korábban

RE: How to use Liferay javascript ?

Liferay Master Bejegyzések: 722 Csatlakozás dátuma: 2010.08.05. Legújabb bejegyzések
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, módosítva 9 év-val korábban

RE: How to use Liferay javascript ?

Liferay Legend Bejegyzések: 1111 Csatlakozás dátuma: 2011.02.08. Legújabb bejegyzések
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