开发者

How to include JavaScript file in Liferay Portlet?

开发者 https://www.devze.com 2023-04-09 05:45 出处:网络
I am not able to include http://maps.googleapis.com/m开发者_高级运维aps/api/js?sensor=false. Whenever I load my portlet for the first time it doesn\'t work but if I refresh the same page then it start

I am not able to include http://maps.googleapis.com/m开发者_高级运维aps/api/js?sensor=false. Whenever I load my portlet for the first time it doesn't work but if I refresh the same page then it starts working fine. I don't know what the issue is. Please Help.


One of the clean ways to include js file in a portlet, independent of the portal server is to configure in portlet deployment descriptor file as below. For liferay, it would be liferay-portlet.xml.

<portlet>
    <portlet-name>MySamplePortlet</portlet-name>
    <header-portlet-javascript>http://maps.googleapis.com/maps/api/js?sensor=false</header-portlet-javascript>
</portlet>
0

精彩评论

暂无评论...
验证码 换一张
取 消