Skip to main content

Basic Hook

Basic Hook and its type


Liferay portal comes with a bundle where all the default built in portlets exist. Typically if any customization required in terms of JSP (UI) and portal properties. We need to go by Hook implementation. Hook is supported by hot deployment. Liferay documentation suggests that - Whenever possible, hooks should be used in place of Ext plugins, as they are hot-deployable and more forward compatible.

Some common scenarios that require the use of a hook are

    When you have to perform a custom action on portal startup
    When you have to perform a custom action on user login
    When you need to overwrite or extend portal JSPs
    When you need to modify portal properties
    When you need to replace a portal service with your own implementation.

Types of HOOK


1. Event Handlers -:

   Liferay has a few event handler connection points throughout its lifecycle, which are desgined to handle events at various points.
        Application Startup Events (application.startup.events)
          This can be used to when we want to add these on application startup event
              -addlayout
              -addResource
              -createRoles
              -createSite
              -setUpExpando

        Login Events (login.events.pre, login.events.post)
           Pre-Event-:This can be used to perform pre action before user login such as when user enter his name in email field if that user
                      dosn't exsist in DB it should return some error messgae
           Post-Event-: This can be used for Landing Page based on user Role

        Service Events (servlet.service.events.pre, servlet.service.events.post)
           This can be used to check if user has the access for Control Panel or not

2. Language Bundles 

The main purpose of Liferay Language Properties Hook is to override liferay default language properties. Liferay Portal uses lots of keys from different language properties files. This hook is extremely simple to develop.  By default Liferay Portal comes with 47 language properties files.


3. Model Listeners 


Model listeners are similar in behavior to portal event handlers except that these handle events with respect to models built using ServiceBuilder.

4. JSPs (More Details Click)

Developing JSP Hook is quite  straight forward and this is one of the most easiest hook to create in Liferay Portal. To create a JSP Hook you just need to know which JSP page you want to customize. You should have liferay source code ready to find out the path of JSP page. Once you located the JSP path you are ready to customize.

5. Portal Properties


Liferay defines few more portal properties in portal.properties file. This file is located in <>/tomcat-7.0.25/webapps/ROOT/WEB-INF/lib/portal-impl.jar. We can override these properties (defined in portal.properties) from portal-ext.properties file.

We can alter the portal's configuration properties by specifying an override file. The properties in this file will immediately take effect when deployed thus allowing runtime re-configuration of the portal.If you had a file /WEB-INF/src/portal.properties


Comments

Popular posts from this blog

Liferay 7.1 Topics Coming Soon stay connected

1. Liferay 7.1 Service Builder 2. Rest Service and Liferay 3. Consuming SOAP service with Liferay 7.1 4. Creating Theme With Liferay 7.1 Using Liferay IDE Using NPM 5. Create Angular NPM Module 6. Web Content Management 7. OSGI Basic 8. Liferay 7.1 with more than 1 DB 9. A sample project 10. Liferay Dev Ops

How the portal page is loaded with respective portlets

How the portal page is loaded with respective portlets When a user requests a page with a URL, 1.    The browser sends the request to the Application Server (AS). 2.    Liferay gets the page name from the URL. 3.    It goes to the layout database table and finds the related        theme and page layout. 4.    Based on the page layout, Liferay finds the portlets added        into each area of the page layout. 5.    Liferay runs the portlet and adds the output in the        portlet.vm template. 6.    Liferay interprets the portlet.vm template and adds the output        in the page layout. 7.    Then Liferay interprets the page layout and adds the output in        the portal_normal.vm template. 8.    After that Liferay interprets the portal...

Liferay Dynamic Query API

Liferay Dynamic Query API  -Liferay Dynamic Query API is an elegant feature in Liferay portlet development. -Dynamic Query API can only perform read operations against database. These we will use specially to provide search operations against database. -Dynamic Query API is independent feature and we can implement anywhere in the development like we can implement in JSP pages, Portlet Action Classes and service implementation classes. Types of Class Loader-: Here we have two class loaders 1. Portal Class Loader-:    If any class or model class in portal level then we need to use Portal Class Loader in Dynamic Query Object.    ClassLoader portalClassLoader=PortalClassLoaderUtil.getClassLoader();    We can implement dynamic query against portal level class such as User, Group, Role, Organization, Layout and Layoutset 2. Portlet Classs Loader-:    Portlet Class Loader is related to each portlet.    ClassLoader portle...