Monday, October 25, 2010

It's a Layout Template Not a Portlet!!!!!

This was an interesting one so I thought I'd share.

This morning I was building some layout templates for Liferay 5.2.3 with the plugins sdk and a simple text editor. (Wordpad, if you must know. Yes, I'm in Windows these days.) I made the changes I needed, zipped it up into a .war file and dropped it into my hot deploy folder.

I opened up Liferay on my localhost to witness the majesty that was my layout template and... Nothing. It didn't appear in the list of choices.

So I re-opened the files and made sure everything was correctly formatted and that I hadn't missed anything in my configuration or code. Hot deploy again and...

Nothing.

So I opened up the terminal window where the Tomcat output was running and yes indeed, it had successfully imported, installed and made my portlet available for use.

Yes, I said portlet.

Now that's interesting... Just for giggles I clicked "Add Application" from the Dock and in the filter box started typing the name of my awesome layout template... And there it was.

Interesting.

So Liferay thinks my layout template is a portlet. I wondered... what if I clicked "add..."

It added a portlet. It added a portlet with the text "The requested resource (/3_columns_i_5-layouttpl/3_columns_i_5layouttpl/invoke) is not available" in it.

Yeah I know, right?

So I started to compare the liferay-plugin-package.xml file with that from a known (and tested) working template I downloaded from Liferay. All the same. Code in the individual files... all the same. WTH???

Now some of you, by now, may have figured out what I did wrong. For those that haven't go ahead and take a guess. I haven't really given enough information to make it blatantly obvious since I wanted to save it as a surprise but try anyway. I'll wait right here.

Back already, eh? Ok I'll tell you.

When I created my .war file I included the docroot directory in the structure. (This is what I get for trying to be fast and slick.) The proper contents of a layout template .war file is what's inside the docroot folder.

Apparently when Liferay 5.2.3 sees docroot in a .war file it thinks you're deploying a portlet and runs with it.

Oh, and for those of you who don't know the quick and dirty way to generate a .war file... Just put your stuff in a .zip file and change the extension to .war.

Just don't include docroot if it's a layout template...

4 comments:

  1. Excellent post, The initial impression that a website has on users has a significant effect on the perception of the visitor regarding the products.
    Thanks for sharing this.
    kelly

    ReplyDelete
  2. Thanks for the kind words, and you're quite welcome :)

    ReplyDelete
  3. Most of them belives there is not any difference between layout for web and blog. So here you get the clear difference between its layout not portlet. Thanks for your views which is outstanding. Keep it up.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete