Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Create a JSF Portlet with Oracle WebCenter Suite and JDeveloper : Page 2

A portal provides users with a unified presentation of portlets generated from disparate data sources. Learn how to develop a JSF portlet with JDeveloper and run it in Oracle's WebCenter Framework.


advertisement
Creating a JSF Portlet
In this section, you will create a JSF application with the Oracle database as its data source and then convert it to a portlet. The JSF application consists of a DataTable that is generated dynamically using a SQL query.

First, create a JDeveloper application by selecting File->New and then General->Application in the New Gallery wizard. Specify an Application name and select WebCenter Application as the application template. A WebCenter application gets created in the Applications Navigator (see Figure 1). The application consists of the Portlets project for creating portlets and the ViewController project for creating JSF view pages, in which portlets may be embedded.

Click to enlarge

Figure 1. A WebCenter Application:
A WebCenter application gets created in the Applications Navigator.



You use the JSF-Portlet Bridge in the WebCenter Framework to "portalize" JSF applications, meaning the JSF applications will be JSR 168-based portlets afterward. Add the library for the JSF-Portlet Bridge to the Portlets project by selecting Tools->Project Properties and adding the Portlet Faces Bridge library with the Add Library option. Also add the ADF Faces Runtime library and the Oracle JDBC library.

Next, create the JSF application you will portalize and deploy in the WebCenter Framework-enabled OC4J:

  1. Select the Portlets project in the Applications Navigator and select File->New.
  2. In the New Gallery wizard, select Web Tier->JSF in Categories and JSF JSP in Items. Click OK.
  3. When the JSF JSP Wizard starts, click Next, select J2EE 1.4 as the Web application version, and click Next again.
  4. Specify input.jsp as the file name and click Next.
  5. Select Automatically Expose UI Components in a new Managed Bean, specify PortletBean as the class name, and click Next.
  6. Select the default tag libraries, JSF Core 1.0 and JSF HTML 1.0, and click Next.
  7. Select the default HTML options and click Next.
  8. Click Finish to create a JSF page (input.jsp) and a faces-config.xml deployment descriptor in the Portlets project.

A portlet requires a portlet.xml deployment descriptor, so add portlet.xml to the Portlets project:

  1. Select File->New.
  2. In the New Gallery wizard, select Filter By->All Technologies and select General->Deployment Descriptors from the Categories menu.
  3. Select portlet.xml and Click OK

See Figure 2 for the directory structure of your JSF portlet application.

Click to enlarge

Figure 2. Directory Structure of the JSF Portlet Application:
A portlet requires a portlet.xml deployment descriptor, so add portlet.xml to the Portlets project.

Now you're ready to add JSF components to your application. In the Component Palette, select JSF HTML and add the following to the JSF page input.jsp:

  • An output label
  • An input text field
  • A command button
  • A data table

The JSF page's input text field specifies a SQL query. When a user clicks the Create Data Table command button, the commandButton_action method gets invoked and a data table gets created dynamically in the PortletBean.java backing bean (Listing 1 shows the backing bean class). The SQL query specified in the input text field runs in the invoked commandButton_action method to generate a result set for the data table. Listing 2 shows all the code for input.jsp with the added components.

Specify an ID for each of the dynamically generated JSF components. If you don't, the JSF framework generates duplicate IDs in the portlet markup and the following error gets generated when the portlet runs:

Duplicate component ID … found in view. An internal error has occurred in method getMarkup()



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap