google.com, pub-5747754088801811, DIRECT, f08c47fec0942fa0 Skip to main content

Liferay interview questions


  • What is Liferay Portal?
  • In General a web portal represents a web application that provides a single point of access to variety of information.
  • Functionality of a portal can extend very easily by creating custom applications that can run inside a portal.
  •  These applications are called portlet.
  •  For running portlet we require application server that can run a portlet container spec (JSR168 or JSR286).
  •  There are dozens of free and enterprise portal products available.
  •  Liferay portal is an open source portal. Below are benefits of it.
1.      Content management system.
2.      Workflow
3.      Social networking
4.      Easy integration with LDAP, Alfresco, Solr, CAS etc.
5.      Inbuilt available portlet related with News, Finance, Social, Workflow etc.
6.      Compatible with different database server, OS and app server.
7.      Compatible with UI technologies and web services.
8.      Compatible with different script Python, Ruby ,Grails, Python
9.      Support Hot deployment


  • WHAT IS LIFERAY HOOK?
  • Liferay portal come with bundle where default built in portlets exist.
  • If any customisation require in JSP or portal.properties we go by hook.
  • Hook is hot deployable.
  • Liferay document suggest wherever possible we should use Hook instead ext.
  • Because it is more future version compatible, It is hot deployable.
Some common scenario in which we use Hook.
  •  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.

  • What Is A Liferay Theme? What Are The Advantages Of Using Them? What are architectures of theme?

  • Liferay themes are the way to customize look and feel of a Liferay portal page.
  • It is hot deployable plugin provide by Liferay.
  • The themes are extendable components that can be deployed separately on a portal and each page on the portal can choose a different theme.
  • Themes are really powerful way to run multiple websites from a single portal. 
  • You can host multiple websites on a single Liferay portal with totally different look and feel
  • The same time save lot resources on website hosting. 
  • A lot of companies use Liferay for creating multiple unique websites with the help of extraordinary themes that can be easily developed. 
  • Themes are also available from marketplace.
  • For developing on our own, we have option of using VM pages(Velocity templates).
  • Liferay provides the feature to deploy the different themes into the portal same like portlets war files.
  • Number of themes we can be deployed into Liferay portal and we can further select those themes for user interface as per the requirement of end user for different site or organization interface as per the requirement of end user for different site or organization pages.
  • We are using CSS, JavaScript and Velocity for it.
  • Liferay are built on top of two base themes, named _unstyled and _styled. Theme.
Archietecture

Docroot
- diffs
css
images
js
templates
 css
- aui
(many directories)
images
(many directories)
js
main.js
templates
- init_custom.vm
- navigation.vm
- portal_normal.vm
- portal_pop_up.vm
- portlet.vm
WEB-INF/
-liferay-look-and-feel.xml
-liferay-plugin-package.properties



  • The _diffs folder must mirror the parent theme’s directory structure. 
  • Since you’ll only customize the parts of your theme that differ from the parent theme, place only the folders and files you’ll customize there.
  • For example, to customize the navigation, copy navigation.vm
  • deep-blue-theme/docroot/_diffs/templates folder (you may have to create this folder first). You can then open this file and customize it to your liking.


  • Difference between Hook and Ext Plugin.

Points

Hook Plugin

Ext Plugin

Deployment

Hot deployable

Require server Restart.

Benefits

Easy extension and easy maintenance.

If we can not achieve functionality with Hook. We should use Ext plugins.

These are recommended when there is no way of implementing required functionality  using hooks.

Combine

It is easy to combine with other plugin like Portlet.

It is difficult to combine with other plugin.

 

 

 

Using Hook we can override Event handlers

a) (Application start-up event, Login events, Service events)

b) Languages bundles.

c) Jsp files (Either portal, portlet)

d) Model Listener

e) Services

 

Using Exts we can customize

a).portal-impl as ext-portal-impl.
b).portal-service as ext-portal-service.
c).util-bridges as ext-portal-utilbridges..
d).util-java as ext-util-java.
e).util-taglib as ext-taglib.
f).web as ext-portal-web.

 

 



  • Spring MVC portlet configuration.
Create new portlet.


1 REPLACE MVCPortlet with Dispatcher Portlet  in -- portlet.xml

2 Create application context file for spring MVC

3 Create Beans DefaultAnnotationHandlerMapping inside file
         
  <context:annotation-config />
         

4 Init parameter provide xml file location contextConfigLocation -- portlet.xml

5 Provide dependency inside Lib folder or with help of Liferay-plugin.package.properties

6 Putting ViewRenderServlet in web.xml file

7 Configure view inside the application context file.

8 Create JSP folder inside the WEB-INF

9 Create Controller in Src

10 Define Controller bean inside the applicationciontext.


  •  Different annotation use in Liferay spring mvc portlet
  • @Controller
This will tell that this is our controller.
  • @RequestMapping("VIEW")
This tell DispatcherPortlet This controller support full view mode.
  • @RenderMapping annotation to this method. 
This annotation tell that this is default render method.
  • @Autowired annotation can be useful for dependency injection.
  The @Autowired annotation is performing Dependency Injection.


  • What is Inter Portlet Communication ?
  • Sometimes we have requirement to communicate between two portlet For example any action done on one portlet will affect on second portlet.
  •  We have to use Liferay inter-portlet communication mechanism which serve the action performed by end user in one portlet and provide the result to the second portlet where the action result needs to be displayed. 
  •  JSR style inter portlet communication ensures that your portlets are going to work on any other JSR compliant portal server.

  • JSR168 vs JSR286

  • The first version of the portlet specification, JSR-168/Portlet 1.0, did not include any support for Inter Portlet Communication.
  • The second version, JSR-286/Portlet 2.0, has supported for IPC Mechanism.
  •  JSR-286 makes it easy to share the data between two portlets. Using IPC mechanisms, we can share the data from ACTION to VIEW phase and VIEW-VIEW Phase.
  •  The first version of the portlet specification, JSR-168/Portlet 1.0, did not include any support for Inter Portlet Communication. The second version, JSR-286/Portlet 2.0, has supported for IPC Mechanism.
  •  IPC through events and public render parameters
  •   Support for WSRP 2.0
  •  Portlet filter – allowing on -the -fly transformations of information in both the request to and the response from a portlet.
  •  Public render paremeters - Allows portlets to share parameters with other portlets.
  • Portlet filters and listeners.
  • Resource serving - Provide ability for portlets to server a resource
  • AJAX support

  •  IMPLICIT OBJECTS USE IN LIFERAY


1          actionRequest                                        (javax.portlet.ActionRequest)
2          actionResponse                                      (javax.portlet.ActionResponse)
3          eventRequest                                         (javax.portlet.EventRequest)
4          eventResponse,                                     (javax.portlet.EventResponse)
5          portletConfig,                             (javax.portlet.PortletConfig)
6          portletName,                                          (java.lang.String portletName ;
7          portletPreferences,                                 (javax.portlet.PortletPreferences)
8          portletPreferencesValues,           (java.util.Map)
9          portletSession,                                       (javax.portlet.PortletSession)
10         portletSessionScope,                  (java.util.Map)
11         renderRequest,                                      (javax.portlet.RenderRequest)
12         renderResponse,                        (javax.portlet.RenderResponse)
13         resourceRequest,                       (javax.portlet.ResourceRequest)
14         resourceResponse                      (javax.portlet.ResourceResponse)

·          themeDisplay             (com.liferay.portal.theme.ThemeDisplay)
·          company                  (com.liferay.portal.model.Company)
·          account                  (com.liferay.portal.model.Account)
·          user                     (com.liferay.portal.model.User)
·          realUser                 (com.liferay.portal.model.User)
·          contact                  (com.liferay.portal.model.Contact)
·          layout                   (com.liferay.portal.model.Layout)
·          layouts                  (java.util.List)
·          plid                     (java.lang.Long)
·          layoutTypePortlet        (com.liferay.portal.model.LayoutTypePortlet)
·          scopeGroupId             (java.lang.Long)
·          permissionChecker        (com.liferay.portal.security.permission.PermissionChecker)
·          locale                   (java.util.Locale)
·          timeZone                 (java.util.TimeZone)
·          theme                    (com.liferay.portal.model.Theme)
·          colorScheme              (com.liferay.portal.model.ColorScheme)
·          portletDisplay           (com.liferay.portal.theme.PortletDisplay)
·          portletGroupId           (java.lang.Long)



  • Portlet Lifecycle 
1.       The init(PortletConfig config) is called once, immediately after a new portlet instance is created.It can be used to perform startup tasks and is akin to a servlets init method.
For example, PortletConfig provides access to initialization parameters.

2.       The processAction(ActionRequest request, ActionResponse response) method is called in response to a user action such as clicking a hyperlink or submitting a form. In this method, a portlet may invoke business logic components, such as JavaBeans, to accomplish its goal.
 A     portlet may modify its own state as well as persistent information about a portlet.

3.       The render(RenderRequest request, RenderResponse response) method follows processAction in the chain of lifecycle methods. Render generates the markup that will be made accessible to the portal user. RenderRequest and RenderResponse methods, also subinterfaces of PortletRequest and PortletResponse, are available during the rendering of a portlet.


4.       The destroy() method is the last lifecycle method, called just before a portlet is garbage collected and provides a last chance to free up portlet resources.


  • What is Portlet preferences ?



          1 Static preference
          It will be constant throughout the portlet.

          2 Run time preferences

         We can change the portlet preferences value at runtime and we can access the value through the portlet. The preferences for a portlet are stored in "PortletPreferences" table.

Steps to follow:
  • Access the "department" value in jsp page from the portlet preferences table.
  • Provide another jsp page to modify the department value.
  • Update the department value in portlet preferences table.
http://liferayway.blogspot.in/2013/08/portlet-preferences-example-program.html

  • Liferay Workflow


Liferay include default workflow engine called Kaleo

It allow any number of simple to complex workflow in simple xml file.

Liferay 6 also provide mechanism for integration of JBPM workflow engine.

The workflow can applied out of box the following entities.

1.     WikiPage
2.     WebContent
3.     DocumentLibrary Document
4.     BlogsEntry
5.     Comments
6.     MessageBoards Message


There are four portlets related to the workflow that allows the users to manage this system.
  •                      My Submissions
  •                      My Workflow Tasks
  •                      Workflow Configuration
  •                      WorkflowPortlet.

  • How to create custom field in jsp page?


There are two way to create custom field in jsp page.

1 Control panel
- With help of control panel we can add custom field.
  
In Jsp we require to use Liferay inbuilt tag to use it.

We require to use <liferay-ui:custom-attribute> in hook.

 <div class="exp-ctrl-holder">
           <liferay-ui:custom-attribute
             className="<%= User.class.getName() %>"
             classPK="<%= (selUser != null) ? selUser.getUserId() : 0 %>"
              editable="<%= true %>"
              label="<%= true %>"
              name="nickname"
 />
</div> 


2 With help of expando API we can create the custom field in the JSP and can use to store data in database.

We require to create hook for it.


  • What is service builder?


Service Builder is a model-driven code generation tool built by Liferay to automate the creation of interfaces and classes for database persistence and a service layer.
Service Builder will generate most of the common code needed to implement find, create, update, and delete operations on the database, allowing you to focus on the higher level aspects of service design. It manage transaction as well.


·          The first step in using Service Builder is to define your model classes and their attributes in a service.xml file. 

·          Liferay service builder is basically used to create the service layers for any business logic implementation.

·          Developer point of view it is very helpfull as it used to create all the service layers automatically.

·          This service builder will create whole structure of the service layers for developer mainly.

·          Service builder is used to create all these classes for developer, where they can add their business logic further and process the data and render the output to view as per the requirement.

·          It will automatic generate ADD, UPDATE, DELETE and SEARCH functionality.

·          It speeds up development process.

·          Service builder requires service.xml which is having some of the required entries.

·          Each of the entry is basically called entity, which is having it's primary key fields with some other required fields.

·          If we want to implement order and finder method, we can implement it by using this service.xml.

·          Each entity creates table into liferay configured database with the given column names and their types.

·          We can create service.xml

·          Related local-service and remote-service by setting them value as "true".

·          When we would run this build-service like below, this would create all the service layers (implementation, utility etc.)

·          Where developer can write their required business logic further.

·          Creation of all the service-classes would be done by the build.xml. we need to build-services using this xml file into Ant view of IDE.



  • Liferay permission


  • Permission is set of actions which will act on object/resource.
  • In Liferay each and every object we can call it as Resource and each resource have set of actions.
  • These actions are controlled by permissions.
  • In Liferay each permission/action will be associated with role and role will be associated with user.
  • Finally permission will be controlled the access of user over the site/ organization.
  • We have different kind of permission in Liferay


    1. Page level permission
    2. Portlet level permission
    3. Individual Resource level permission



  • Page level permission:

Page level permission will be decided whether page should be visible to particular role user or not. Based on permission action page will be visible to user

  • Portlet level permission:

Portlet Level permission will decide whether portlet should be visible to particular role user or not.

  • Individual Resource level permission

Individual resources like image, document or functionality with in portlet or application.
Example in Announcement portlet we have add announcement. Update and delete announcement.



  • Web Service
  • Liferay have in built support for REST API. So we can create REST web services for Plugin portlets means we can create web services for custom entities or portlet related entities.
  • We can create web service with help of Service builder.
  • We require setting use remote service true for entities
  • Define web service java method in XXXServiceImpl and Run service Builder
  • We can access plugin portlet json web service.
  • All of the public methods of that interface become registered and available as JSON web services.




 

Comments

Popular posts from this blog

Disable cache content of browser access on back button after logout liferay dxp

Some time we have requirement where we do not want to allow back button after logout and show cached browser content. Liferay provide properties which with we are able to restrict to see content on back button after logout. If user click back button after logout it will show the login page. We require to provide below properties in portal-ext.properties. Restart the server once applying below properties browser.cache.signed.in.disabled=true

Liferay crud porrtlet with Jasper Reports.

I have used Meera Prince Crud operation demo for the Jasper reports which allow to export report in PDF , word, XLS format. It will look lie below image. Find Source code for the complete example on below location. LIFERAY JASPER REPORT INTEGRATION 1 I have available PhoneManger Crud Portlet which have pagination and crud functionality. 2 I create report-listing-mobile.jrxml  file with help of Ireport tool. <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report-listing" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin=&q