Total Pageviews

Sunday, August 26, 2012

Automated Undeployment of Liferay EXT

Those who work with Light Weight EXT environment very well know that its redeployment is a bit tricky because it needs its undeployment correctly. I've already written an article for its manual undeployment (see article), but during development it takes good time and efforts, so I thought to get some automated way to get it done and the solution I got is using ANT. There the three variation with change only in invocation method. Lets see it:

NOTE: In all examples, name of ext is considered as : example-ext, and following scripts are to added in build.xml file inside the ext folder of sdk. We need to shutdown the server, run this target, start the server and deploy ext again.

1. EXT context name is hardcoded inside ANT script.


Now this can be invoked, as the following:

2. Secondly, we all make the "build.${user.name}.properties" (eg. build.apoorva.prakash.properties") in which we generally set app.server.dir property with path of our web server path. We can create a new property in the same file with the name of ext instead of hard coding the name of ext in ant script, so that it will become a bit of configurable. Advantage of this approach is - as we are allowed to have only one ext in a project and while we create the custom build properties file, we can put the name of the ext in that file along with the name custom app.server.name property. So the custom build file will look as the following:
Now we need to make some minor changes in ANT script, which will look as following:
We can call the target simply as following:

3. Lastly, we can pass name of the ext on the command prompt to make the approach more flexible. If we invoke the ANT script written above as follows, it will supply the name from the command line:
The point to remember is that, don't make the property in the custom build property file.

Hope this will help.

Saturday, August 11, 2012

Using Custom portlet services in Theme Template

Service builders and velocity template are two very important parts of Liferay, and I personally feel joy working with velocity. Today, I am going to write one more article on Velocity templates, which is about the usage of custom portlet services in theme velocity templates. I've already written an article about usage of Liferay services in theme templates (see article). Calling custom portlet services which we build using the service builder is a bit different, however we need to call the same findService method which is overloaded in ServiceLocator class. All difference is we need to pass the servlet context name along with the service class name, as under
The servlet context name is the name of folder of your portlet inside the web-app folder, and if you have doubt, you can use following code to get servlet context name.
One caution, you should have the portlet deployed in the server, whose service you are going to use in theme, otherwise this will give you "Bean Locator is null" exception on server logs.

Hope this will help.