Monday, April 27, 2015

Custom Action(Events) Hook in Liferay

Today we will discuss about Custom Action Hook  in Liferay. In file their are some properties which have multiple values and some have only one value like true/false.

a)For single value like true/false we override the property see 
Portal Properties hook in Liferay.

b)For multiple values properties like   any values you specify in a hook don’t override the list defined in the portal, but rather are appended to that list.Your actions will then fire when Liferay Portal starts in addition to the list of actions that are specified in the default Liferay installation

In liferay there are some portal events you can see those events in

These events are:-


The action of these events are defined in so we need to extend to create a custom action.

So lets start step by step:-

Step 1:-Create Liferay hook project
File-->New-->Liferay Plugin Project-->Provide name-->Select hook in plugin type-->Finish.
You can see snapshot in step 2 of Portal Properties Hook in Liferay

Step 2:-Create  hook inside project
Right click on project-->New-->Liferay hook Configuration-->tick>Next.

then this pop up is open:-

then click on add another pop up is open where you can select the event click on select event button.This time pop up open with events as:-

Select and click ok.Now Click on New button of previous figure to add our class as:-

Provide Classname, java package and select  superclass  as Action and click ok.

Now Ok and finish.This will create file automatically also provide entry in liferay-hook.xml.

Step 3:-Check Generated Code
By using eclipse ide file automatically created as:-

and liferay-hook.xml as:-


Step 4:-Provide your custom code
Open from package com.test and paste this code:-

Step 5:-Check Output
Now deploy your hook and login to liferay as soon as you login the eclipse console shows:-

My Login Pre event

Project Structure

You can Download Source code from Custom Action Hook in Liferay

Hope this will Help....

Related Post:-

No comments:

Post a Comment

Total Pageviews

Like Us on Facebook

Number Of Unique Visitor

Free counters!