Editing velocity template of Liferay changes not showing or takes a while

5.3k views Asked by At

I'm currently editing my portal_normal.vm (server/tomcat/webapps/mytheme-theme/templates) testing if I can write on the file and see it on my browser. I tried putting a test comment "<!-- test -->" just to see if I can really write on the file. So I refreshed the file and hope I can see the comment I've added, but there we're none. So I continued refreshing (ctrl+r),\ and viewing the source code for almost an twenty minutes. After a while when I tried viewing it again it reflected in my source code. So I thought it was cached by either Liferay or my browser.

So I tried tweaking the comment adding version on it ("<!-- test v2 -->"), hoping to see changes. I checked it on another browser and the comment didn't update or include my added version. So I think Liferay is responsible for the issue.

this is what my portal-ext.properties contain:

auth.token.check.enabled=false

# Database settings
jdbc.default.jndi.name=jdbc/LiferayPool

#For removing captch
captcha.check.portal.create_account=false

session.enable.phishing.protection=false

default.regular.theme.id=my_site_WAR_my_theme

#Delete cookies while deleting session
session.enable.persistent.cookies=false

#redirecting null problem.
redirect.url.security.mode=mysite.com

journal.template.velocity.restricted.variables=

admin.email.from.name=Market.Travel Team
[email protected]

# Added because of the Error - No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
hibernate.current_session_context_class=thread

session.enable.url.with.session.id=false

and my portal-developer.properties

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

Addition: When I tried editing the css files I can see the changes fast. Just one reload the the changes appear. I think it is just in my velocity template that take some time or there's something wrong.

Liferay version: Liferay Portal Community Edition 6.0.6 CE

Thank You!

1

There are 1 answers

0
Jonathan Dixon On

There is really no need to define your own portal-developer.properties. By adding -Dexternal-properties=portal-developer.properties to your JAVA_OPTS in tomcat/bin/setenv.(sh|bat) Liferay will use it's default developer settings, which are almost identical to what you have provided. However, I do not believe this is contributes to (or could resolve) your problem. More details here.

The developer properties do allow you to make live changes to the templates provided you are changing the right file. Due to the default context.xml Liferay provides to the deployed webapps, the webapps are copied/cached in tomcat/temp/{id}-webapp-name. This means if you change the template in webapp/mytheme then it may take tomcat a while to pick up on the change, if it notices the change at all (this will depend on the tomcat configuration). On the other hand, if you make a change in temp/1-mytheme it will show up immediately. Editing the files in the temp folder is probably not ideal, so...

How to fix this: (no specific order)

  • Prevent Tomcat from using the temp directory for your theme. Create a context.xml file for your theme.

    <Context cachingAllowed="false"/>

    This file should be placed in the META-INF folder of your theme. If you are using the Liferay auto-deploy feature the context.xml file may be clobbered, here, and here. If this is the case you will need to find a work around that best suits your needs, such as modifying the context.xml after the theme is deployed.

  • If you are using the Liferay Plugin-SDK the you can follow the fast plugin development guide for setting up your development environment.