Portlet Fundamentals and Development

Author

Reads 6.8K

Three business professionals discussing over a laptop in a modern office setting.
Credit: pexels.com, Three business professionals discussing over a laptop in a modern office setting.

Portlets are reusable UI components that can be deployed in a portal environment. They provide a way to encapsulate a specific functionality or service.

Portlets can be categorized into two main types: JSR 168 portlets and JSR 286 portlets. JSR 168 portlets are the older version and are still widely used.

A portlet can have multiple windows, known as portlet windows, to display different content or functionality. This allows for a more flexible and dynamic user experience.

Portlets are typically developed using Java and JavaServer Faces (JSF) technology. This allows for a high degree of customization and integration with other portal components.

Additional reading: WebSphere Portal

What is Portlet

A portlet is a pluggable user interface software component that's managed and displayed in a web portal. It can be an enterprise portal or a web CMS.

Portlets can aggregate and personalize content from different sources within a web page. This means they can bring together various types of information into a single page.

A different take: Web Portals Development

Credit: youtube.com, Portlet Meaning

A portlet responds to requests from a web client and generates dynamic content. This is done by producing fragments of markup, such as HTML, XHTML, or WML.

Portlets can resemble a web-based application that's hosted in a portal. Examples of portlet applications include e-mail, weather reports, discussion forums, and news.

The javax.portlet package defines the API for Java Portlet Specification V2.0. It's a Java technology-based web component that processes requests and generates dynamic content.

Portlets provide a presentation layer to Information Systems. They generate fragments of markup, which are then combined into a portal page.

Portlets are bundled in Portlet Applications as web applications using the WAR file format.

For more insights, see: Enterprise Portal

Portlet Containers

A portlet container is responsible for managing the life cycle of portlets, providing them with the required runtime environment, and managing their persistent storage mechanisms for preferences.

Portlet containers receive requests from the portal to execute requests on the portlets they host.

A portlet container sends data to the portal for aggregation, but it's not responsible for aggregating the content produced by the portlets.

The portal itself handles aggregation, taking the data sent by the portlet container and combining it with other content.

Portlet Standards

Credit: youtube.com, what is portlet in java #Portlet #Java

Portlet standards are platform-independent application programming interfaces that enable software developers to create portlets that can be plugged into any portal supporting the standards.

These standards are defined by the Java Community Process (JCP) through Java Specification Requests (JSRs), which aim to define proposed specifications and technologies for the Java platform.

The Portlet Specifications, specifically JSR-168 and JSR-286, define portlets that can be used by any compliant portlet container, and GateIn 3.2 includes a container that supports both versions.

Standards

Standards are crucial for portlets to operate seamlessly across different portals. Portlet standards are platform-independent application programming interfaces that enable developers to create portlets that can be plugged into any portal supporting the standards.

The Java Portlet Specification is an example of a portlet standard. This specification allows developers to create portlets that can be used in any portal supporting the standard.

Most Java EE portals, including GateIn 3.2, include a compliant portlet container. GateIn 3.2, in particular, includes a container that supports both JSR-168 and JSR-286 portlet containers.

GateIn 3.2 is fully JSR-286 compliant, which means any JSR-168 or JSR-286 portlet can operate within the portal as mandated by the respective specifications.

Global Metadata Elements

Credit: youtube.com, A Portlet-API-based Approach for Application Integration

In the world of portlets, metadata is crucial for proper functioning. The global portlet.xml file is where global metadata is declared, conforming to Portlet 2.0's XSD.

The global portlet.xml file is where you'll find specific elements that are supported, including Portlet Filter, Portlet Mode, and Window State. These elements are defined in the Portlet Specification with some restrictions.

Let's take a closer look at the supported elements:

  1. Portlet Filter: This is where you declare filters that extend the behaviors of portlet objects, such as transforming content in portlet requests and responses.
  2. Portlet Mode: This element allows you to declare custom Portlet Modes in the global portlet.xml file.
  3. Window State: This element also allows you to declare custom Window States in the global portlet.xml file.

These elements are essential for setting up portlet filters and declaring custom Portlet Modes and Window States. By understanding these elements, you'll be better equipped to manage your portlet applications.

Portlet Development

Portlet development can be done in Oracle JDeveloper, allowing you to create portlet producers.

You can develop your portlet producers in Oracle JDeveloper, which provides a comprehensive platform for creating and deploying portlets. This includes tools for creating portlet producer applications, as well as features for portlet modes, interportlet communication, and portlet performance.

Some key aspects of portlet development include portlet personalization and customization, multilanguage portlets, and portlet deployment.

About Development

Credit: youtube.com, Portlet development

You can develop your portlet producers in Oracle JDeveloper, which provides a comprehensive environment for creating, testing, and deploying portlet applications.

To create a portlet producer application, you'll need to follow the guidelines outlined in the Java Portlet Specification V2.0, which defines the API for portlet development.

Portlets can operate in different modes, including About mode, where they provide information to users. The guidelines for exposing content in About mode are specific and should be carefully followed.

Interportlet communication enables portlets to share data and react to events, making it easier to create interactive and dynamic portlet applications. This can be achieved through public render parameters and events, which can be used to share data and trigger actions between portlets.

Portlet personalization and customization are also essential aspects of portlet development, allowing users to tailor the content and behavior of portlets to their specific needs. This can be achieved through various mechanisms, including user preferences and context-dependent rendering.

Credit: youtube.com, Introduction to Portlet Development: Programming to JSR 168

Here's a quick rundown of the key concepts and tools you'll need to get started with portlet development:

By following these guidelines and using the right tools and frameworks, you can create engaging and interactive portlet applications that meet the needs of your users.

JavaServer Pages Example

To create a JavaServer Pages portlet example, you can follow the steps outlined in the JSPHelloUser directory.

The example can be found in the JSPHelloUser directory, which includes a JSP page to render the markup.

Using the portlet tag library, you can generate links to the portlet in different ways.

The example demonstrates the use of the other standard portlet modes.

To execute the example, run the command mvn package in the JSPHelloUser directory.

Copy the generated WAR file, JSPHelloUser-0.0.1.war, to the deploy directory of JBoss Application Server.

Select the new JSPHelloUser tab in your portal to view the results.

Here's a brief overview of the example's features:

  • Adding more features to the previous example
  • Using a JSP page to render the markup
  • Using the portlet tag library to generate links
  • Using the other standard portlet modes

Modes

Modes play a crucial role in portlet development. A portlet can have different view modes, with three modes defined by the JSR-286 specification.

Credit: youtube.com, Portlet 2.0 Modes "Edit & Help"

One of these modes is the "edit" mode, which allows a user to customize the behavior of the portlet. This mode is defined by the JSR-286 specification and is an essential part of portlet development.

A portlet can also be in a state of minimal information display, which is known as the "minimized" state. This state is defined by the JSR-168 specification and is one of the three states that a portlet can consume on any given page.

Portlets can be quite flexible, and their modes can be tailored to suit different user needs.

Portlet Technologies

JSF portlets are a great way to expose existing JSF applications and task flows as Java portlets.

The Oracle JSF Portlet Bridge is used to create JSF portlets, and it simplifies the integration with WSRP portlet consumers like WebCenter Portal.

JSF portlets don't require separate source code, so you only need to maintain one source for both your application and your portlets.

Credit: youtube.com, Introduction to portlets and portals

Using the Oracle JSF Portlet Bridge eliminates the need to store, maintain, and deploy portlets separately from your application.

Application developers with knowledge of Faces can create JSF portlets.

JSF portlets are best suited for displaying content from a JSF application or individual task flows within the application as a portlet.

Portlet Deployment

Portlet Deployment is a crucial step in making your portlet available to a consumer application. To deploy a portlet, you must first package it into a WAR file, which can be done using a JAR file utility like WebSphere Application Server.

The WAR file must include certain descriptors, such as the portlet.xml file, which defines the portlet name, class name, and supported markup types. For example, the SimplestHelloWorld portlet in GateIn 3.2 has a portlet.xml file that declares the portlet name, class name, and supported markup type as text/html.

To deploy the portlet, you must copy the WAR file into the deploy directory of your application server, such as JBoss or Tomcat, and then start the server. Once the server is running, you can create a new portal page and add the portlet to it.

Credit: youtube.com, portlet deployment

Here are the typical directory structures for a portlet WAR file:

Remember to set the gatein.portlet.config property in the configuration.properties file to point to the global portlet.xml file, which is typically located in the conf directory of your application server.

Deployment

Deployment is a crucial step in making your portlet available to users. You must package your portlet in a WAR file and deploy it to a WSRP container.

To deploy a portlet, you need to create a WAR file by packaging your portlet's class files and resources in a specific directory structure. The portlet information directory is not part of the public document tree of the application, and files in /WEB-INF are not served directly to a client.

You can use a JAR file utility to build a WAR file. For example, you can use the following command to create a WAR file with the name HelloWorld.war and include all files in the /WEB-INF and /images directories: jar -cf HelloWorld.war images WEB-INF.

Credit: youtube.com, Deploying and Managing Portlets in WebSphere Portal

A typical portlet WAR file can include servlets, resource bundles, images, HTML, JavaServer Pages (JSP), and other static or dynamic files. The directory structure of the WAR file must adhere to the JSR-286 Portlet Specification, which includes descriptors such as the portlet.xml file.

Here's an example of the SimplestHelloWorldPortlet/WEB-INF/portlet.xml file, which defines the portlet name, its Fully Qualified Name (FQN), and the markup types it supports:

Once you've packaged your portlet in a WAR file, you can deploy it to a WSRP container, which is a remote producer that communicates with the consumer application through Web Services for Remote Portlets (WSRP). WebCenter Portal supports WSRP versions 1.0 and 2.0, which enable interoperability between different portlet containers and consumer applications.

Location

When working with portlet deployment, it's essential to know the location of the global portlet.xml file. This file is crucial for configuring portlet settings, and its path varies depending on the hosting application server.

The path to the global portlet.xml file is determined by the value of gatein.portlet.config in the configuration.properties file. For Tomcat, the file is located at TOMCAT_HOME/gatein/conf/portlet.xml.

JBoss users will find the file at JBOSS_HOME/server/default/conf/gatein/portlet.xml.

Portlet Performance

Credit: youtube.com, NetSuite Dashboard Portlets

Portlet Performance is a crucial aspect of any portlet-based application. Portlets can be optimized for performance by minimizing the amount of data being transferred between the portlet and the server, as mentioned in the "Portlet Architecture" section.

This can be achieved by implementing caching mechanisms, which can reduce the number of requests made to the server. By doing so, portlet performance can be significantly improved.

Portlets can also be designed to be stateless, which means they don't store any data locally and instead rely on the server to manage the state. This approach is discussed in the "Portlet Life Cycle" section.

A well-designed portlet can handle a large number of requests without any noticeable performance degradation. In fact, some portlets can handle hundreds of requests per second.

Portlet performance can also be affected by the type of content being rendered. For example, portlets that render complex graphics or videos may require more processing power and memory than those that render simple text or images, as mentioned in the "Portlet Rendering" section.

To ensure optimal portlet performance, it's essential to monitor and analyze the performance metrics regularly. This can help identify any bottlenecks or areas for improvement.

Portlet Customization

Credit: youtube.com, Create custom netsuite portlet in 1 minute #netsuite

Portlet customization allows users to personalize or customize portlets at runtime. Personalizations are visible only to the user that performs them, while customizations are visible to all users who have not personalized the portlet.

Portlet preferences greatly enhance the reusability of portlets. The same portlet can be instantiated on multiple pages, or multiple times on the same page, with each instance behaving differently.

You can create additional portlet preferences, either during portlet creation or by editing the portlet.xml file after portlet creation, to enable users to perform other modifications on the portlet at runtime. Portlet preferences are stored in the persistence store, along with information about the registration and portlet instances.

For testing purposes, a file-based or consumer persistence store may be used, but for production configurations, it is recommended to use a consumer persistence store.

About Custom Java

Custom Java portlets are a powerful way to create personalized and dynamic content in your portal, and they're surprisingly easy to use.

Credit: youtube.com, Part I: Portlet Edit Mode and the NumberGuesserPortlet

You can write custom Java portlets from scratch using the Java Portlet Specification 2.0 (JSR 286), or use a declarative wizard in JDeveloper to simplify the process.

The wizard assists in creating the framework for your portlet, but you'll still need to write the portlet logic yourself, which is best suited for experienced Java developers.

You can also consume legacy portlets from Oracle WebLogic Portal or Oracle PDK-Java, without needing to convert them to JSR 286 first.

Custom Java portlets are a good choice when you can't find a prebuilt portlet or existing JSF application to meet your needs, or when you have very specialized business rules or logic.

They're also a good option if you require personalized authentication, granular processing of dynamic results, or complete user interface control.

For more information on creating custom Java portlets, check out the resources provided in the article.

Personalization and Customization

Personalization and customization are key features of portlet development. Personalizations are visible only to the user who makes them, while customizations are visible to all users who haven't personalized the portlet.

Credit: youtube.com, NetSuite Customizing Dashboard Portlets

Portlet preferences enable end users to personalize or customize portlets at runtime. This greatly enhances the reusability of portlets, as the same portlet can be instantiated on multiple pages or multiple times on the same page.

Each instance of the portlet can behave differently, yet still use the same code and user interface. For example, by default, a portlet preference is created to enable users to change the title of the portlet at runtime.

Portlet preferences can be stored in one of three types of persistence stores: consumer, database, or file. A consumer persistence store ties the producer metadata to the consumer application, and it's recommended for production environments.

A file-based or consumer persistence store may be used for testing, as it removes the dependency on a database. By default, JSR 286 and JSF portlets use a consumer persistence store.

Here are the three types of persistence stores:

  • Consumer—Ties the producer metadata to the consumer application.
  • Database—Persists data using a relational database.
  • File—Persists data using the file system.

It's worth noting that a consumer persistence store is recommended for production configurations.

Portlet Tutorials

Credit: youtube.com, 168 Tutorial-Handling the PortletRequest PortletResponse Cyc

Portlet Tutorials are a must for developers who want to create engaging and interactive web applications. They are targeted toward portlet developers.

Reading the JSR-286 Portlet Specification is also highly recommended to ensure a thorough understanding of the subject. It's a good idea to read and understand this specification before diving into the tutorials.

The tutorials in this chapter are designed to help developers create effective portlets. They provide a step-by-step guide to building portlets that are user-friendly and efficient.

Developers should expect to learn about the best practices and techniques for creating portlets that meet the requirements of the JSR-286 Portlet Specification.

Portlet Primer

So, you're new to portlets and want to know the basics? Well, let's start with the Portlet Primer. It's designed to provide information to the user on how to use the portlet.

The Portlet Primer is a crucial part of the portlet's functionality, as it helps users understand what they can expect from the portlet and how to interact with it.

To use a portlet effectively, you need to know how to navigate its interface, which is where the Portlet Primer comes in.

Portlet Producer Applications

Credit: youtube.com, Portlet

A portlet producer application is an application specifically configured for building and deploying Java portlets. It's a specialized tool that helps you create and manage portlets.

To create a portlet producer application, you need to ensure that the appropriate technology scopes are set, tag libraries are added, and required Java classes are added to the class path. This will make relevant components appear in the Component Palette and context menus become available in JDeveloper.

The WebCenter Portlet Producer Application template is a great way to start creating an application with a single project scoped for the creation of Java portlets. This template ensures that scopes are set properly and the right tag and Java libraries are added.

To create an application using the WebCenter Portlet Producer Application template, follow these steps:

  1. Access the New Gallery dialog in any of the following ways:
  2. In the New Gallery dialog, select WebCenter Portlet Producer Application, and then click OK.
  3. In the Name your application page of the Create WebCenter Portlet Producer Application wizard, in the Application Name field, enter a name for the application.
  4. In the Directory field, accept the default path or enter a path to the directory where the application should be stored.
  5. If required, in the Application Package Prefix field, enter a prefix to use for packages to be created within the application.
  6. Click Finish to create the portlet producer application with default project configurations.

The options exposed in the Oracle JDeveloper user interface are limited to those appropriate for developing portlets. This means you'll only see the features and tools you need to create and manage portlets.

Portlet Global Settings

Credit: youtube.com, SAP SuccessFactors Employee Central - Custom Portlet configuration #sapsucessfactors

Portlet Global Settings allow you to define settings that apply to all portlets in your application, making it easier to manage and maintain your portlets.

The Portlet Specification introduces PortletFilter as a standard approach to extend the behaviors of portlet objects, enabling you to transform the content of portlet requests and responses.

To set up a portlet filter, you need to follow three steps: implement a PortletFilter object, define the filter in the portlet application deployment descriptor, and define the filter mapping in portlet definitions.

This process can be tedious and error-prone, especially when you have many portlet definitions. The global portlet feature is designed to overcome this limitation.

Here's a summary of the steps to set up a global portlet filter:

By using the global portlet feature, you can simplify the process of setting up portlet filters and reduce the risk of errors.

Frequently Asked Questions

Are portlets still used?

Portlets are not as widely used as they once were, but portal software still exists for specialized servers. Their usage has declined with the shift away from traditional portal technology.

Katrina Sanford

Writer

Katrina Sanford is a seasoned writer with a knack for crafting compelling content on a wide range of topics. Her expertise spans the realm of important issues, where she delves into thought-provoking subjects that resonate with readers. Her ability to distill complex concepts into engaging narratives has earned her a reputation as a versatile and reliable writer.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.