Feeds

Creating a Portlet from a JSF Application with WebCenter

Pass the portlet, dear

The Power of One Brief: Top reasons to choose HP BladeSystem

A portal is a web application that aggregates a collection of web applications (portlets) running on a page in separate windows. A portlet is a web component (application) that runs in a portlet container, processes requests and generates dynamic content.

Portlets are the pluggable user interface components in a portal page. Portlets facilitate the development of SOA (Service Oriented Architecture) based applications. The different portlets in a portal page may obtain data from different data sources. Java Portlet Specification (JPS), based on Java Specification Request (JSR 168), and Web Services for Remote Portlets (WSRP) are standards for developing and consuming portlets.

Oracle WebCenter Suite is the newest component of the Oracle Fusion Middleware. Oracle WebCenter Suite, based on SOA, provides a unified environment in which a user may access different enterprise applications and services. JDeveloper 10.1.3.2 includes a WebCenter Framework pre-configured OC4J using the WebCenter extension for JDeveloper. The WebCenter pre-configured OC4J provides a JSR 168 portlet container for developing WSRP 1.0/WSRP 2.0 standards based portlets. Portlet applications may be developed in JDeveloper and deployed to the WebCenter Framework. Subsequently, the portlet may be consumed in a WebCenter application by registering a WSRP producer with the application. In this article we shall develop an example JSF portlet based on the JSR 168 and WSRP 2.0 standards and run the portlet in the WebCenter Framework.

Setting the Environment

Install JDeveloper 10.1.3.2 Studio Edition. We shall create a JSF DataTable based portlet. We shall use the Oracle database as the datasource for the JSF portlet. Install Oracle 10g database including the Oracle database instance ORCL and the sample schemas. Create an example database table CATALOG in the OE schema from SQL *Plus with SQL script catalog.sql, in the Resources zip file.

Creating a JSF Portlet

The example JSF application that is to be portelized consists of a DataTable that is generated dynamically using an SQL query. First, create a JDeveloper application with WebCenter Application as the application template. The WebCenter application consists of the Portlets project for creating portlets and the ViewController project for creating JSF view pages in which portlets may be embedded. Add the library for the JSF-Portlet Bridge to the Portlets project.

Adding Portlet Libraries.

Next, create a JSF application to be portelized and deployed in the WebCenter Framework enabled OC4J with File>New>Web Tier>JSF. Select Automatically Expose UI Components in a new Managed Bean, specify a class name (PortletBean). Add portlet.xml to the Portlets project with File>New>General>Deployment Descriptors>portlet.xml. In the Component Palette select JSF HTML and add a Output Label, an Input Text, a Command Button and a Data Table to the JSF page input.jsp.

Adding JSF Components.

The JSF portlets application files are available in the in the Resources zip file. Next, configure a JDBC connection with the Oracle database. Select the Connections view, right-click on the Database node and select New Database Connection. Next, create a deployment profile, webapp1, for the JSF portlet application with a J2EE Web Context Root of portletsApp.

Deploying the JSF Portlet

Next, deploy the JSF portlet to the OC4J that is pre-configured with the WebCenter Framework. Start the WebCenter Preconfigured OC4J with Tools>Start WebCenter Preconfigured OC4J. Configure a connection with the WebCenter Preconfigured OC4J. In the Create Application Server Connection Wizard specify connection name (LocalOC4J), connection type as Standalone OC4J 10g 10.1.3, username as oc4jadmin, password as welcome, host name as localhost, and RMI Port as 22667. Next, deploy the WAR deployment profile that was created from the JSP portlet application to the WebCenter Preconfigured OC4J. Right-click on webapp1.deploy and select Deploy to>LocalOC4J. The WSDLs for the WSRP application get created.

Registering a Portlet as a WSRP Producer

WSRP defines a set of interfaces that standardize interactions with portlet components that generate markup to be consumed in a user application. Before consuming a portlet in a WebCenter application page, a WSRP Producer for the portlet is required to be registered with the application. The WebCenter Framework provides a WSRP Producer Registration wizard to register a WSRP 1.0/WSRP 2.0 Producer for a portlet with an application. A WSDL is required to register WSRP Producer with an application. The WSDL URLs may be obtained from URL http://localhost:6688/portletsApp/info, port 6688 being the HTTP port.

WSRP Producer Test Page.

Next, register a WSRP Producer for the JSF portlet with the WebCenter application. Select the ViewController project and select File>New. In the New Gallery wizard select Web Tier>Portlets. Select WSRP Producer Registration and click on OK. In the WSRP Portlet Producer Registration Wizard specify a name for the WSRP Producer and click on Next. Obtain the WSDL URL for the JSF portlet application from the WSRP Producer Test Page and specify the URL in the URL Endpoint field.

Specifying Portlet URL

Specify the default execution timeout fro the producer and click on Finish. The WSRP Portlet Producer gets registered with the WebCenter application.

Portlet Application Directory Structure.

Adding a Portlet to a JSF Page

Portlets registered with a WebCenter application using a WSRP Portlet Producer become available in the Component palette just like any other JSF component. In this section the JSF portlet is added to a JSF page. Add a .jspx JSF page to the ViewController project. In the Tag Libraries window select the ADF Portlet Components library, which is required to add portlets to a JSF page. Next, add the JSF portlet that was generated earlier to the JSF page. Position the cursor in the PortletsPage.jspx page and select WsrpPortletProducer1 in the Component Palette and select the DataTable Portlet. The DataTable Portlet gets added to the JSF page just like any other JSF component would. Run the WebCenter application JSF page.

Running a WebCenter Application JSF Page.

The JSF DataTable portlet gets displayed. Specify a SQL query statement in the SQL input field and click on the Create Data Table button – see Figure 7.

Specifying an SQL Query.

Finally, a Data Table gets displayed; with the Oracle database as the datasource for the Data Table – see Figure 8.®

DataTable Portlet.

Securing Web Applications Made Simple and Scalable

More from The Register

next story
Apple fanbois SCREAM as update BRICKS their Macbook Airs
Ragegasm spills over as firmware upgrade kills machines
HIDDEN packet sniffer spy tech in MILLIONS of iPhones, iPads – expert
Don't panic though – Apple's backdoor is not wide open to all, guru tells us
Mozilla fixes CRITICAL security holes in Firefox, urges v31 upgrade
Misc memory hazards 'could be exploited' - and guess what, one's a Javascript vuln
NO MORE ALL CAPS and other pleasures of Visual Studio 14
Unpicking a packed preview that breaks down ASP.NET
Captain Kirk sets phaser to SLAUGHTER after trying new Facebook app
William Shatner less-than-impressed by Zuck's celebrity-only app
Cheer up, Nokia fans. It can start making mobes again in 18 months
The real winner of the Nokia sale is *drumroll* ... Nokia
EU dons gloves, pokes Google's deals with Android mobe makers
El Reg cops a squint at investigatory letters
Chrome browser has been DRAINING PC batteries for YEARS
Google is only now fixing ancient, energy-sapping bug
prev story

Whitepapers

Designing a Defense for Mobile Applications
Learn about the various considerations for defending mobile applications - from the application architecture itself to the myriad testing technologies.
How modern custom applications can spur business growth
Learn how to create, deploy and manage custom applications without consuming or expanding the need for scarce, expensive IT resources.
Reducing security risks from open source software
Follow a few strategies and your organization can gain the full benefits of open source and the cloud without compromising the security of your applications.
Boost IT visibility and business value
How building a great service catalog relieves pressure points and demonstrates the value of IT service management.
Consolidation: the foundation for IT and business transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.