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:

Saturday, 12 October 2013

Earning money through online

Liferay monitoring using Google Analytics

Liferay monitoring using Google Analytics

Liferay includes built-in support for Google Analytics, allowing administrators
to make use of Google’s tool set for analyzing site traffic data. When you sign
up for Google Analytics, a snippet of code is provided which needs to be added
to your web pages to allow Google’s system to register the page hit. It can be a
tedious process to add this code to every page on a site, especially if it’s a large
site and there is a lot of user-generated content.
is problem can be solved in Liferay by puing Google’s code into a custom
theme wrien specifically for the web site on which the portal is running. Doing
this, however, requires a theme developer to make specific changes to the theme
and it prevents users from using the many themes that are freely available for
Liferay “out of the box.”
Because of this, support for Google
Analytics has been built into Liferay,
and can be turned on through a simple
user interface. is allows Liferay
administrators to make use of
Google Analytics on a community by
community basis and turn it on and
off when needed.
To enable Google Analytics support,
go to Site Seings in the control
panel, and then select Analytics
on the right. You’ll see a very simple
form, pictured below.
Put your Google Analytics ID
(which should have been provided to you when you signed up for the service)
in the field and click Save. All the pages in the community you selected will
now have the Google Analytics code in them and will be tracked.
is is a fairly simple procedure, and it gives you the ability to take advantage
of some great tools to help you visualize who’s coming to your site and
from where. Next, we discuss some topics germane to maintaining your Liferay

installation as it’s used. Let’s start with backup.

Portal Instances in Liferay

Portal Instances in Liferay

Portal Instances
Liferay Portal allows you to run more than one portal instance on a single server.
e Portal Instances page of the control panel lets you manage these instances.
Data for each portal instance are kept separate from every other portal instance.
All portal data, however, is kept in the same database.
Each portal instance requires its own domain name. Liferay will direct users
to the proper portal instance based on this domain name. So before you configure
an instance, configure its domain name in your network first. When you’re
ready to add an instance, click the Add buon here.
You’ll be prompted for four fields and a check box:
16.6. PLUGINS INSTALLATION 595
Web ID: A general convention is to use the domain name for this. It’s a
user-generated ID for the instance.
Virtual Host: Put the domain name you configured in your network here.
When users are directed to your Liferay server via this domain name, Liferay
will then be able to send them to the proper portal instance.
Mail Domain: Enter the domain name for the mail host for this instance.
Liferay will use this to send email notifications from the portal.
Max Users: Enter the maximum numbers of user accounts you would like
your portal instance to support.
Active: Use this check box to choose whether to create an active or an inactive
portal instance.
When you are finished filling out the form, click Save. Now navigate to the
portal using your new domain name. You will see you are brought to what looks
like a clean install of Liferay. is is your new portal instance which can now

be configured any way you like.

Data Migration in Liferay

Data Migration in Liferay


If you are upgrading from a previous release of Liferay Portal or if you need to
migrate your data from one system to another, the Data Migration tab helps you
to do that without your developers having to write custom scripts.scripts.
590 CHAPTER 16. USING THE CONTROL PANEL
e first section lets you copy your entire Liferay database from the current
database under which it is running to the database you specify in this set of
fields. You’ll need to enter the driver class name (and the driver will need to be
on Liferay’s classpath), the JDBC URL of the database to which you’ll be copying
your data and the credentials of a user with access to that database. Once you
have all of this information entered, click Execute to copy the data.
e next section helps you migrate your documents. If you want to move
off of the Jackrabbit JSR-170 repository to the file system, or to the Jackrabbit
repository from the file system, or to any of the other repositories supported
by the documents and media library, you can do so very easily. Make sure you
have already set up your portal-ext.properties file so the hook is properly
configured before running this migration. Select the Document Library hook
that represents where you want your documents migrated and click Execute.
Your documents will be migrated to the new repository. You can then shut down
Liferay, make the new repository the default in the portal-ext.properties

file and then restart.

Log Levels in Liferay

Log Levels in Liferay
            Log Levels tab of the Server Administration page allows you to dynamically
modify the log levels for any class hierarchy in the portal. If you have custom
code you have deployed which isn’t in the list, you can use the Add Category
tab to add it. If you change the log level near the top of the class hierarchy
(such as at com.liferay), all the classes under that hierarchy will have their
log levels changed. If you are testing something specific, it is much beer to be
as specific as you can when you change log levels. Modifying them too high in
the hierarchy generates a lot more log messages than you nee