Top 27 Java Liferay Interview Questions
Q1. How Do You Perform Junit Tests On Your Portlet?
Junit assessments are there to check the code in particular via presenting the price of any method input parameter, how the approach could work and gives the values.
Public elegance MyEmployeeTest
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"ApplicationContext-provider.Xml");
public void testMyMethod()
UserService employeeService = (UserService) context.GetBean("userService");
//Provide the user Id as 101581
User consumer = storeService.FindUserByUserId(1234);
//get the employee
Set employee = consumer.GetEmployeesForUserId();
System.Out.Println("Employee Name : "+employee.GetName());
Q2. What Is A Portlet Lifecycle?
Following is the portlet lifecycle:
init(): It especially initializes the portlet.
Render(): It takes the HTML output to User Interface. It especially render the view in time period of JSP/HTML code and show into the respective portlet.
Destroy: This technique takes care of freeing the portlet assets.
Q3. How Can I Configure Liferay To Use Email Address As User Name Instead Of Screen Name?
We can set this from control panel -> portal settings -> Authentication -> LDAP -> How do users authenticate?. Here we will choose some thing we require from e-mail deal with,display call or person ID. At the time of LDAP authentication, we need to provide the specified LDAP mappings which essentially reads all of the info related to users and usergroups from LDAP directory and import into Liferay portal. At the time of this reference to 1/3 birthday celebration we want to provide the specified subject like authentication ought to be via e mail cope with or display screen name or user ID.
Q4. How To Setup A Liferay Cluster From Scratch?
We want to setup below houses in our portal-ext.Houses(that is for one instance represented by way of 1p, equal homes we need to feature for 2d example additionally represented via 2p) and some required IP addresses.
#cluster configurations - these settings are for cluster
net.Sf.Ehcache.ConfigurationResourceName=/myehcache/hibernate-clustered.Xml
dl.Store.Record.Device.Root.Dir=/webapps/document_library_cluster
#different settings for cluster
liferay.Home=/webapps/liferay-1p/liferay-portal-6.1.10-ee-ga1/
lucene.Dir=/webapps/liferay-1p/liferay-portal-6.1.10-ee-ga1/records/lucene
cluster.Link.Enabled=authentic
lucene.Reflect.Write=real
multicast.Group.Deal with["cluster-link-control"]=239.255.Four.1
Q5. What Is A Portlet?
Liferay portal comes with extraordinary portlets via default. These portlets are not anything but different small packages jogging in the example(portal). Portlets are pluggable software program components which can be managed in a web portal.
In standard phrases you could name them as unique catalogues as portlets produce fragments of markup code which can be aggregated into a portal. So a portal page is displayed as a group of portlet, thease more than one small programs collectively making a web page of the website and these all pages collectively makes one network or agency portal. Hence a portlet (or series of portlets) resembles a web-based totally utility this is hosted in a portal.
Portlet is a small utility to satisfy the requirement of positive area. Inter portlet verbal exchange is supported below Liferay portal. Portlet aid warm deployment function of Liferay Portal.
Q6. How To Configure Liferay To Use A Jndi Jdbc Datasource Instead Of Internal C3p0 Connection Pool?
We want to do the access of perticular aid with a few certain parameter like name, factory, driverclassname, url of database, uaername and password.
Below is the access of aid in which JDBC datasource is configured.
Call="jdbc/LiferayPool"
factory="org.Apache.Tomcat.Jdbc.Pool.DataSourceFactory"
driverClassName="com.Mysql.Jdbc.Driver"
url="jdbc:mysql:///?AutoReconnect=authentic&useUnicode=genuine&characterEncoding=UTF-8&useFastDateParsing=false&noAccessToProcedureBodies=authentic"
username="liferay"
password="0bknSWE2zzl"
initialSize="10"
maxActive="2 hundred"
minIdle="0"
/>
Below is the entry of resource wherein c3p0.ComboPooledDataSource is configured.
<Resource
name="jdbc/LiferayPool"
auth="Container"
type="com.Mchange.V2.C3p0.ComboPooledDataSource"
factory="org.Apache.Naming.Factory.BeanFactory"
driverClass="com.Mysql.Jdbc.Driver" jdbcUrl="jdbc:mysql:///?UseUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false&noAccessToProcedureBodies=true"
user="liferay"
password="0bknSWE2zzl"
minPoolSize="10"
maxPoolSize="100"
/>
Q7. What Is Portal-ext.Properties File? How This Can Be Configured And Used In Liferay?
Liferay Portal comes with default configurations which might be stored in portal.Assets record. You can use portal-ext.Houses report to override the values in portal.Homes document.
This lets in you a clean way to hold your own reproduction of configurations that can be used outside the portal on the equal time you may easily upgrade the portal.
Q8. How Can You Customize Liferay Search Feature? What Are The Apis To Do It?
We can personalize Liferay Search characteristic, relies upon upon our requirement via under methods.
Hook : If changes are required as in line with the view facet like we want to alternate the quest end result shape view then we can write the Hook to customize it.
EXT : If modifications are required as in line with the center functionality like we need to trade the quest question term, we can enforce EXT.
Q9. What Is A Liferay Theme? What Are The Advantages Of Using Them?
Liferay issues are the way to customise appearance and sense of a liferay portal web page. The subject matters are extendable additives that may be deployed separately on a portal and every web page at the portal can pick a unique subject matter (if required).
Themes are absolutely powerful way to run more than one web sites from a single portal. You can host a couple of web sites on a unmarried liferay portal with totally extraordinary appearance and experience. This permits you to be unique at the same time keep loads sources on web hosting.
A lot of organizations use liferay for creating multiple unique web sites with the assist of awesome topics that may be without problems developed.
Themes also are to be had from market.
For developing on our own, we have choice of using VM pages(Velocity templates). Liferay offers the feature to install the one-of-a-kind subject matters into the portal identical like portlets conflict documents. So wide variety of topics we can be deployed into Liferay portal and we will in addition select those subject matters for consumer interface as in keeping with the requirement of give up person for distinctive site or employer pages.
Q10. What Is Inter-portlet Communication? Why Is It Required To Use Jsr Style Inter-portlet Communication?
Sometimes we've got the requirement wherein we want to establish verbal exchange in among two portlets as an example any movement finished in a single portlet redirecting the quit person to different portlet where a few sort of result is showing as per movement done on first portlet.
So on this use case we should use liferay inter-portlet communication mechanism which serve the action carried out by using quit person in a single portlet and offer the result to the second portlet in which the action end result wishes to be displayed. We can say that it really works on striker-catcher mechanism.
JSR style inter portlet conversation guarantees that your portlets are going to paintings on another JSR compliant portal server. If you use a liferay precise way to speak among portlets than you can no longer be able to install and run the equal portlet conflict on every other JSR compliant portal (e.G. Apache Pluto)
Q11. How To Support Internationalization (i18n) On Liferay Portlets? How Do You Support Multiple Languages Without Writing Java Code In Liferay?
We can help internationalization (i18n) on Liferay portlets and through out this whole Liferay portal. We need to offer something language we want to assist into LIferay portal. This is in particular reads the areas range and offer the available language like en_US(english), SG(singapore), zh_CN(easy chinease), zh_TW(traditional chinease), ja_JP(Japanease).
In the identical way to provide aid of a couple of languages with out writing java code in Liferay, we are able to use Locales this through out the portal,
portlet, hooks and topics. This entry we will offer into identical portal-ext.Houses which Liferay portal might study and provide all of the trlation hence.
Locales=en_US,zh_CN,zh_TW,ja_JP,ko_KR
If we are writing a few custom messages in out code then we need to provide the under property documents also as in keeping with the referred to as language and the use of of Locales would convert it for that reason. We can use LocaleUtil in our code if you want to convert the certain message given in language files.
For instance we want the assetCategory title in multi languages then we need to apply this assetCategory.GetTitle(locale). So here anything locale we've noted earlier could be in action and pick the given title name from positive locale associated language.Assets file.
Language_en_US.Homes
Language_zh_CN.Properties
Language_zh_TW.Residences
Q12. How To Customize The Behavior Of Liferay Default Out Of The Box Portlets (e.G. Document View, Calendar, Blog, Wiki Etc) ?
If we need any customization, associated with JSP and UI then we are able to enforce this using Hooks. Liferay portal comes with a bundle wherein all of the default built in portlets exist.
If any customixation required in the core level lessons then it may be done via EXT as an instance LDAP users and consumer groups import amendment. However here in EXT, restart would be required.
Q13. How Can I Configure Two Different Domain Names (e.G. First.Instance.Com And Second.Example.Com) On Liferay?
At the time of introduction of any web site we need to offer domain names which in addition take it as website online area name. We want to offer the positive domain call as required through the manage panel of liferay portal. Single example of Liferay Portal supports web hosting of or greater domain names through groups(web sites).
When we can go to control panel -> Site settings -> we will provide the site URL, info like website online(network) description, club kind, energetic status and digital host.
Q14. How Can You Integrate Liferay With An External Content Management System (e.G. Alfresco)?
Liferay passes consumer credentials through CMIS to the alfresco with the intention to connect. To enable this in liferay, we want to go into following below assets in portal-ext.Homes to be able to permit liferay to keep password in consultation.
Consultation.Save.Password=true
Also one more aspect we need to think about is that Liferay passes logged in user's credentials to CMIS Repository (whihc is alfresco
right here) as defined above. What this me is that userid/password in liferay ought to healthy userid/password in Alfresco. Alfresco by means of default uses a loginid (which is just like display-call in liferay) to authenticate consumer. So we want to make liferay also authenticate the use of display call with the aid of making following access into portal-ext.Homes.
Organization.Security.Auth.Kind=screenName
So we need to begin Liferay. Login as administrator and visit manipulate panel. We want to go to Document and Media so that you can deliver up a screen in which we want to click on Add -> New Repository. This could deliver one screen where we essentially provide connection information to connect with Alfresco like under.
Name: Give any name you want to offer in your repository view in liferay. For instance, I will supply Alfresco repository name.
Description: A quick description approximately it.
Repository Type: We can join either using AtomPub or the use of net services.
AtomPub URL: This might be the CMIS repository URL wherein our alfresco is strolling. In our case, it is might be http://localhost:8080/alfresco/provider/api/cmis (Note: In case of Alfresco four.0, it'll be http://host:port/alfresco/cmisatom).
Repository ID: It is essentially used to connect to a specific repository incase we've got more than one repositories to be had. If we do not enter a repositoryId, then it's going to just look for the first repository the use of the given parameters and set it to that.
Q15. How Will You Configure A Portlet That Can Be Added Multiple Times On A Portal Page?
One property is there in portlet.Xml that is as follows:
<instanceable>genuine</instanceable>
by means of the use of the value proper and false we can configure a portler that may be introduced multiple times on a portal page.
Q16. What Is A Liferay Portal Instance?
Liferay portal ships with the one liferay portal tomcat bundle which is up and strolling in any server with sure database settings. We may have more than one liferay instances running from one database.
Liferay Portal lets in you to run multiple portal example on a unmarried server. The Portal Instances web page of the manage panel helps you to control these times. Data for each portal instance are stored separate. All portal statistics, however, is kept in the equal database.
Each portal instance calls for its own area call. Liferay will direct customers to the proper portal example based on this domain name. So earlier than you configure an instance, we want to configure its area name in our community first. When we are equipped to add an instance, click the Instances tab - > Add button.
It can be precipitated for four fields and a check field:
Web ID: A fashionable conference is to use the domain call for this. It’s a consumer-generated ID for the instance.
Virtual Host: Put the domain call you configured to your community right here. When users are directed on your Liferay server thru this area name, Liferay will then be able to ship them to the proper portal example.
Mail Domain: Enter the domain name for the mail host for this instance. Liferay will use this to ship email notifications from the portal.
Max Users: Enter the maximum numbers of user money owed you would love your portal example to aid.
Active: Use this take a look at box to pick out whether to create an lively or an inactive portal example.
Now we need to click on Save. Now navigate to the portal the use of new domain name. We will see that looks like a clean deploy of Liferay. This is our new portal example which can now be up and jogging.
Q17. What Is The Difference Between View Mode And Edit Mode Of Portlets?
The modes of a portlet are typically associated with the types of operations a consumer can perform on the portlet. A view mode is where customers are allowed to do read only operations, whereas in edit mode consumer can add/replace the information inside the portlet.
Each portlet mode has a technique which handles it:
doView()
doEdit()
doHelp()
These techniques will comprise especially our "traffic directing" logic, which are responsible to determine what view the consumer wants to see.
Once the view has been decided, we will ahead directly to techniques which simply enforce that view.
For fashionable portlet view modes have views:
The default view which indicates the listing of gadgets.
The shape, in which users will specifically do the add and edit action.
In this in which cease person can edit the specific item, is referred to as edit mode of portlet.
Q18. How To Set The Display Category Of A Custom Built Liferay Portlet ?
We can set the display class like below noted liferay-show.Xml. Suppose we have evolved one portlet in which portlet ID we've provided. We need to enter the custom built liferay portlet into certain class like name "class.Cms", "category.Collaboration" and so on.
By doing this custom built liferay portlet could are available required category by way of clicking the add utility characteristic of liferay as there might be many of portlets under different classes. So under tag we need to go into for the entry of a portlet into positive class.
<display>
<category name="category.Cms">
<portlet id="20" />
</category>
</display>
Q19. Which One Is Best To Start In A Clean Setup?
Liferay package with tomcat app server is the exceptional one to start in a easy setup.
Q20. What Is The Difference Between Hook, Ext And Portlet?
Liferay offers three ways to increase the capability of a Liferay portal. Each of the way suits is right for extraordinary needs.
Hook:
Liferay portal comes with a package deal wherein all of the default built in portlets exist. Typically if any customization required in phrases of JSP (UI) and portal homes. We want to go with the aid of Hook implementation. Hook is supported by way of hot deployment. Liferay documentation shows that - Whenever feasible, hooks should be used in place of Ext plugins, as they're warm-deployable and greater ahead compatible.
Some not unusual situations that require the usage of a hook are:
When you need to perform a custom motion on portal startup
When you have to carry out a custom movement on consumer login
When you want to overwrite or expand portal JSPs
When you need to modify portal residences
When you need to replace a portal service along with your very own implementation.
EXT:
Liferay EXT Plugins are the most effective way to extend the portal capability. If any customization required inside the middle level lessons then it may be finished thru EXT as an example LDAP customers and person groups import change. But right here in EXT, restart could be required.
EXT Plugins should be used simplest in case the portal functionality can not be prolonged using Portlet of Hooks. The EXT plugins are complex to develop and might cause maintenance issues in case you are trying to improve.
From liferay files, The major use instances in which an Ext plugin may be used are:
Customizations to portal.Homes (that isn't supported through Hook Plugins)
Customizing and making adjustments to the Struts Actions for portal
Customizations of the Liferay be declared in Liferay's Spring documents
Adding JSPs that are referenced from portal homes that may most effective be modified from an ext plugin (make sure to check if the property may be changed from a hook plugin before doing this)
Direct overwriting of a category (now not endorsed unless it's strictly vital)
Portlet:
Portlets are the maximum common and easiest manner to extend and provide a custom capability for a liferay portal. This is a small utility to satisfy the requirement of positive area. It is largely a gaggle of code(Java Files, JSP, CSS, Java Scripts and many others.). Portlet is supported by means of hot deployment.
Liferay additionally has a market wherein a whole lot of beneficial portlets are available for down load and those portlets can contributed by way of anybody within the world. We lately contributed a Speed studying portlet and a My IP Address portlet in this marketplace for free use by way of liferay network.
Q21. How To Use Aui In Liferay? What Are The Advantages Of Using It In Liferay Instead Of Jquery Or Some Other Js Library?
AlloyUI (AUI) is Liferay's open-supply javascript library. It is constructed on Yahoo User Interface (YUI) and has aid for a variety of advanced javascript features in particular designed for portlets. As it's miles Liferay furnished JS library right here no need to merge this code. It is designed to take benefit of and comprise patterns from the first-class libraries to make building sturdy and flexible internet programs.
It is a JavaScript library, a CSS framework, a set of HTML recipes and a taglib library, all blended to empower developers across multi-skilled teams deliver rich and dynamic programs. Only we want to add sure tag library like below in an effort to use Liferay Alloy UI libraries.
<taglib>
<taglib-uri>http://liferay.Com/tld/aui</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-aui.Tld</taglib-location>
</taglib>
So similarly we will use these all shape and fields like beneath in our JSP code.
<aui:form>
<aui:input name="Name" size="45" />
</aui:form>
Q22. What Is A Liferay Portal?
In widespread, a web portal represents an internet software that gives a single point of get admission to to style of facts.
Functionality of a portal can extended very without difficulty by using growing custom programs which can run internal a portal. These packages are referred to as portlets.
For jogging portlets you want application server which can run a portlet box spec (JSR168 or JSR286). There are dozens of free and organization portal products available.
Liferay portal is an open supply portal and underneath are the blessings of the use of Liferay portal:
Content control machine(Documents, Articles).
2-level,three-degree workflows and publishing.
Social networking. Four)Sites and organization basis pages.
Integration with third birthday party like LDAP, Solr, SSO(CAS, Siteminder).
Portlets realted to Wiki's, News, Finance, Social, Workflow, Collaboration.
Compatible with specific Operating systems, databases and APP servers.
Compatible with UI technologies and net services.
Compatible with distinctive scripts like PHP, Ruby, Grails, Python.
Suppport of hot deployment feature.
Q23. What Jsr Version Liferay Implements? Why Jsr Compatibility Is Important While Choosing A Portal?
JSR is a "Java Specification Request". Liferay Portal is advanced to stick to JSR 168 and JSR 286 specs.
This specification is created with the aid of committee of JEE portal carriers. This specification is designed to gain interoperability between distinctive portals and portlets.
Liferay helps specially underneath JSRs:
JSR-168(Portlet 1.Zero)
JSR-286(Portlet 2.0)
JSR-127(JSF 1.0)
JSR-a hundred and seventy
JSR-314(JSF 2.Zero)
JSR-329
Why those standards are defined?
These standards are described for the benefit of portal users (quit customers). Before those requirements have been born, portal patron have been required to use one portal and there was no smooth manner to interchange among exclusive portal providers. Earlier portal have been very seller specific and all functionality had been advanced the use of proprietary API, era and programming strategies. The JSR 168 and JSR 286 requirements have described the manner portlets may be evolved that will assist users in long term.
Benefits of Following JSR Standards:
Following these standards will ensure that there's no seller lock in. However this can be assured handiest while the portlets are developed sticking to the standards.
Q24. What Are The Advantages Of Using Tomcat Bundle Of Liferay Against Other App Servers (e.G. Jboss, Glassfish Or Others)?
It is feasible to use Liferay with Liferay IDE with other then tomcat server bundles but there are some capabilities or blessings with a view to no longer be to be had:
Native eclipse server adapter that helps launching and debugging.
Deployment via add/put off modules wizard would not be to be had.
Auto redeployment based totally on modifications to mission sources.
Q25. What Is Liferay Service Builder? Is There Any Alternative To Use Service Builder? What Are The Advantages And Disadvantages Of Using It?
Liferay carrier builder is largely used to create the provider layers for any enterprise logic implementation. From developer point of view it's far very helpfull because it used to create all of the provider layers computerized. Suppose we want to expand a portlet, for this we want to put in writing all the required implementation training, software cleasses and other required classes. Service builder is used to create these types of training for developer, wherein they can add their business good judgment similarly and procedure the statistics and render the output to view as in line with the requirement.
As in step with the advantage, this provider builder will create entire structure of the carrier layers for developer in particular. It certainly helps them to write down the code and their common sense in service builder created version implementations and service implementation training. These training comes with everyday CRUD (create, update and delete)operations. For developer, no want to add whatever greater as whole service and utility layers are already got created through provider builder. It honestly accelerate the developement procedure.
Service builder calls for service.Xml that is having some of the desired entries. Each of the access is basically known as entity, that is having it's number one key fields with some other required fields. If we want to put in force order and finder approach, we are able to enforce it by way of using this carrier.Xml.
Each entity creates table into liferay configured database with the given column names and their sorts. We can create service.Xml associated neighborhood-service and remote-provider through setting them price as "true". When we would run this build-provider like underneath, this will create all the provider layers(implementation, software and so on.) where developer can write their required enterprise common sense further. Creation of all of the carrier-instructions might be finished by using the build.Xml, we want to build-offerings using this xml record into Ant view of IDE.
Q26. How To Use Ldap Authentication With Liferay?
LDAP is lightweight directory get admission to protocol that is maximum normally used for authentication and authorization of users. LDAP particularly consists customers and usergroups of any employer with positive serach filter out like DN entries. In the manipulate panel of liferay we've got choice to offer the LDAP settings so that portal can touch the 0.33 birthday party like LDAP and fetch the desired users and agencies as according to given mappings.
For example Active directory is a LDAP implementation that may store customers. Liferay aid integration of any LDAP implementation thru its admin control panel.
We need to provide the settings in control panel - > portal settings -> LDAP
This will require LDAP URL, username, password, users search filters mappings, organizations seek filters mapping and so on.
Q27. How To Use Jquery In Liferay?
We want to offer the entry like beneath in our JSP files. So that it could study the supplied java script path very easily and we are able to use jQuery for this reason.
<script kind="textual content/javascript" src="<%=themeDisplay.GetPathThemeCss()%>/../js/jquery-1.7.2.Min.Js"></script>

