Monday, November 28, 2011

Theme Development in Liferay

After installing a portal system (or web server), the first thing you want to do is create a simple web page and start customizing the theme. Unfortunately, Liferay's documentation is terribly unclear about that.

Well, its suggested normal method is to choose from a number of ready themes. Umm, NO! Nobody wants to use a theme like that. Every organization has their own colors and graphics and if not, you nevertheless want to have something that you have in your mind, not what some others have.

So, the "advanced" method is to develop a custom theme, which you can then deploy in Liferay. The Liferay plugin for Eclipse supports that. However, that method is way too heavy for me at least. I don't want to run a separate development Liferay on my machine, as I don't have enough memory in my home computer to do it fast enough. I want to work directly with the production server. I also suspect that deploying a theme takes longer than a second.

So, what I wanted to do was to just edit some CSS in the web server, save, reload, and see the result. This method of themeing does not seem to be documented anywhere, or at least it's hard to find. Anyhow, the easy way seems to be to edit the custom.css file in "classic" theme. The full path to the file is tomcat-x.x.x/webapps/ROOT/html/themes/classic/css/custom.css.

The problem with that was that just editing it did not reload it immediately, or actually ever. Even restarting the serve does not reload it. I found some suggestions for properties that would need to be set in the portal-ext.properties, but they didn't quite work in my case.

Finally, I found the solution right there in the Liferay's installation package. The file tomcat-6.0.29/webapps/ROOT/WEB-INF/classes/portal-developer.properties has the following settings for development:
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=trueroot

I don't actually know which of the settings are really necessary, but now it seems to work great. Just edit the file and it's reloaded immediately.

Sunday, November 20, 2011

Installing Liferay on MySQL

I'm installing a new web server for the astronomical association Turun Ursa. As we support Liferay at work, using it for this purpose may have some synergy so that I don't need to learn yet-another-portal. Well, not that Liferay is the easiest to learn. Anyhow, it also makes it possible to develop some portlets if I ever need one. I think I may need to redo my planetarium application again in Java - the old C++ version for Sparc stopped working some time ago after some upgrade at the university.

Anyhow, the instructions for doing the proper installation were rather unclear as they didn't really tell much details about creating the database. They referred to a "Chapter 6", which didn't exist at all. I guess they referred to these instructions, which were more helpful. Anyhow, below is a brief summary.

The setup is done here using the database root user. Some Liferay example used that though I don't really see why. Creating a separate Liferay user might be nicer. Well, I have Liferay running as a root anyhow to get it running in port 80, so the database user probably doesn't make it significantly safer.
  1. Shut down the server

    # ./tomcat-6.0.29/bin/shutdown.sh

    ...and wait for a bit.

  2. Move the 7Cogs demo data generator away

    # mv tomcat-6.0.29/webapps/sevencogs-hook/ .
  3. Create the database with a database command and not using the mysqladmin to be able to set the character set. It's probably important.

    # mysql -prootpassword
    mysql> create database lportal character set utf8;
    Query OK, 1 row affected (0.00 sec)

    The MySQL configuration stuff is explained in this wiki.

  4. Create a portal-ext.properties file in the Liferay installation directory with content:

    #
    # MySQL
    #
    jdbc.default.driverClassName=com.mysql.jdbc.Driver
    jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
    jdbc.default.username=root
    jdbc.default.password=rootpassword
  5. Start up the server

    # ./tomcat-6.0.29/bin/startup.sh
  6. Follow that it starts OK

    # tail -F tomcat-6.0.29/logs/catalina.out
Well, rather trivial but took me a bit time as the documentation was a bit...hazy.

Other notes:
  • When first logging in, create a new user account with your own name. Then log out and log in as user "test@liferay.com" with password "test" (this information was not really obvious in the instructions either). Go to Control Panel -> Users and give yourself the Administrator role. You need to remove or disable the "test" account at some point...

Thursday, November 10, 2011

Windows behind the background

I've had a lot of trouble with my dual screen setup with Kubuntu 11.10. It works like a dream when you set up it at first. The trouble starts when you turn off either or both of the monitors and then turn them on. KDE is "intelligent" so that it tries to switch between the single and dual display set up depending on what displays are on. Unfortunately, the result is rather uncontrolled and random.

So, this morning I arrived at work and opened my laptop first...MISTAKE! I should have turned on the external monitor instead. So, it did not just not work, but also got completely stuck. So, I restarted kdm from console screen. After that, the behavior got really odd. No windows were visible. I could see them in the task panel, but they were nowhere. Then, I switched to the 3D cube view and I could see them - behind the background!

So, apparently the background is no longer a "root image" in X, but a window itself, and it has a Z index. I was able to bring the windows forth by right-clicking them in the task bar and selecting "Advanced -> Keep Above Others". But that was rather nasty thing to do. Then occasionally, the panel itself would drop below the background image and using the machine became impossible. Even restarting the machine did not help, apparently the Z index of the background was saved in system configuration. Great.

I traced the problem to .kde/share/config/plasma-desktop-appletsrc. Apparently, the background is managed as a desktop applet (aka "desktop widget") and each has a zvalue parameter defined in the configuration.

I did not trace the issue further, just removed the file. Apparently others have met the same issue, hence this post.