Foros de discusión

Why temp/work clean and tomcat restart is required for hookto update js.

thumbnail
Raja Seth, modificado hace 8 años.

Why temp/work clean and tomcat restart is required for hookto update js.

Regular Member Mensajes: 233 Fecha de incorporación: 18/08/11 Mensajes recientes
HI Team,

I have a requirement in which I need to add my custom my code inside tomcat-7.0.42\webapps\ROOT\html\js\liferay\ddm_repeatable_fields.js . For which I am creating a hook. But when I deploy the changes doesn't comes up. I need to stop my server, clean-up temp/work and then restart my server. Why I need to restart the server when hook is hot deployable? Is there any workaround that my changes can reflect without restart of server?

Thanks & Regards,
Raja
thumbnail
Meera Prince, modificado hace 8 años.

RE: Why temp/work clean and tomcat restart is required for hookto update js

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi
Its happened for static resource files and have you tried with clear browser cache?

Regards,
Meera Prince
thumbnail
Raja Seth, modificado hace 8 años.

RE: Why temp/work clean and tomcat restart is required for hookto update js

Regular Member Mensajes: 233 Fecha de incorporación: 18/08/11 Mensajes recientes
Meera Prince:

Its happened for static resource files and have you tried with clear browser cache?


Hi Prince,

Thanks for your reply! Yes I tried clearing browser cache but still didn't worked.

Regards,
Raja
thumbnail
Olaf Kock, modificado hace 8 años.

RE: Why temp/work clean and tomcat restart is required for hookto update js (Respuesta)

Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientes
Raja Seth:
I have a requirement in which I need to add my custom my code inside tomcat-7.0.42\webapps\ROOT\html\js\liferay\ddm_repeatable_fields.js


First of all, this is not a requirement. This is the solution that you came up with to implement the underlying requirement that you had. And obviously the solution has a few shortcomings. You're probably using a JSP-Hook to update these JS resources. Now the JSP hook is not a JS hook and Liferay bundles, combines, minifies JS resources and caches these minified results - this is what you see delivered after you've deployed your hook. You should have some success with the settings from portal-developer.properties or by adding ?strip=0 to your URLs - these are good for testing, but not for production.

Luckily you've already found the procedures to fully deploy your changes to production - and obviously they're not fun. But as Liferay does not have a JS hook, let's look at the alternatives: You can write an ext-plugin (this would require a restart as well) and you can add the required JS code to your theme (if you can just add it). In your theme it doesn't require a restart. You could also update portal-ext.properties and update the barebones and everything properties with additional code. Again, this would require a restart.

Which one do I recommend? As I don't know your requirements (remember: What you described is not a requirement) I can't decide for one.
thumbnail
Raja Seth, modificado hace 8 años.

RE: Why temp/work clean and tomcat restart is required for hookto update js

Regular Member Mensajes: 233 Fecha de incorporación: 18/08/11 Mensajes recientes
Hi Olaf,

Sorry for the lines which make the context of question in different way. Yes you are correct as this is the solution I came up with to implement my requirement.

Thanks for the alternates you have shared, but as you know that I need to override tomcat-7.0.42\webapps\ROOT\html\js\liferay\ddm_repeatable_fields.js which I guess would not solve my problem if I go with theme or update portal-ext.properties and update the barebones and everything properties. EXT is another solution. But I guess it's better to go with hook instead of EXT.

I think I got the answer as you mentioned that Liferay provides JSP hook not the JS hook and I am trying to do the same via JSP hook which I guess is better to go instead of EXT coz it will reduce some the steps.

Thanks & Regards,
Raja
thumbnail
Meera Prince, modificado hace 8 años.

RE: Why temp/work clean and tomcat restart is required for hookto update js

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi Raja Seth
Ext not recommend so you please go with JSP Hooks,
Here you can the description jsp hooks what it do.
Overriding Web Resources
Hooks are commonly used to override web resources, found in portal-web in Liferay’s source. You can use a hook to override JSP files, JSPF files, JavaScript files, or images.

https://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/overriding-web-resources-with-hook-liferay-portal-6-2-dev-guide-en

Regards,
Meera Prince
thumbnail
Raja Seth, modificado hace 8 años.

RE: Why temp/work clean and tomcat restart is required for hookto update js

Regular Member Mensajes: 233 Fecha de incorporación: 18/08/11 Mensajes recientes
Thanks Prince!
thumbnail
Olaf Kock, modificado hace 8 años.

RE: Why temp/work clean and tomcat restart is required for hookto update js

Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientes
Hi Meera,

In general I agree - if it can be done with Hooks, it should be done with Hooks. However, in this case - for the reason discussed above - JSP-Hooks might not be appropriate for JS files: They update the files, but not the cached minified versions. And the minifier might not expect the files to be changed.

Physically it's possible to overwrite JS files with JSP hooks - it's even possible to physically overwrite Liferay's web.xml or inject a jar-file into Liferay's WEB-INF/lib with a JSP hook. However - will it work? Will it work Hot-Deployable as JSP-Hooks do? No!

Some changes can't be done with hooks, or they need additional steps (deleting temp files), just as Seth mentions. If that's ok: Fine. Just keep it in mind. Ext is only discouraged if there's no other way around. In this case there's an argument if a hook is more maintainable or not IMHO. Especially as I still don't have a clue if the problem couldn't be solved by just adding a custom JS file to the theme and introduce the change this way.
thumbnail
Meera Prince, modificado hace 8 años.

RE: Why temp/work clean and tomcat restart is required for hookto update js

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi Olaf Kock,
Thanks for very useful information.

Regards,
Meera Prince