Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

Oracle WebCenter 11g: Portlets

Save for later
  • 6 min read
  • 21 Sep 2010

article-image

(For more resources on Oracle, see here.)

Portlets, JSR-168 specification

Specification JSR-168, which defines the Java technologies, gives us a precise definition of Java portlets:

Portlets are web components—like Servlets—specifically designed to be aggregated in the context of a composite page. Usually, many Portlets are invoked to in the single request of a Portal page. Each Portlet produces a fragment of markup that is combined with the markup of other Portlets, all within the Portal page markup.

You can see more detail of this specification on the following page: http://jcp.org/en/jsr/detail?id=168

While the definition makes a comparison with servlets, it is important to note that the portlets cannot be accessed directly through a URL; instead, it is necessary to use a page-like container of portlets.

Consequently, we might consider portlets as tiny web applications that return dynamic content (HTML, WML) into a region of a Portal page.

Graphically, we could view a page with portlets as follows:

oracle-webcenter-11g-portlets-img-0

Additionally, we must emphasize that the portlets are not isolated from the rest of the components in the pages, but can also share information and respond to events that occur in other components or portlets.

oracle-webcenter-11g-portlets-img-1

WSRP specification

The WSRP specification allows exposing portlets as Web services. For this purpose, clients access portlets through an interface (*. wsdl) and get graphic content associated. Optionally, the portlet might be able to interact directly with the user through events ocurring on them.

This way of invoking offers the following advantages:

  • The portals that share a portlet centralize their support in a single point.
  • The portlet integration with the portal is simple and requires no programming.
  • The use of portlets, hosted on different sites, helps to reduce the load on servers.

WebCenter portlets

Portlets can be built in different ways, and the applications developed with Oracle WebCenter can consume any of these types of portlets.

  • JSF Portlets: This type of portlet is based on a JSF application, which is used to create a portlet using a JSF Portlet Bridge.
  • Web Clipping: Using this tool, we can build portlets declaratively using only a browser. These portlets show content from other sites.
  • OmniPortlet: These portlets can retrieve information from different types of data sources (XML, CSV, database, and so on) to expose different ways of presenting things, such as tables, forms, charts, and so on.
  • Content Presenter: This allows you to drop content from UCM on the page and display this content in any way you like or using a template.
  • Ensemble: This is a way to "mashup" or produce portlets or "pagelets" of information that can be displayed on the page.
  • Programmatic Portlets: Obviously, in addition to the previous technologies that facilitate the construction of portlets, it is also possible to build in a programmatic way. When we build in this way, we reach a high degree of personalization and control. However, we need specialized Java knowledge in order to program in this way.

As we can see, there are several ways in which we can build a portlet; however, in order to use the rich components that the ADF Faces framework offers, we will focus on JSF Portlets.

Developing a portlet using ADF

The portlet that we will build will have a chart, which shows the status of the company's requests. To do this, we must create a model layer that represents our business logic and exposes this information in a page. Therefore, we are going to do the following steps:

  1. Create an ADF application.
  2. Develop business components.
  3. Create a chart page.
  4. Generate a portlet using the page.
  5. Deploy the portlet.

In this example, we use a page for the construction of a portlet; however, ADF also offers the ability to create portlets based on a flow of pages through the use of ADF TaskFlows. You can find more information on the following link: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/taskflows.htm#BABDJEDD

Creating an ADF application

To create the application, do the following steps:

  1. Go to JDeveloper.
  2. In the menu, choose the option File | New to start the wizard for creating applications. In the window displayed, choose the Application category and choose the Fusion Web Application ADF option and press the OK button.

    oracle-webcenter-11g-portlets-img-2

    Unlock access to the largest independent learning library in Tech for FREE!
    Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
    Renews at $15.99/month. Cancel anytime
  3. Next, enter the following properties for creating the application:
    • Name: ParacasPortlet
    • Directory: c:ParacasPortlet
    • Application Package Prefix : com.paracasportlet

    oracle-webcenter-11g-portlets-img-3

  4. Click Finish to create the application.

Developing business components

Before starting this activity, make sure you have created a connection to the database.

  1. In the project Palette, right-click on Project Model, and choose New.

    oracle-webcenter-11g-portlets-img-4

  2. On the next page, select the category Business Tier | ADF Business Components and choose Business Components from Tables. Next, press the OK button.

    oracle-webcenter-11g-portlets-img-5

  3. In the following page, you configure the connection to the database. At this point, select the connection db_paracas and press the OK button.
  4. In order to build a page with a chart, we need to create a read-only view. For this reason, don't change anything, just press the Next button.

    oracle-webcenter-11g-portlets-img-6

    (Move the mouse over the image to enlarge.)

  5. In this next step, we can create updateable views. But, we don't need this type of component. So, don't change anything. Click the Next button.

    oracle-webcenter-11g-portlets-img-7

  6. Now, we need to allow the creation of read-only views. We will use this kind of component in our page; therefore select the table REQUEST, as shown next and press Next.

    oracle-webcenter-11g-portlets-img-8

  7. Our next step will allow the creation of an application module. This component is necessary to display the read-only view in the whole application. Keep this screen with the suggested values and click the Finish button.

    oracle-webcenter-11g-portlets-img-9

  8. Check the Application Navigator. You must have your components arranged in the same way as shown in the following screenshot:

    oracle-webcenter-11g-portlets-img-10

  9. Our query must determine the number of requests for status. Therefore, it will be necessary to make some changes in the created component. To start, double-click on the view RequestView, select the Query category, and click on the Edit SQL Query option as shown in the following screenshot:

    oracle-webcenter-11g-portlets-img-11

  10. In the window shown, modify the SQL as shown next and click the OK button.

    oracle-webcenter-11g-portlets-img-12

    SELECT Request.STATUS,
    COUNT(*) COUNT_STATUS
    FROM REQUEST Request
    GROUP BY Request.STATUS

  11. We only use the attributes Status and CountStatus. For this reason, choose the Attributes category, select the attributes that are not used, and press Delete selected attribute(s) as shown in the following screenshot:

    oracle-webcenter-11g-portlets-img-13

  12. Save all changes and verify that the view is similar to that shown next:

    oracle-webcenter-11g-portlets-img-14