Saturday, 25 October 2014

ECJ solution in Liferay eclipse

ECJ solution in Liferay eclipse

When we use JDT compiler in eclipse then It will expect ecj.jar should be available in global ant runtime path.

So we need to add ecj.jar file to ANT global class path as follows

Go to eclipse windows preferences


Select ANT run time as follows




Now add jar file to ant global class path. Select external jar file button then browsecj.jar file

Note:

ecj.jar file available in Plugins SDK lib directory (liferay-plugins-sdk-6.2.0/lib)



Thursday, 23 October 2014

Liferay intalation

Getting Started with Liferay IDE
  1. Getting Started with Liferay IDE
    1. Introduction
    2. Requirements
    3. Liferay Plugins SDK Setup in Eclipse
    4. Liferay Tomcat Server Setup
    5. Testing/Launching Liferay Tomcat Server
    6. Creating New Liferay Projects
    7. Deploying New Liferay Projects to Liferay Server
Introduction
NOTICE If you are using Liferay Developer Studio, please note there is a more appropriate tutorial for getting started with that product located here: Getting Started with Liferay Developer Studio
Liferay IDE is an extension for the Eclipse platform that supports development of plug-in projects for the Liferay Portal platform. Its available as a set of Eclipse plug-ins installable from an update-site. The latest version supports developing 5 Liferay plug-in types: portlets, hooks, layout templates, themes, and EXT-style plug-ins. Liferay IDE requires the Eclipse Helios Java EE developer package.
Requirements
Before getting started:
  1. Liferay Portal 6.0 (6.0.5 or greater) downloaded and unzipped
  2. Liferay Plug-ins SDK 6.0 (6.0.5 or greater) downloaded and unzipped
  3. Eclipse Helios Java EE for developers + Liferay IDE – see the Liferay IDE Installation Guide for more information.
Note: earlier versions of Liferay, e.g. 5.x, are not supported yet by the Liferay IDE
Liferay Plugins SDK Setup in Eclipse
Before you can begin creating new Liferay plug-in projects, a Liferay Plug-ins SDK and Liferay Portal must be installed and configured in the IDE.
  1. Open Eclipse with Liferay IDE installed.
  2. Open Preference page for Liferay > Installed SDKs (Go to Window > Preferences > Liferay > Installed SDKs)

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_1.png
  3. Add your SDK using the Add button which brings up the Add SDK Dialog.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_3.png
  4. Browse to the location of your Plug-ins SDK installation.
  5. The default name is the name of the directory but you can change it if you wish.
  6. Select OK and you should see your SDK in the list of Installed SDKs.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_4.png
Note: Multiple SDKs can be added to the preferences but you will need to select at least one SDK to be the default which is represented by the SDK that has the checkbox selected.
Liferay Tomcat Server Setup
  1. In Eclipse open the Runtime environments preference page (Go to Window > Preferences > Server > Runtime environments)

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_5.png
  2. Click Add to add a new Liferay runtime and find Liferay v6 Tomcat under the Liferay, Inc. category and click Next.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_6.png
  3. Click Browse and select the location of the liferay-portal-6.0.x directory.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_8.png
  4. Once you have selected the Liferay portal directory if it has a bundled JRE then that bundled JRE will be automatically selected as the JRE to use for launching the server. However, if there is no bundled JRE (Mac and Linux users) then you will need to select the JRE to use for launch.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_8a.png
  5. Click finish and you should see the Liferay portal runtime in the list of runtimes in the preference page.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_9.png
  6. Click OK to save the runtime preferences.
  7. If you didn’t choose to create a server you will need to create one from the servers view before you can test the server.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_9a.png
  8. Find the Liferay, Inc category and select the Liferay v6 Server and choose the Liferay v6 Runtime that you had previously created.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_9b.png
Testing/Launching Liferay Tomcat Server
  1. Once your Liferay Portal Server setup is complete you can launch the server from the servers tab of Eclipse. Simply select the server and then click on the green “Start the Server button.” Once the server is running a red “Terminate” button will appear which you can use to stop the server.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_10a.png

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_10b.png
  1. Alternatively, you can start/stop the server by selecting “Run” or “Terminate” from the Run menu of Eclipse.
  2. Once the server is finish launching you can open the portal home from the context menu of the Liferay Tomcat server in the Servers view:

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_10c.png
Creating New Liferay Projects
  1. Now that an SDK and portal server have been configured you can create a new Liferay plug-in project. Go to File > New Project... > Liferay > Liferay Plug-in Project.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_11a.png
  2. In the Liferay project wizard page, the newly configured SDK and Liferay Runtime should be pre-selected. Also the plugin type “portlet” is the default. Simply time in a project name and corresponding display name and click Finish.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_12a.png
  3. If it worked you should see a new plugin project in the package explorer.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_13a.png
Deploying New Liferay Projects to Liferay Server
  1. Now with the newly created project, right-click the Liferay Server in the Servers view and select “Add and Remove...”

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_14a.png
  2. Select the new project and click “Add” to move it to be deployed to the server.

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_14b.png

    and then click "Finish"
  3. You should see the project get deployed to Liferay Tomcat server and in the console see a message about 1 new portlet being available:

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_14c.png
  4. Open Liferay Portal Home http://localhost:8080/ in most cases
  5. Log in with test account:
    1. user is test@liferay.com
    2. password is test
  6. Click Add > More...
  7. Expand the Sample category and click the “Add” click next to the “Demo” application
  8. You should see the correctly deployed portlet on the page

    http://127.0.0.1:49958/help/topic/com.liferay.ide.eclipse.doc/help/gettingstarted/images/lide_getting_started_15a.png


Tuesday, 29 October 2013

Liferay 6.2 for u


If the user belongs to at least one site and has some administration priviledges then two additional menus appear:
  1. My Sites: Shows the sites that the user belongs to, with direct links to the public and private pages (if they exist).

     
  2. Admin: Contains a link to the Control Panel if the user has access to it and direct links to the site administration sections (Pages, Content, Users and Configuration) that the user has access to. The direct links to each section was one of the last additions based on early user feedback and it has two benefits: It requires fewer clicks to perform any administration operation and it shows the type of things the user will be able to manage for this site even before clicking them.

That's it for now. I'd love to hear your feedback on these changes.
Also, feel free to let me know what other features or improvements of the dockbar or Liferay 6.2 in general that you would like us to cover in upcoming blog entries.

Tuesday, 22 October 2013

LIFERAY PORTAL 6.2 IMPROVES MOBILITY AND WEM


LIFERAY PORTAL 6.2 IMPROVES MOBILITY AND WEM


For the first time in a few years, CMS Report isn't present at Liferay's North American Symposium currently taking place in San Francisco. However, we still have plenty of our friends there helping to feed us with any CMS related news coming out of this conference. Probably the biggest news presented yesterday was Liferay, Inc. revealing Liferay Portal 6.2 to the crowd. 
Liferay offers a more refined, mobile-ready version of the company’s flagship product. The new version should also help enterprises execute their engagement strategy across channels and audiences by making it easy to create mobile-responsive websites that connect with users across every stage of the relationship lifecycle. 
“Today’s enterprises need to interact with their customers, partners, and employees through compelling, seamless experiences across several channels,” said Bryan Cheung, CEO of Liferay. “Liferay Portal 6.2 is a modern, intuitive platform designed to help enterprises understand and reach their customers across mobile, web, and live contexts.”
A key focus of the new release is supporting mobile websites and apps. Websites and content created with Liferay Portal 6.2 automatically display correctly on mobile devices, and site administrators can define rules to handle specific devices and families differently. Liferay also provides mobile device previews right from the interface so users can quickly see how pages look on smaller screens. Finally, a new Mobile App Software Developer Kit (SDK), currently in the works for 6.2, will help developers build custom native apps that incorporate Liferay Portal functionality such as collaboration applications or integrated back end systems.

Major highlights in the new Liferay Portal 6.2 include:

Entirely Updated Modern User Interface – Twitter® Bootstrap-based theming for a slick, vibrant look and feel with instant access to the Bootstrap theme library; new Control Panel theme with streamlined site administration.
Liferay Portal 6.2 Control Panel 
New Mobile Engagement Features – Mobile readiness out of the box with responsive layouts, one-click mobile previews, mobile device rules, and a Mobile App SDK.
Improved Web Experience Management – Site Hierarchies for managing content and users across multiple sites; Application Display Templates, which allow developers to quickly customize the look and feel of applications; improved multi-language support for content, URLs, and applications.

Portal Resiliency, Modularity and Security – Increased platform stability through portlet sandboxing for isolation of individual portlet components from the portal; greater modularity in Liferay Portal architecture with ability to manage multiple versions of libraries, share libraries across multiple plugins, and upgrade and rollback portlets from version to version.
Liferay  Portal 6.2 App Manager
The new version will be available as part of the Liferay Portal Enterprise Subscriptions. Liferay Portal 6.2 will be available to the public later this year.

Wednesday, 16 October 2013

The Portlet Lifecycle

The Portlet Lifecycle

Essentially any client request made to the portal will result in one or more portlets
being invoked. The portlet lifecycle is defined in the Portlet interface of the Portlet
API and provides the following interface.
init(PortletConfig config)
processAction(ActionRequest req, ActionResponse res)
render(RenderRequest req, RenderResponse res)
destroy()
Initialization and Shutdown
The portlet container is responsible for initializing all of the portlets. The
initialization may take place once the portlet container starts up or the first time a request
is made to a portlet. If an error occurs during the portlet initialization, the portlet is not
placed into service. Generally, the initialization method is used to start up any resources
that are useful for the duration of the portlet’s functioning. As an example, the creation of
a connection to a database or a web service is often best done in the init method. The
PortletConfig object provides portlet configuration information that has been
defined in the descriptor.
Similarly the portlet container may invoke the destroy method when it decides
the portlet should be removed from service. This normally happens when the portal is
being shutdown.
Request Handling
Generally in the portal lifecycle, the portlet container will initialize all of the
portlets when the portal is started and invoke the destroy method on all portlets when
the container is shutdown. However while the portal is running every client request made
to the portal will often result in one or more portlets creating a markup fragment to be
included in the final portal page.
A request can be broken into two phases, action handling or rendering markup.
An action request is an optional state that can be made to change the state of the
underlying portlet application. For instance an example login portlet would allow users
to provide their name and password and will display a submission form to send the
supplied information to the portal, resulting in an action request. The portlet container
will handle any action request first before any content is generated as shown in the UML
sequence diagram. Once the action request has completed, the portlet container generates
markup by invoking the render method of every portlet on the page in no particular
order excepting those portlets that have defined their content to be cached. The portal is
responsible for aggregating all portlet fragments and displaying a full portal page back to
the user’s browser. A client request does not have to result in a processAction invocation.
However, every client request to the portal must go through the render phase (unless the
portlet’s content is cached).
Both processAction and render methods supply a request and response object.
The ActionRequest and RenderRequest objects inherit from PortletRequest, a decorator1
for a HttpServletRequest object defined in the Servlet specification. The portlet request
provides much of the same functionality as a HttpServletRequest object that traditional
J2EE web application developers are familiar with as well as methods for querying the
1 A Decorator[GoF], also known as a Wrapper is a design pattern that provides additional
functionality to an object by sub-classing to provide additional methods and exposing
many of the same methods of the underlying (wrappee) object. The Java stream and file
I/O classes are good examples of decorators.
current window state or portlet mode. The primary difference between the ActionRequest
and the RenderRequest is that an ActionRequest may not write to the output stream, since
it is responsible only for performing business logic.
Any event triggered within portlet such as submitting a form or clicking a link
will result in either an action request or a render request being made. The Portet API
provides methods for the construction of URLs in the portal to cause either event to
occur.


Monday, 14 October 2013

User Registration Portlet customization

User Registration Portlet customization


The registration or create account portlet in Liferay portal can be customized to add/remove some of its field without any coding.

This blog explain some of these customization properties which developers can add them in portal-ext to change the behavior of user registration portlet.

users.screen.name.always.autogenerate - If you do not want your users to provide screen name, you can use this property hide screen name text field. The default value is false. If it is changed to true, the screen name field will not appear on the registration page and screen name will be auto generated by the portal.

login.create.account.allow.custom.password - The default registration portlet in Liferay doesn't provide option of password selection to user. If this property is set to true, the registration screen will show password fields to user and user can provide password of his/her choice.

field.enable.com.liferay.portal.model.Contact.male - If your site is not interested in knowing the gender of the user, you can remove gender selection from the page by setting false value of this property.

field.enable.com.liferay.portal.model.Contact.birthday - Last configuration is for birth date field. You can remove bith date selection by setting false value to this property.

Following screen shot shows customized registration portlet using above properties.


captcha.check.portal.create_account - This propery can be used to tell whether or not to use captcha checks for the account creation.

There are few other properties related to user registration which requires more attaention.
users.email.address.required - Set this to false if you want to be able to create users without an email address. An email address will be automatically assigned to a user based on the property "users.email.address.auto.suffix". If user is entering his email id, the system will not generate a new one. Usually, setting this property to false will make sense when you don't want user to use email address for login.

Sunday, 13 October 2013

GENERICPORTLET IN LIFERAY

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:

doDispatch(RenderRequest request, RenderResponse response)
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 callsuper.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)throwsPortletException,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: