Showing posts with label portlet. Show all posts
Showing posts with label portlet. Show all posts

Wednesday, November 26, 2014

Portlet Introduction / Portlet Technology Introduction


Portlet is small fragment of dynamic content in the web page. And this dynamic content may be text,HTML,xml or some other MIME format. Portlet technology implemented by JSR 168 and JSR 286 standards.

Generally in web application we are very familiar with servlet technology and portlet technology is similar to servlet technology but it consist its own features. servlet technology based on client and server architecture in the web world here the client is browser.

Portlets life cycle is managed by portlet containers these are in application servers. portlet life cycle consist different stages like instantiation,serving and destroying. Portlet containers are similar to servlet containers to manage entire life cycle of portlet.

Generally in the portlet technology each page consist one or more portlets and each portlet render dynamic content to make complete web page.

In technical understand portlet technology implemented in Java in the package javax.portlet.

This portlet API consist many interfaces and implementation classes to developed portlet based application in the web world.

How does portlets are differed from servlet

Generally in servlet web application each servlet will be referred by URL to invoke or access and each web page content will be served by one servlet but in portlets each page will be served by different portlet and each portlet will have its own lifecycle and own URL pattern to execute.

Servlet will generate dynamic content which send to browser and it’s in single web page but portlet will server fragment of dynamic content and portal page is responsible to aggregate content from different portlet to generate whole page.

There are many people implemented the portlet technology.

Liferay
JetSpeed
Pluto
uPortal
WebLogic
Websphere
Entando

Understanding the Portlet Technology


Basically we need to following things to run portlet based application

JRE
Portlet Container+Application Server
Portlets

Portlet Container

Portlet containers is responsible for run the portlet and it provides the required run time environment. Portlet containers manage the life cycle of portlets. When ever portal server send the request then portlet containers receive the requests and its invoke the respective portlet to process request means its instantiated the portlet and execute appropriate life cycle methods to prepare response. Portlet container send portlet response back to portal server like that portal server receive responses of different portlets and aggregate all response to complete client request.

Application Server

Application servers are responsible to process client request and send response back to client. Application server provided different services to manage and run web applications. The services like JMS, JNDI, JTS, JAAS, JDO,Connection Pooling and all these services required by the applications.

Application servers integrated with different containers to provide different run time environments like servlet containers to provides run time environment to execute servlets, portlet containers is to provides the run time environment to execute portlet, EJB containers to provided environment to execute Enterprise Java Beans applications.

Apart from this application severs have more capabilities to provide different services to run different technology based applications.

Portlets

As we already know each portlet has it own life cycle and which will be managed by portlet container. According to the JSR 168 standard portlet have three life cycle stages.

Basic portlet consist following life cycle stages

Portlet life cycle  

init:

Initialize the portlet and put the portlet into service

Handle requests:

Process different kinds of action- and render-requests

Destroy:

Put portlet out of service

Theoretically we have 3 life cycle stages in portlets and these will be implemented via portlet interface. Portlet interface is implemented in javax.portlet package by Sun Microsystems.

Every portlet that should implements the portlet interface or it should extend the class that already implemented the portlet interface.

As we know portlet have three life cycle staged and the following are interface methods which handle portlet life cycle in portlet implementation.

init(PortletConfig config):

This method is initialize the portlet and this will be called only once when portlet is instantiated, we can say when we drag and drop portlet in page.

If any necessary functionality required at initial time of portlet we will use this method and write code here. It is similar to servlet init method. This method can be used to create expensive objects/resources used by the portlet.

processAction(ActionRequest request, ActionResponse response):

When user is requested to server then portlet will execute process action method.
This method will notify the portlet that used has triggered an action this portlet. , a portlet can issue a redirect, change its portlet mode or window state, modify its persistent state, or set render parameters.

render(RenderRequest request, RenderResponse response):

Render method will generate content and that will be send to web client.
In the portal page we have many portlet we have triggered action in one portlet then all portlet will be executed render method to aggregate dynamic content. The portlet can produce markup that may depend on the portlet mode or window state, render parameters, request attributes, persistent state, session data, or backend data.

destroy ():

Indicate to the portlet the life cycle's end. This method allows the portlet to free up resources and update any persistent data that belongs to this portlet.

Note:

In the portlet life cycle for each action or request the final method is render method. Render method will be called for every time to aggregate content or produce content.

Generally portlet have different URL to call these methods like Action URL and Render URL. 
 
Action URL will execute portlet porcessAction(----) method and then it will be execute the render(----) method.

Render URL will execute the portlet render (---) method only. 

Portlet Lyfecycle Execution Process 



Portlet Characteristics

Portlet have addition Characteristics when we compare with servlet.

Portlet Widow States:

Portlet has different window states. Window state specifies how portlet will look in the page .Window state decides how much space will be accommodated in portlet page.

The following are important window states as for JSR 168 Standards.

Maximized:

When portlet state is decided as Maximized then entire page only one portlet is visible.
Generally we will use this state after perform some action then we will make widow state is Maximized.

Normal:

Specified that is portlet may share the page with other portlets. This is the default window state.

Minimized:

Portlet should only render minimal output or no output at all.

Portlet Modes:

Portlet mode specifies that the function will be performed by portlet.
Generally following are the portlet modes that each portlet should support as for JSR 168&286 standards.

View:

This view mode is when portlet is access or render then portlet is in view mode and this is default mode for portlet.

Edit:

Edit mode will be used to edit some portlet functionality and generally we wil use this mode for administrator to modify or edit something.

Help:

This will used to provide content to end user about portlet i.e how to use and access portlet like help information. 
 
Persistent storage for preferences:

Portlets provide a Portlet Preferences object for storing user preferences. These preferences are stored in a persistent data store, so they will be available across server restarts. As a developer, you don't have to worry about the actual implementation of how it is stored.

Portlet Sessions:

Like Http Session in the portlet technology also have different scopes of session to share data among the portlet or with in the portlet. Portlet also can use Http Session.

Portlet Session by default scope is portlet level what ever the data stored in Portlet Session can be available with in portlet. If we want share data among the portlets then we have to use application level scope so that data can be shares across the portlets.

Portlet technology have concept called publics render parameters to exchange data among portlets this is we can all it as Inter Portlet Communication.

We can use portlet sessions or public render parameters to establish communication among portlets which are in same page.

Portal context 

Portal context provides information such as the portal vendor, the portal version, and specific portal properties. The information allows the portlet to use specific vendor extensions when being called by a portal that supports these extensions and, when being called by other portals, to return to some simpler default behavior.

Properties 

Properties communicate vendor-specific settings between the portlet and portlet container, and between the portlet and the portal. 

These properties show up in several places in JSR 168. The portlet can read String properties with getProperty() from: 

ActionRequest, to receive properties that are action-request specific

RenderRequest, to receive properties that are render-request specific

PortalContext, to receive properties that are portal specific and do not change for different requests 

The portlet can write String properties with setProperty() to: 

ActionResponse, to set properties in response to an action request

RenderResponse, to set properties in response to a render request

Packaging and deployment

Portlet are packages as web archive file(WAR) this archive file consist of portlet deployment descriptors, resources and other java libraries which are required by portlets.

In the portlet application we have two deployment descriptors that is web.xml and portlet.xml

web.xml specifies the things related to web application deployment properties

portlet.xml specifies the portlet application related deployment properties and it always describes only one specific portlet application.

portlet application deployment is a two-step deployment that deploys the Web application into the application server and the portlets into the portal server.

Author

Wednesday, November 12, 2014

Liferay’s Development Platform Quick Notes


What is web application?

A web application or web app is any software that runs in a web browser.
It is created in a browser-supported programming language (such as the combination of JavaScript, HTML and CSS) and relies on a web browser to render the application.


Generally web application can serve static data or dynamic data to the client when it send request to the server.Web application will be available in the network such as Internet or Intranet.

What is Portal?

A portla application is web application consist of more content(files,images) and other dynamic functionality.

What is Liferay?

Liferay is portal based web application which reduce development cost and as developer can easily develop applications and they can run into liferay portal. 

What are the ways to incorporate application into Liferay?

Liferay supports two main, standards-based technologies for incorporating your applications into Liferay Portlets and Open Social gadgets.

What is hot deployment?

Hot deployment is process in web application deployment so that we need not stop server while deployment of application and the changes can be applied as soon as deployment is finished.so it makes application available with zero downtime.

What is portlet?

Portlets are small web applications written in Java that run in a portion of a web page and portal container is responsible to aggregate all portlets content and make it as web page.

What are the portlet features?

portlet are hot deployed applications.

zero down time.

Large functionality we can split it and make it as portlets.

What are the technologies can we use in portlet application?

We can use Java web based frame works to developer portlets(spring, struts, jsf, vaadin)
Liferay is also providing their own portlet development frameworks such as MVC Portlet and Alloy Portlet.

What is open social gadget?

open social gadgets are small application developed using browser based technologies such as HTML,JavaScript,Ajax. 

What are the features of open social gadgets ?

Open Social gadgets provide a standard way to develop applications for a portal environment.

Open social gadgets can use any of the back end technologies such as php,python,ruby and groovy. 

Open social gadgets are specific to develop social application.

How many types of Open social gadgets?

There are two types of Open social gadgets Remote gadgets and Local gadgets.

What is remote Gadget?

Remote gadgets run in remote server but present or use in any of portal and its developed in any of technologies but deployed in respective portal server but we can use it any where. its not advisable some intranets are not allowed to run remote apps in local portal.

What is Local Gadget?

local gadgets deployed in local server and use in portal which is already deployed in same server. 

How portlet can exposed to outside world?

Liferay lets you expose portlets to the outside world as Open Social gadgets. 

How liferay can Reuse existing web application in portals?

Redevelop an exist application into portlet applications. 

Web service based integrations like we expose web application features as web services and we will consume in liferay portlets. 

Iframe based usage. 

Using Web proxy liferay portlet 

If web application is used Struts or JSF then we can convert as portlets with minimal changes.

What are the technologies liferay supports?

Liferay support any of J2EE technologies so that we can develop portlet applications any of your choices. 

We can use Spring MVC, Struts 2, Ruby, PHP.

We can also use component based frameworks such as JSF,Vaadin and GWT.

The simpler way we can use liferay specific portlet framework such as MVC Portlet and Alloy Portlet 

What are the JavaScript libraries liferay supports?

Liferay supported JavaScript libraries such as Jquery, YUI, AUI, ExtJS and Dojo. 

What are the notable JSF component libraries?

We can use Component libraries such as ICE Faces, Rich Faces,Prime Faces with combination of JSF framework. 

What is advantage of Component based framework?

Component based framework work helps us to develop user Interface very quickly because we can find plenty of UI components that makes UI development easy as much easy. 

From Which version AUI is in Liferay ?

From version 6 liferay have come up with their own JavaScript implementation called Alloy UI which is based on YUI3. 

Most of the liferay portlets have used AUI Java script and its components to develop liferay user interface. 

What is AUI?

Alloy UI(AUI) is user interface component library consist of JavaScript,CSS and JSP tags. AUI provide many UI components for quick UI development in liferay and its built it on top of YUI3.

What is Service Builder Tool(SB)?

Liferay developed tool called Service Builder which can develop database services with simple configuration. 

Liferay’s Service Builder automates creating interfaces and classes for database persistence and service layers

What type of web services generated by Service Builder?

SB also implemented SOAP, JSON based web services to expose services to out side world.

Liferay not impose you to use specific technologies we can use any of technologies when we develop applications. 

Liferay have given many out of box features so that we can extend to customize liferay.

Which mechanism Liferay provided for extending or customize the liferay portal?

Liferay introduces mechanism called Plugins so that we can extend or customize liferay portal.we have different types of Plugins based on its contextual use.

Each plugin we can package as war file and deploy into liferay portal server so that we can see changes or add new features to the portal. 

Whats are the liferay plugins available?

Liferay have given Plugins SDK so that we can develop liferay plugins such as portlet,hook,layout,theme,ext and web.

What is Theme and its features?

Theme is liferay plugin and Themes are used to customize look and feel of liferay portal.

Themes consist of many css files, velocity,free marker template and java script files. 

Liferay 6 come up with responsive feature so that we can view lifera portla in mobile phone,tablets and desktops with consistence view. 

Most importantly, themes let you focus on designing your site’s UI, while leaving its functionality to the portlets. 

Themes are hot deployment capable plugin 

What is Layout Template and its features?

Layout Templates provide predefined page layout.we can split page as sections so that we can fill sections with portlets means arrangement of portlet in the page can decided by layout templates.

We can embded common use portlets in the layout so that it will be visible whenever we applied layout to the page. 

Like themes, layout templates are also written in Velocity and free marker templates and are hot-deployable. 

What is Hook Plugin and its features?

Hooks are used to Customizing or Extending the Out-of-Box Functionality and its 
hot-deployable. 

Hook pluigins to user to modify portla properties not all some limited properties. 

Hooks can used to modify language properties files, JSP files, Struts Actions and modify portal services using Using service wrapper.

Hooks perform custom actions on startup, shutdown, login, logout, session creation, and session destruction. 

Liferay have many kind of hooks like JSP Hook,Portal Properties Hook, Language Properties hook, Service wrapper hook, Indexer Post Processor Hook, Struts Action Hook, Custom Action hook and Servlet filter hook

What is Ext Plugin and its features?

We will use Ext Plugins for advanced customization. ext can modify or change any of portal existed behaviors we can change any part of portal using ext plugins.

Ext plugins provide the largest degree of flexibility in modifying the Liferay core, allowing you to replace essentially any class with a custom implementation.

Ext Pluins not hot deployable so we need to restart server to see changes. 

Ext Plugin was introduced from Liferay 6 version before it was a separate component along with plugins SDK. 

What is Portlet Plugin and its features?

Portlet is used to add new features to liferay portal and its look like independent application and it uses the Liferay Portla API and Services.

Portlets are hot deployable applications. 

Portlet pluigins are very flexible application and its have independent database schema and its own services to fulfill requirements. 

Each portlet plugin may have one or more portlets. 
Portlet plugin use the Service Builder tool to generate the service layer. 

What is Web Plugins?

Web plugin is separate web application and that can be deployed into liferay portal. 

What are the Liferay development Choices?

Liferay Plugin development have many choices so that developer can choose their flexible tools.
Liferay have given many ways to develop liferay plugins such as 
 
Apache Ant and the Plugins SDK
Eclipse and the Liferay IDE
Liferay Developer Studio
Maven Based Development
Other IDE tools(NetBeans, IntelliJ IDEA )

What is default Build Mechanism in Liferay?

Liferay used ANT based build to deploy plugins into portal we can also use MAVEN based build.

What is Plugins SDK?

Liferay have given Plugins SDK so that we can develop plugin applications and its consist set of libraries and plugin templates so that we can simply create plugins and deploy into liferay portal. 

What is ANT?

ANT is a build tool for build and deploy applications. Its xml based configuration to defined application build process and its includes task called compile, packaging and deploy into server.

What is Apache ANT and the Plugins SDK?

Liferay Plugins SDK have provided ANT based commands so that we can run commands for create plugins and deploy plugins into portal. 

Plugins SDK provided command based UI with help of ANT tool. 

Before Start Development we need to install ANT in our machine and need to set required environment variable such as ANT_HOME and need to set ANT path variable. 

What is Eclipse and the Liferay IDE?

Liferay have developed Liferay IDE for eclipse so that we can integrate Liferay IDE with eclipse to develop Liferay Plugin.

Liferay IDE is GUI based interface to crate plugins ant its also provide different plugin templates so that we can create basic plugin very quickly and its consist of all basic configuration and its files. 

Liferay IDE is Eclipse Plugin and we need configure Plugins SDK into Eclipse to start development. 

Liferay IDE created plugins are used ANT tool to build and deploy into portal.

Liferay IDE/Eclipse by default have ANT tool if you want use your local installed ANT we need to configure in eclipse. 

What is Liferay Developer Studio?

Liferay Have developed Developer Studio and its Enterprise Edition for plugin development.

Its also like Liferay IDE but its have many features so that we can create and deploy liferay plugins. 

What is MAVEN?

Maven is application build tool so that we can build and deploy applications into server with minimal effort. If can do many tasks like compile,packaging and deploy into server.

What is MAVEN Based Development?

Many developers prefer other command-line alternatives to Apache Ant. The most popular of these alternatives is Maven. To support developers that want to use Maven we have mavenized Liferay artifacts for referencing in your Maven projects. See the next chapter for an in-depth look at developing plugins in Maven. 

What are the other IDE tool liferay can use?

We can also use NetBeans, IntelliJ IDEA for plugins development. 

Author

Tuesday, April 8, 2014

Introduction to JSR 286/ Portlet Specification 2.0

Introduction:

JSR 286 is advanced portlet specification and it was added new features to JSR 168.
We can also call Portlet Specification 2.0. Java Community People was founf some of the limitations in JSR 168 and they are added new specifications to JSR 168 then they released as JSR 286 standards.

We already know JSR 168 standard and Portlet Specification 1.0


In JSR 168 covers the basic portlet technology need and its specification later Java Community People was added more features and specification in JSR 286.

The following are important Specification and Features
  • Inter Portlet Communication
  • Another State in Lifecycle
  • Ajax Support
  • Serving Resources
  • Portlet Filter and Listeners
  • Support Many Web Application Frame works in Portal Container
  • Improve Cache Mechanism
  • Support for WSRP 2.0

Inter Portlet Communication

The important feature in JSR 286 is Inter portlet communication. Inter portlet communication is mechanism to send or receive data between two portlets.

We can achieve IPC with different ways in portlets and we can make communication between portlet which are in same page or other pages too. We will use different ways based on our requirement.

In JSR 168 IPC works between portlets which are in same page using Portlet Session Mechanism.

In JSR 286 they made communication between portlet which are in different pages using other mechanism

The following are new IPC mechanism added in JSR 286
  1. Events
  2. Public Render Parameters

Events:

Event based mechanism way to communicate between portlet which are in same or in other page too.

Here one portlet will send the event and other portlet will listen the event. Here another method added in lifecycle so that it send or publish the events and when page render respective listener portlets receive the dada or events. Here before portlet execute render phase it can send events to other portlets


Public Render Parameters

Public render parameters are another way in IPC. We will use some public render parameters to each portlet so that it will carry the data between portlet and it will available to other portlets.
We will define some public render parameter such a way it will available to other portlet to get the data from that.

Another State in Portlet Lifecycle

New lifecycle phase added in portlet lifecycle. In JSR 168 the state of transition change from Action Phase to Direct Render Phase no more states in between that.

In JSR 286 to implement IPC they will add another Lifecycle state that is called Events Phase.
Before transition from Action Phase to Render Phase portlet can send events to other portlet in Events phase. So that another  lifecycle phase was added for portlet so that it will send some events to other portlet.



 Ajax Support

JSR 286 support Ajax mechanism to communicate with server. This is one of the good features. Generally if any portlet is have in action page other portlet need to render the portlet within the page.

With the help of Ajax we can avoid render all portlets in page. We simply send Ajax call from portlet so that we can communicate with server then get the response.

Serving Resources

In JSR 168 portlet specification will render only HTML content in render phase it can’t render some resources like pdf, images and other content type.

In JSR 286 was added another feature called serving resources with help of this we can serve the images, pdf and other content types to client.

In the portlet interface they added new method called serveResource(----)  method so that It will serve the other content types to client. This method also used specially for Ajax call in portlet, to call this method we will use different URL i.e. serve recourse URL.

Generally in the portlet transition state will always change from Action Phase to Render Phase when we perform actions.

But when we call serve Resource phase it will directly serve the content and it won’t go to render phase.

Portlet Filter and Listeners

We can portlet related filters and Listeners in portlet portlet.xml file. This will add advantage to perform some events or some actions before portlet is rendered.

Support Many Web Application Frame works in Portal Container

Generally Portal specification is different and we will use portlet container to manage portlets and its lifecycle. But we have many elegant web application frameworks.

In JSR 286 support other web frame works to run in portlet container so that developer can develop portlet in any web application frame work and run in the portlet container with help of small changes. It will support JSF, Struts, Spring, Vaadin and other MVC bases frameworks.

Support for WSRP 2.0

The Web Services for Remote Portlets specification defines a web service interface for accessing and interacting with interactive presentation-oriented web services.

This will help us access portlet from remote location other portals. We need to deploy portlet in portal we simply use this protocol we can access other portlet which are in other portlet container.


Author

Recent Posts

Recent Posts Widget

Popular Posts