Share

Interview Questions

1. What is GroupId and CompanyId?
Ans:   CompanyId is the liferay portal instance id. If you setup liferay to be multi-tenant, this id is used to separate data between the virtual portal.
GroupId is organizational or site id.It's used if you want to separate your data between organization or sites.

2.What are the portlet Lifecycle methods?
Ans:
  1. init()
    1. It is called when portlet is deployed
  2. render()(Render Phase)
    1. Called to render the content.It represents Render Phase
  3. processAction() (Action Phase)
    1. Called when any action performed.It represents Action Phase
  4. processEvent() (Event Phase)
    1. Called when any Event is triggered.It represents Event Phase
  5. serveResource() (Resource Phase)
    1. Called when any Resource is served with resource URL.It represents Resource Serving Phase
  6. destroy()
    1. When portlet is un-deployed
3. If we perfom action or operation on on portlet in a page then what happens to other portlets in a same page?
Ans:
if action() method is completed for one portlet then its' render() method is called along with render()
method of all portlet on that page.


4. When init() method of portlet called? 
Ans: 
Intialization phase of portlet represented by init() method. When we deploy the portlet in liferay server portlet container calls init() method of portlet.

5.What is window state?
 Ans: 
window State represents current state of portlet.

6.What are the types of window States? 
Ans: 
Maximize: It shows the portlet in Whole page
Minimize:It shows the portlet in invisible stage.User explicitly need to make it either normal or
                 maximize.
Normal: It shows the portlet in normal as it is default
POP_UP: Used to show portlet in model popup

7.What is the difference between and ?
 Ans: 
  •  we can create render URL for current portlet only.
  •  we can create render URL for other portlet too. For this we need to give plid and portletName attribute. If we not provide these attribute then render URL created by tag will point to current portlet.
8. What are the default variables in a theme or Name some default velocity variables in a theme?
 Ans: 
Please o through the following Link
                              Default-variables-defined-in-theme

9. How to get a variable present in a portlet into theme?
 Ans: 
Theme can access the request and thus any query parameter given to the page.$request will give access to the request... thus you can do $request.getParameter("parameter").

Note that the parameter will not be namespaced so you should make sure that you don't namespace it also in your form.

10.What is custom attributes/fields
Ans:
It is the way to add additional attributes/fields to the existed portal entities so that in our real requirement if any fields you want then you can add.

11.How to give entire portlet as portlet
Ans:
By using Web Services for Remote Portlets(WSRP).These are the presentation-oriented webservices. These are web services that send user interfaces over the wire, rather than raw data like JSON objects or SOAP data envelopes.


12. What is structure and template?
Ans:
Structure will decide what kind of data we are going to use and template will decide look and feel  for data.

13.What is singleton and can you name singleton classes in Liferay
Ans:
A class which we can create one and only one instance of class is called singleton.
To make class as a singleton we need to make following three things
1. Constructor of that class must be private
2 .Create one  private static variable of type that class only
3. Create one public static method which will actually create instance of that particular class and assign to this static variable.
And the following are singleton classes in Liferay(As per my observations)

  • SessionContext
  • LiferayServerContext
14. Explain liferay folder structure and their contents
Ans:
Please go through the following link(It takes few minutes to read)

15. What is the difference between Servelt and Portlet
Ans:
Please go through the following link(It takes few minutes to read)

16.What is the similarities between  Servlet and Portlet
Ans:

  • Both are build on java technology
  • Both are managed by containers(Portlet container and Servlet container)
  • Client/server model
  • Life cycle is manged by container
17. What is the functionality provided by Servlet but not Portlet
Ans:
set encoding type to the response or Unable write any data into the Headers
The URL of the client request to the portal

18.How to achieve mapping relations between tables by using service builder
Ans:
If the entity and mapping-key attributes are specified and mapping-table is not,then the Service Builder will assume you are specifying a one to many relationship.(6.2 not support,It is handling in different way)

If the entity and mapping-table attributes are specified and  is not mapping-key, then the Service Builder will assume you are specifying a many to many relationship.(6.2 not support,It is handling in different way)

19. What are the steps to create finder method?
Ans:

  1. Define finder tag and finder columns in Entity tag
  2. Run service builder
  3. Implement custom method in XXXLocalServiceImpl class
  4. Run service builder
  5. Call implemented method using XXXLocalServiceUtil class
20. What is the difference between XXXLocalService and XXXService 
Ans:
LocalService: When we call methods from LocalService classes there is no security check applicable or there is no permission checking available.
Service: But here there is some security and permission checking applicable when we call methods from these classes.If user do not have permission then it throws Principle Exception


21. What is the use of XXXUtil class?
Ans:
All finder methods will be available in this class.By using this class  only we can call finder methods in the XXXLocalServiceImpl or XXXServiceImpl.

22. What are the steps to create a custom method?
Ans:

  1. Implement Custom method in XXXLocalServiceImpl class
  2. Run service builder
  3. Call implemented method using XXXLocalServiceUtil

23. What will happen if i call finder method in Jsp or Controller Class by using XXXUtil class?
Ans:
We will get Exception like as follows
org.hibernate.HibernateException: No Hibernate Session bound to thread

24. How to overcome from the above Exception?
Ans:
  1. Create one method in XXXLocalServiceImpl
  2. Call the finder method in XXXLocalServiceImpl method(XXXServiceUtil.findbyXxxx())
  3. Call the custom method in Jsp or Controller by using XXXLocalServiceUtil.method_name() 
25. What are the files will be generated when you run service builder?
Ans:
  • Persistance Layer
  • Service Layer
  • Model Layer
  • WebServices if you put remote attribute as true
  • Hibernate/Spring Config files
26. Which javascript method will be execute on each portlet ready?
Ans: 
Liferay.Portlet.ready(fn) : Executed after each portlet on the page has loaded.
Aui.ready(fn) : Executed HTML in the page has finished loading
Liferay.on(fn) : Excuted everything ready.

27. How to add new section/page in user-profile page(see below image) ?
 Ans:
The following 3 properties determine which sections are available 
  • users.form.add.main=Details(Under section page name)
  • users.form.add.identification=
  • users.form.add.miscellaneous= 
Categories that have no menus then they won't display(Like identification and miscellaneous) 


To add new section under category do the following steps
  • Choose a name for section and add it in the desired category as you wish in the properties mentioned above.
  • Create one jsp form with the same name given for the section
  • Locate this jsp under user_admin/html/ by using hook/ext.
  • Add a new entry in Language-ext.properties. 
28. How to get UserId?(It seems to be simple but in interview you can't get idea suddenly some times)
Ans:
User currentUser;
currentUser = themeDisplay.getUserId()
currentUser = PortalUtil.getUser(request)
currentUser = (User) request.getAttribute(WebKeys.USER)
29. What is meant by instanceable-portlet?
Ans:
Allow multiple instances on the page
Have different preferences
30. Liferay core portlets main configuration defined in which file?
Ans: portlet-custom.xml 

31. What developer mode do?
Ans:
  • Doesn't minify CSS and JS
  • Caching disabled for Templates and webcontents
  • Server does not launch browser when startup
For above all respective properties are there please go through in detail.
32. By which type of hook you can modify the method of service(UserLocalService)?
Ans: Service Wrapper hook
33. Which classes will be create when we run service build?
Ans:  
Persistance:
XXXPersistance
XXXPersistanceImpl
XXXUtil 

Service:
XXXLocalService
XXXLocalServiceImpl
XXXLocalServiceBaseImpl 
XXXLocalServiceUtil
XXXLocalServiceWrapper
if you put remote-service is true then 
XXXServiceSoap
XXXSoap

Model:
XXXModel
XXXModelImpl
XXX
XXXImpl
XXXWrapper 

34. Which class you will write logic for modifying the database column width only once?
Ans: GlobalStartupAction 

35. What is the difference between application.startup.events and global.startup.events?
Ans:
global.startup.events - Run once for global server
application.starup.events - Run for every portal instance at startup

36. Which class Liferay MVC portlet extends?
Ans: LiferayPortlet

37. Which class JSR-286 portlet extends?
Ans:GenericPortlet

38. How you will enable developer mode in Liferay?
Ans:
By adding portal-developer.properties file to application server's configuration file.  

39. How can you generate remote services using liferay service builder?
Ans:
By enabling remote-service-true in service.xml

40. How to implement custom-sql in Liferay?
Ans:
Step 1: Specify your Custom Sql
Create a folder custom-sql inside docroot/WEB-INF/src/custom-sql. Now craete a default.xml inside custom-sql folder.
Step 2: Implement your Finder Method

  • Crate a class XXXFinderImpl in the persistance package which extends BasePersistanceImpl class
  • Run the service builder to generate the Finder interface and Util for Fimder(XXXFinder and XXXFinderUtil)
  • Modify XXXFinderImpl class to have it implements XXXFinder interface you just generated.

Step 3: Craete a finder method inside XXXFinderImpl class
Step 4: Access your finder method from your service

  • Add the method inside XXXLocalServiceImpl class
  • Call the finder method by XXXFinderUtil.MethodName()
  • Run the service builder

Step 5: Access the method in action class by using XXXLocalServiceUtil

41. Tell me the steps for SOLR and Liferay Integration
Ans:

  • Download the latest SOLR and extract the zip file,name it as SOLR_HOME
  • Download the Solr war and deploy the war file in liferay tomcat server
  • Copy the schema.xml file from solr-web/WEB-INF/config which is deployed and paste/replace in SOLR_HOME/example/solr/config folder
  • Change the solr url as follows in solr-spring.xml which is located in solr-web/WEB-INF/classes/META-INF folder


 to this   

  • Now shutdown the tomcat server
  • Start the Solr Server using the following command from SOLR_HOME/example folder n command promt/terminal
    • java -jar start.jar
  • Now start the liferay sever
  • Add the search portlet in your page and test.

No comments:

Post a Comment