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:


WHAT IS PORTLET ?

Similar to servlets, portlets are web components that are deployed inside of a container and generate dynamic content. On the technical side, a portlet is a class that implements the javax.portlet.Portlet interface and is packaged and deployed as a .war file inside of a portlet container.
Portlets are similar to servlets, in that:
  1. Portlets are managed by a specialized container.
  2. Portlets generate dynamic content.
  3. A portlet's life cycle is managed by the container.
  4. Portlets interact with web client via a request/response paradigm.
Portlets are different from servlets, in that:
  1. Portlets only generate markup fragments, not complete documents.
  2. Portlets are not directly URL addressable. You can’t send somebody URL of a portlet. You can send him the URL of the page containing a portlet.
  3. Portlets cannot generate arbitrary content, since the content generated by a portlet is going to be part of portal page. If a portal server is asking for html/text, then all portlets should generate text/html content. On the other hand, if the portal server is asking for WML, then each portlet should generate WML content.
Portlet interface:
The Portlet interface is used by the portlet container to invoke the portlets. Every portlet has to implement this interface, either by directly implementing it, or by using an existing class implementing the Portlet interface.
A portlet is a Java technology-based web component. It is managed by the portlet container and processes requests and generates dynamic content as response. Portlets are used by portals as pluggable user interface components.
The content generated by a portlet is called a fragment. A fragment is a piece of markup (e.g. HTML, XHTML, WML) adhering to certain rules and can be aggregated with other fragments into a complete document. The content of a portlet is normally aggregated with the content of other portlets into the portal page.
The portlet container instantiates portlets manages their lifecycle and invoking them to process requests. The lifecycle consists of:
  • initializing the portlet using using the init method
  • request processsing
  • taking the portlet out of service using the destroy method
Request processing is divided into two types:
  • action requests handled through the processAction method, to perform actions targeted to the portlet
render requests handled through the render method, to perform the render operation

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 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
1.      Throws a PortletException
2.      Does not return within a time period defined by the portlet container

public void processAction(ActionRequest request,ActionResponse response)             throws PortletException,java.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.
Typically, in response to an action request, a portlet updates state based on the information sent in the action request parameters. In an action the portlet may:
·         issue a redirect
·         change its window state
·         change its portlet mode
·         modify its persistent state
·         set render parameters
A client request triggered by an action URL translates into one action request and many render requests, one per portlet in the portal page. The action processing must be finished before the render requests can be issued.

public void render (RenderRequest request,   RenderResponse response)throws PortletException,java.io.IOException
Called by the portlet container to allow the portlet to generate the content of the response based on its current state.

public  void destroy():
Called by the portlet container to indicate to a portlet that the portlet is being taken out of service. Before the portlet container calls the destroy method, it should allow any threads that are currently processing requests within the portlet object to complete execution. To avoid waiting forever, the portlet container can optionally wait for a predefined time before destroying the portlet object.
This method enables the portlet to do the following:
·         clean up any resources that it holds (for example, memory, file handles, threads)

What is portal ?

What is portal?

A portal is generally defined as a software platform for building websites and web applications.
The main task of a portal is to aggregate different applications into one page with a common look and feel for the portal user.

Initially the term portal is used in a well known internet search sites and navigation websites. Portal is the starting point to access all the information on the World Wide Web. The original portals are search engines. The example for portal are Yahoo!, Excite, Infoseek, AOL, MSN, Netscape Netcenter and Lycos, represented the next phase of portal development. simply single source for all information on a specific domain.

Compared to the original Internet search engines, Internet portals offer a more structured, navigable interface. Browsing an organized hierarchy of categories developed by people who scoured the Internet for relevant and useful Websites is more effective than issuing a keyword search against the entire Web.

Portals are often the first page the web browser loads when users get connected to the Web or that users tend to visit as an anchor site. They offer users a surplus value of service based on the features of classic search engines:

What a portal does:

·         Universal login.
·         Handles both structure and unstructured data.
·         Gives messages and notifications.
·         Integration to other systems.
·         Gives multi-channel support
·         Content can be tuned based on personalization, location, browser, etc.
Features of portals:

·         Security.
·         Publishing content.
·         Transactions.
·         Search.
·         Access different data.
·         Personal content.
Major Functions of Portals:

·         Search and navigation.
·         Information integration.
·         Personalization.
·         Notification.
·         Collaboration and groupware.
·         Integration of application and business intelligence.
·         Task management and work flow.
·         Infrastructure functionality.
Types of portals:
The portals can be differentiated on the basis of their content and intended users. They can be categorized into:
·         Vertical portals.
·         Horizontal portals.
·         Enterprise portals.
·         Knowledge Portals.
·         Corporate Portals.
·         Market space Portals.