Thursday, 27 November 2014

Use of theme settings in theme plugin project

Requirement:

 In one portal instance we have a 2 websites Ex: EClassRoom and EMeetings.
 Now you want apply themes to them.

 But both sites will have the same theme structure but some content is changed, Like in EClassRoom website  you want show footer like "powered By www.eclassRoom.com"and in EMeetings website you want show footer like "powered By www.emeetings.com"

To fulfil the above scenarios we need to develop 2 themes with same structure, only because of footer content if different for both of them


Instead of creating two themes packaged as separate .war files,we create one set of two themes that share the majority of the code including CSS, JavaScript, images, and most templates using concept called "Configurable theme settings" it will allow you to mention same theme id with diffrent names in "liferay-look-and-feel.xml"


Follow the below steps to achieve it:

Step 1: create plugin project with theme
     File --> New--> Liferay plugin project --> enter name.
     Check theme and finish.

Step 2: open liferay-look-and-feel.xml and configure below properties


    <look-and-feel>
      <theme id="eclassroom" name="E-Class Room Theme">
        <settings>
          <setting key="theme-id" value="eclassroom" />
        </settings>
      </theme>
      <theme id="emeetings" name="E-Meetings Room Theme">
        <settings>
          <setting key="theme-id" value="emeetings" />
        </settings>
      </theme>
    </look-and-feel>

Step 3: create templates folder under _diffs  :docroot/_diffs/templates
Step 4: copy portal_normal.vm  file from "docroot/templates/" to "docroot/_diffs/templates"
Step 5: Replace the default footer section with the following lines of code:

    #set ($isEcrOrEmtgsThm = $theme.getSetting("theme-id"))
    #if ($isEcrOrEmtgsThm == "eclassroom")
      #language ("powered-by") <a href="http://www.eclassroom.com" rel="external">eclassroom.com</a> 
      // if you want you can include other velocity file by creating vm file in docroot/_diffs/templates like: //        //#parse ("$full_templates_path/footerEclassroom.vm")
    #else
      #language ("powered-by") <a href="http://www.emeetings.com" rel="external">emeetings.com</a> 
      // if you want you can include other velocity file by creating vm file in docroot/_diffs/templates like:    //#parse ("$full_templates_path/footerEmeetings.vm")
    #end
   
Step 6:Build and deploy the theme file.   
Step 7 : open control panel click on look and feel  their you should be able to see both the eclassroom and emeetings themes and apply any one of them to test it.

Based on the theme to be selected,you able to see your footer changes.

Monday, 17 November 2014

Attuen interview Quesitions on liferay

What is caching mechanism  in Liferay?
How to give a entire portlet as a webservices?
Explain about WSRP?
How to get a variable present in a portlet into theme?
What are the steps to work with finder method?
What are the methods are executed while working with Ajax calls?
What are the methods are executed while working with IPC?
I have 2 portlets in a liferay page now i did refresh then tell me how many render and action urls are created?
What is difference b/w  Hooks and Exts when to go?
What is diff b/w Jsr 168 and jsr 286 and what which jsr version is current liferay version followed?
Diff b/w liferay 6.0.6 and 6.2?
I will add a one value in portal.properties and same property will have in web.xml so what value will be affected?
How to handle transaction management in liferay ,Is it developer responsibility to handle or liferay handle it?
How to add same portlet for multiple time in one page?
How to add portlet to control panel?

Friday, 14 November 2014

Embedding portlets in a layout

Create New  Liferay Plugin Project.
Enter columns-1-3-1 for the Project name and Columns 1 3 1 for the Display name.
Select Layout Template as your plugin type.
Click Finish.

You will see following file under /columns-1-3-1-layouttpl/docroot/columns-1-3-1.tpl
open that file and write the following code:

 <div class="tworows" id="main-content" role="main">
    <div class="portlet-layout">
        <div class="portlet-column portlet-column-only" id="column-1">
            $processor.processPortlet("states_WAR_PortletModesportlet") //here we need to give a portlet id which you want include Layout
            $processor.processColumn("column-1", "portlet-column-content portlet-column-content-only")
        </div>
    </div>
    <div class="portlet-layout">
        <div class="aui-w33 portlet-column portlet-column-first" id="column-2">
            $processor.processColumn("column-2", "portlet-column-content portlet-column-content-first")
        </div>
        <div class="aui-w33 portlet-column" id="column-3">
            $processor.processColumn("column-3", "portlet-column-content")
        </div>
        <div class="aui-w33 portlet-column portlet-column-last" id="column-4">
            $processor.processColumn("column-4", "portlet-column-content portlet-column-content-last")
        </div>
    </div>
    <div class="portlet-layout">
        <div class="portlet-column portlet-column-only" id="column-5">
            $processor.processColumn("column-5", "portlet-column-content portlet-column-content-only")
        </div>
    </div>
</div>


Click on save
Do ant deploy
Login into portal[localhost:8080] as a admin
Add new page to portal.
Apply Layout[columns-1-3-1] which you have created
Able to see the portlet along with layout in page.

Wednesday, 12 November 2014

Important Liferay Blogs and Sites

http://www.liferaysavvy.com
http://liferaytips.tumblr.com
https://sushilsaini.wordpress.com
http://spaquet.blogspot.in
http://tirthalpatel.blogspot.in
http://koolanky.blogspot.in
https://www.lumdev.net
http://liferaysatish.blogspot.in
http://btnkumar.blogspot.in
https://www.safaribooksonline.com
https://www.permeance.com.au/web/tim.telcik/home/-/blogs/1167536
http://www.theserverside.com
http://www.opensourceforlife.com
https://liferayportaltutorial.wordpress.com
http://liferaytutorial.blogspot.in

Tuesday, 11 November 2014

Embed portlet in Theme,layout and webcontent

Embed portlet in theme?
    $theme.runtime("56_INSTANCE_a123")

Embed portlet in Layout?
     $processor.processPortlet("73")



Embed portlet in Webcontent?
 <runtime-portlet name="here portlet name" instance="any name its like string you can enter any thing" queryString=""/>

 queryString="" --- is used to arguments

Liferay Interview Quesitions : Attuneww

What is the diff b/w portal-impl.jar and portal-service.jar?
What is the organization in liferay?
What is the diff b/w Organization and site when to prefer which one?
Tell me the one scenario like when to go for organization?
Explain steps for implementing spring portlet?
While deploying the portlet using ANT I want put my war file deploy folder of tomcat so what can I do?
How to work with multiple databases?
What is the diff b/w liferay-portelt.xml and portlet.xml?
How to develop our custom theme?
What is velocity and how to use in liferay?
What is the service builder and how it works in liferay?
What is the use of remote-service=true in service.xml?
How to expose our services as a webservices?
What is structures and templates?
How to make portlet as a instancable ?
what is the diff b/w hook and ext when to go?

Friday, 7 November 2014

CD Quesitions on Liferay

1.What are the plugins in Liferay?
2.What are the customfields ?
3.Explain about portlet life cycle.
4.What is service builder?
5.What is the team?
6.what is the difference between community/organization?
7.How to embed portlet in themes and layouts?
8.what is encapsulation?
9.what is use of Class.forName()?
10.Have you created hook?
11.Have you created ext?
12.Explain about jsr 286 features
13.How to connect to multiple databases?
14.what is the use of remote service=true?
15.How can I access the services in the entire portal level?

Liferay Interview Quesitions

What is diff b/w liferay 6.1 and 6.0.6?
What are the steps to migrate from 6.0.6 to 6.2?
what will be the happen when we override any portal services using hook?
what is Hook and Ext and when to go for them?
I have 2 portlets now I want use one portlet services in another portlet how can I?
when user click on the login  we want validate the user Date Of Birth along with his password?
What is jsr used by liferay 5.x?
What is diff b/w jsr 168 and jsr 286?
Have you used any Design patterns in project?
Have you used collection any where in project and explain?
Explain about how singleton class will work?

Wednesday, 5 November 2014

Liferay Interview Quesitions

What is liferay and what is the main use liferay portal?
Diff b/w jsr 168 and 286 and what about jsr 314?
Explain about lifecycle of portlet?
Have you done any integrations like solr and JBPM
Have done any integrations like Alfresco or some other thrd perty ?
have done any Junit testing for your apps?
I have a 2 organizations in my liferay instance ,so how can you provide domains or url for that 2 organizations?
How to change the user login options like he have login with user id or Email address ?
How do mail configurations in liferay?
What is use of portal.properties,what it contains and how do we override?
What are the implicit objects of jsp?
what is diff b/w servlet config and servlet context?
Have you done any themes and why we go for themes?
Explain about projects you worked on?
Have you aware of cloud deployments?
What is dependency injection?

Saturday, 25 October 2014

GenericPortlet:

GenericPortlet:
 GenericPortlet is abstract class and it extends Object class and implements Portlet,PortletConfig interfaces.
The GenericPortlet class provides a default implementation for the Portlet interface.It provides an abstract class to be subclassed to create portlets. A subclass of GenericPortlet should override at least one method, usually one of the following:

    processAction, to handle action requests
    doView, to handle render requests when in VIEW mode
    doEdit, to handle render requests when in EDIT mode
    doHelp, to handle render request when in HELP mode
    init and destroy, to manage resources that are held for the life of the servlet

Normally there is no need to override the render or the doDispatch methods. Render handles render requests setting the title of the portlet in the response and invoking doDispatch. doDispatch dispatches the request to one of the doView, doEdit or doHelp method depending on the portlet mode indicated in the request.
Portlets typically run on multithreaded servers, so please note that a portlet must handle concurrent requests and be careful to synchronize access to shared resources. Shared resources include in-memory data such as instance or class variables and external objects such as files, database connections, and network connections.

Methods in GenericPortlet:

doHelp(RenderRequest request, RenderResponse response)
doView(RenderRequest request, RenderResponse response)
getInitParameter(java.lang.String name)
getResourceBundle(java.util.Locale locale)
init()
render(RenderRequest request, RenderResponse response)
init:
public void init(PortletConfig config)  throws PortletException
Called by the portlet container to indicate to a portlet that the portlet is being placed into service.
The default implementation just stores the PortletConfig object.
The portlet container calls the init method exactly once after instantiating the portlet. The init method must complete successfully before the portlet can receive any requests.
The portlet container cannot place the portlet into service if the init method does one of the following:
1.         it throws a PortletException
2.         it does not return within a time period defined by the Web server
public void init() throws PortletException
A convenience method which can be overridden so that there's no need to call super.init(config).
Instead of overriding init(PortletConfig), simply override this method and it will be called by GenericPortlet.init(PortletConfig config). The PortletConfig object can still be retrieved via getPortletConfig().
processAction:
public void processAction(ActionRequest request,ActionResponse response)
throws PortletException,java.io.IOException
Called by the portlet container to allow the portlet to process an action request. This method is called if the client request was originated by a URL created (by the portlet) with the RenderResponse.createActionURL() method.
The default implementation throws an exception.
Specified by:
processAction in interface Portlet
render:
public void render(RenderRequest request,RenderResponse response)
throws PortletException,java.io.IOException
The default implementation of this method sets the title using the getTitle method and invokes the doDispatch method.
Specified by:
render in interface Portlet
getTitle:
protected java.lang.String getTitle(RenderRequest request)

Used by the render method to get the title. The default implementation gets the title from the ResourceBundle of the PortletConfig of the portlet. The title is retrieved using the 'javax.portlet.title' resource name.Portlets can overwrite this method to provide dynamic titles (e.g. based on locale, client, and session information). Examples are:
  • language-dependant titles for multi-lingual portals
  • shorter titles for WAP phones
  • the number of messages in a mailbox portlet
Returns:
the portlet title for this window
doDispatch:
protected void doDispatch(RenderRequest request,RenderResponse response)
throws PortletException,java.io.IOException
The default implementation of this method routes the render request to a set of helper methods depending on the current portlet mode the portlet is currently in. These methods are:
·      doView for handling view requests
·      doEdit for handling edit requests
·      doHelp for handling help requests
If the window state of this portlet is minimized, this method does not invoke any of the portlet mode rendering methods. For handling custom portlet modes the portlet should override this method.
doView:
protected void doView(RenderRequest request, RenderResponse response)throws PortletException,java.io.IOException

Helper method to serve up the mandatory view mode. The default implementation throws an exception.
doEdit:
protected void doEdit(RenderRequest request, RenderResponse response)
throws PortletException,java.io.IOException

Helper method to serve up the edit mode. The default implementation throws an exception.
doHelp:
protected void doHelp(RenderRequest request,RenderResponse response)throws PortletException,java.io.IOException

Helper method to serve up the help mode. The default implementation throws an exception.
getPortletConfig:
public PortletConfig getPortletConfig()
Returns the PortletConfig object of this portlet.
Returns:
the PortletConfig object of this portlet
destroy:
public void destroy()
Called by the portlet container to indicate to a portlet that the portlet is being taken out of service. The default implementation does nothing.
Specified by:
destroy in interface Portlet
getPortletName:
public java.lang.String getPortletName()
Returns the name of this portlet.
Specified by:

getPortletContext:

public PortletContext getPortletContext()
Returns the PortletContext of the portlet application the portlet is in.
Specified by:

getResourceBundle:

public java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
Gets the resource bundle for the given locale based on the resource bundle defined in the deployment descriptor with resource-bundle tag or the inlined resources defined in the deployment descriptor.
Specified by:
getInitParameter:
public java.lang.String getInitParameter(java.lang.String name)
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
Specified by:
getInitParameterNames:
public java.util.Enumeration getInitParameterNames()
Returns the names of the portlet initialization parameters as an Enumeration of String objects, or an empty Enumeration if the portlet has no initialization parameters.
Specified by: