| ||||||||||||||||||||||||||||||||||
|
Find this tutorial in: /usr/local/resin/webapps/resin-doc/portlet/tutorial/basic-hello
Try the Tutorial The Hello, World tutorial shows the most basic portlet and its configuration in a simple browser page.
Portlets form a design pattern where a Portal servlet combines one or more component Portlets into a web page. Because the portlets are written as components, they can be cleanly written and tested. Applications which currently use many servlet includes might be more cleanly written as portlet applications. The Portal part of the pattern is a servlet which manages the portlets. In this example, the servlet is a simple "invoker" which calls a single portlet to render the page. Many applications will write their own Portal servlets, using Resin's generic portal library to handle the Portlet API. The "Hello, world" portlet requires the following configuration:
A Portlet is a class that implements class javax.portlet.Portlet . It is similar to a servlet. The HelloWorldPortlet in this tutorial sends a Hello, World message to the browser. The response to the browser is generated by the render() method.
class com.caucho.portal.generic.PortletServlet is a servlet that dispatches to a portlet. In this way, portlets can be used as drop-in replacements for servlets.
Portlets work without modification in all portal products. The PortletServlet is a simple way to get a portlet going, and provides a convenient way to replace servlets with portlets. This approach is valuable for developers that wish to take advantage of the well defined pattern that portlets provide, without necessarily needing the more complete set of features such as sophisticated rendering and management of multiple portlets per page that a more complete portal provides.
The tutorial takes advantage of Resin's dependency injection features. The PortletServlet also supports the use of init-param's if dependency injection is not available.
|