Foros de discusión

fragment for javascript files

thumbnail
Fernando Garcia, modificado hace 7 años.

fragment for javascript files

New Member Mensajes: 13 Fecha de incorporación: 12/04/11 Mensajes recientes
I have created a liferay fragment for the calendar web portlet. For JSP files the fragment is working ok, but when I want to modify a javascript file, the fragment is not possible.

In liferay 6.2 you can modify javascript files with hooks and since fragments are the new way to modify liferay modules jsp I thought this was posible. Any ideas? Thanks
thumbnail
David H Nebinger, modificado hace 7 años.

RE: fragment for javascript files

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
Not sure whether these will help, but...

  • Have you tried clearing browser cache? Could you have the older copy of the JS cached?
  • Have you tried restarting the portal? Does it start serving the new JS?
  • Have you tried purging the temp and work directories to ensure you're not getting some older artifact?







Come meet me at the NAS!
thumbnail
Fernando Garcia, modificado hace 7 años.

RE: fragment for javascript files

New Member Mensajes: 13 Fecha de incorporación: 12/04/11 Mensajes recientes
Thank you for your quick response.

I already have tried the first two points you mention. The third one I just tried and still I don't see my js changes.
Just to make sure I deleted the temp and work folders under tomcat folder. Just saying because there is a work folder under liferayHome folder and I assume you referred the way purging is done in liferay 6.

Thanks
thumbnail
David H Nebinger, modificado hace 7 años.

RE: fragment for javascript files

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
Under 7, you want to purge both work folders. The tomcat one is the regular tomcat folder, the work folder in $LIFERAY_HOME is the one used by Liferay to compile the JSP files from the OSGi bundles.

Honestly I don't know if it is possible to use a bundle fragment to replace a JS file. I don't know if they actually go through the same mechanisms or not, just trying to help...






Come meet me at the NAS!
thumbnail
Fernando Garcia, modificado hace 7 años.

RE: fragment for javascript files

New Member Mensajes: 13 Fecha de incorporación: 12/04/11 Mensajes recientes
Just tried purging both works directories and same result. I don't see any js change.

Since in liferay 6 you are able to hook js/css files, I thought a bundle fragment was going to be the way under liferay 7.

I have looked liferay 7 dev documentation and the liferay blade examples and there is not mention on how this can be done...
Thanks for your help David.
Marek Hornak, modificado hace 7 años.

RE: fragment for javascript files

New Member Mensaje: 1 Fecha de incorporación: 14/08/15 Mensajes recientes
I'm refreshing this thread as it seems to be forgotten. The fragment module works flawlessly for JSPs, but Javascript files stay unaltered. Is there a way we can override Javascript files of Liferay 7 modules?
thumbnail
Chema Balsas, modificado hace 7 años.

RE: fragment for javascript files (Respuesta)

Regular Member Mensajes: 127 Fecha de incorporación: 25/02/13 Mensajes recientes
Hi Marek, Fernando!

As far as I can tell, overriding js files using a fragment is not a supported feature. The bundle entry resolution works that way for jsps, but not for other types of files.

There is still a fair share of techniques to accomplish it. I assume that the most common case would be to override YUI/AlloyUI default modules. To do this, one possible solution is to create an additional module (not a fragment) with your module implementations and a config.js file like the following:

;(function() {
	AUI().applyConfig(
		{
			groups: {
				mymodulesoverride: {
					base: MODULE_PATH + '/js/',
					combine: Liferay.AUI.getCombine(),
					filter: Liferay.AUI.getFilterConfig(),
					modules: {
						'my-module-override': {
							path: 'my-module.js',
							condition: {
								name: 'my-module-override',
								trigger: 'the-module-to-override',
								when: 'instead'
							}
						}
					},
					root: MODULE_PATH + '/js/'
				}
			}
		}
	);
})();


In order for the system to pick up the module configuration, you should specify it using the Liferay-JS-Config header. For example, if you're using bnd, you could add the following to your bnd.bnd file

Liferay-JS-Config: /META-INF/resources/my-module-override/js/config.js


Hope this helps, but please, let me know otherwise with some extra context to figure out what else could be done.

Thanks!
thumbnail
Chenna Yon, modificado hace 6 años.

RE: fragment for javascript files

New Member Mensajes: 7 Fecha de incorporación: 8/01/15 Mensajes recientes
Thanks, Chema Balsas for your sharing.
It's really helping me a lot.
thumbnail
Gaurav Jain, modificado hace 6 años.

RE: fragment for javascript files

Junior Member Mensajes: 85 Fecha de incorporación: 12/07/16 Mensajes recientes
Hi Chema Balsas
Can you please explain it bit more. As I am not able to locate the path(name) of js module to be overridden, in the above example. FYI I am trying to override \portal-master\modules\apps\foundation\frontend-editor\frontend-editor-ckeditor-web\src\main\resources\META-INF\resources\_diffs\plugins\itemselector\plugin.js

Thanks in advance
Gaurav
Shubhankit Roy, modificado hace 5 años.

RE: fragment for javascript files

New Member Mensajes: 8 Fecha de incorporación: 27/04/15 Mensajes recientes

Hi Chema and David!

I have a situation where I need to change some of the default values that are shown in the dialog box that opens on clicking the 'table' icon from the icons available in the ckEditor. Is there a way to achieve this?

 

 

 

 

komeil bitaraf, modificado hace 7 años.

RE: fragment for javascript files

New Member Mensajes: 7 Fecha de incorporación: 21/05/16 Mensajes recientes
hi
i am using liferay 7
i want to override my input_date taglib in html/taglib/ui/input_date/page.jsp
and add different datepicker
my page.jsp completely change in overriding core jsp but i can't add datepicker.js and show TypeError: $(...).datepicker is not a function
tnx
komeil bitaraf, modificado hace 7 años.

RE: fragment for javascript files

New Member Mensajes: 7 Fecha de incorporación: 21/05/16 Mensajes recientes
hi
i am using liferay 7
i want to override my input_date taglib in html/taglib/ui/input_date/page.jsp
and add different datepicker
my page.jsp completely change in overriding core jsp but i can't add datepicker.js and show TypeError: $(...).datepicker is not a function
tnx