留言板
Import Javascripts- Liferay 5
Hi everybody,
I'm looking for a way to import javascript files, at page-level, that allows me to made changes on its without portal restart.
At the moment I import that as follow:
This way it works as I want, but the Javascript code is replicated for every portlet in page.
I'm looking for a way to import javascript files, at page-level, that allows me to made changes on its without portal restart.
At the moment I import that as follow:
<script type="text/javascript">
<%@ include file="../scripts/myscript.js" %>
</script>
This way it works as I want, but the Javascript code is replicated for every portlet in page.
Hi,
use liferay-portlet.xml and its <portlet-header-javascript>/scripts/myscript.js</portlet-header-javascript>. I assume you script is located in your <webapp_docroot>/scripts/ folder.
This way, for more portlets on the same page, script will be included only once.
See DTD of liferay-portlet.xml for more inrformation.
use liferay-portlet.xml and its <portlet-header-javascript>/scripts/myscript.js</portlet-header-javascript>. I assume you script is located in your <webapp_docroot>/scripts/ folder.
This way, for more portlets on the same page, script will be included only once.
See DTD of liferay-portlet.xml for more inrformation.
Josef Šustáček:
Hi,
use liferay-portlet.xml and its <portlet-header-javascript>/scripts/myscript.js</portlet-header-javascript>. I assume you script is located in your <webapp_docroot>/scripts/ folder.
This way, for more portlets on the same page, script will be included only once.
See DTD of liferay-portlet.xml for more inrformation.
Yes, but in this way if you made any changes in the Javascripts you will not see that until you do not restart the portal.
I don't think its necessary. But I assume you have to run you Liferay in developer's mode. It's just a bunch of portal-ext properties, that disables compressing and bundling of JS and CSS files. Place this properties into separate file and inclide it in portla-ext.properties via
I'm developing my files using this approach quite often. Try to have a look at portal-developer.properties in standard downloadable Liferay 6.0.6 bundle, it has some content like this:
include-and-override=portal-developer.properties
I'm developing my files using this approach quite often. Try to have a look at portal-developer.properties in standard downloadable Liferay 6.0.6 bundle, it has some content like this:
theme.css.fast.load=false
theme.images.fast.load=false
javascript.fast.load=true
javascript.log.enabled=true
layout.template.cache.enabled=false
browser.launcher.url=
combo.check.timestamp=true
freemarker.engine.cache.storage=soft:1
freemarker.engine.modification.check.interval=0
openoffice.cache.enabled=false
velocity.engine.resource.manager.cache.enabled=false
com.liferay.portal.servlet.filters.cache.CacheFilter=false
com.liferay.portal.servlet.filters.themepreview.ThemePreviewFilter=true