In this lesson, you learn how you can use an OmniPortlet to
publish data from various data sources in a variety of layouts. You learn to
select and configure different data sources to publish content by using the
OmniPortlet. You learn to modify the layout, and add parameter support to your
OmniPortlet. You also learn how to enhance the reusability of an OmniPortlet
by controlling the flow of parameters and events across your OmniPortlet and
portal pages.
An OmniPortlet enables portal developers to quickly and easily
publish data from various data sources in a variety of layouts by using a Web-based
wizard. The OmniPortlet can be based on almost any kind of data source such
as a spreadsheet, XML, Web services, database, or even application data from
an existing Web page. The OmniPortlet provides you with a wizard-based portlet
creation experience and supports content caching to improve performance.
An OmniPortlet provides the most common layouts for portlets:
tabular, chart, news, bulleted list, and form. The OmniPortlet enables you to
select different layouts and change them independently of the data source, giving
maximum flexibility. You can refine the retrieved data by applying filters to
it.
The OmniPortlet Web provider enables content contributors
and content managers to:
Display
data from multiple sources
Sort
the data to display
Format
data by using a variety of layouts
Define public portlet parameters
Map
public portlet parameters with page parameters
The OmniPortlet provider is installed as part of OracleAS
Portal. You can add this OmniPortlet to your portal page from the Portlet Repository
where it is found under Portlet Builders. If the portal administrator
has reorganized the Portlet Repository, the default portlets may be in different
locations within the Portlet Repository.
If you have downloaded the OmniPortlet as part of the OracleAS
Portal Developer Kit, you must perform either of the following tasks:
Refresh the provider if you have upgraded the preinstalled
one
Register the OmniPortlet if you have installed it
in a different instance
You can then add the OmniPortlet to any portal page.
In this section, you add an OmniPortlet instance to your portal
page.
1.
Access your portal.
Click the Navigator link.
2.
Your path must
be Path: Page Groups
> <YourName> Oracle By Example > Pages.
3.
Click the Edit
link to the right of the <YourName> OBE Home Page
link.
4.
Click the Key
Indices tab.
5.
Click the Add
Portlet
icon on the region header. OracleAS Portal displays the Portlet Repository.
6.
Click Portlet
Builders.
Note: If you are not using the OmniPortlet
that is readily available and have installed the OmniPortlet in another
OracleAS Portal instance, then you can locate your OmniPortlet in the
Portlet Staging Area. By default, all newly registered
providers and portlets are available in the Portlet Staging Area in
the Portlet Repository.
7.
Click the OmniPortlet
link to move it to the Selected Portlets area.
The first step in building an OmniPortlet is to define the
data source and configure it to create a personalized portlet. You can publish
content using an OmniPortlet by performing the following tasks:
Choosing the type of data
Configuring
the access to secure data
Filtering
the data
Setting
the title, header, and footer text for the OmniPortlet
Selecting
the layout format
Specifying
the layout options
An OmniPortlet offers an easy way to publish data from a database
by using the SQL data source. The SQL data source option uses standard Java
Database Connectivity (JDBC) drivers and provides ready-to-use access to the
Oracle database along with other databases supporting Open Database Connectivity
(ODBC). You can enter the database connection information or reuse existing
saved connection information to access a specific database. After the connection
information is correctly entered, any SQL statement can be written and parameterized.
In this section, you configure an OmniPortlet to publish data
from a database by using a SQL statement.
1.
Click the Define
link for the new portlet. The first page of the OmniPortlet wizard displays
where you can specify the data source.
2.
You configure your
OmniPortlet to use a SQL data source. Select the SQL option
button.
3.
Click Next.
4.
In the Connection
section, click the Edit Connection button to define the
database connection used to retrieve the data.
5.
Create a new connection
by using the details given in the following table:
Field
Value
Connection Name
DB Connection
User Name
scott
Password
tiger
Connection String
<hostname>:<port>:<sid>
For example, localhost:1521:ASDB
Driver Name
Oracle-thin
Note: You must specify appropriate values in the Connection
String field to connect to a database.
6.
Click Test
to check the connection information.
You see the Connection Successful
message in the Connection Test Result window.
7.
Click Close
to close the window.
8.
Click OK
to return to the OmniPortlet wizard page.
The new Connection Name now appears in the Connection
section.
9.
In the SQL
section, enter the following statement:
select * from scott.dept
10.
Click Test
to test the SQL query.
11.
Click Close
to close the Query Results window.
12.
Click Next.
You can use this page to filter and order the data that appears in your
portlet. An OmniPortlet supports filtering of data in two areas:
Filtering at the data source itself by specifying the details on the
Source page
Filtering at the middle tier by using the conditions specified on the
Filter page
Note: It is always more efficient to
filter and sort the data at the data source because you can streamline
the process by retrieving only the necessary data. The best practice to
use the middle-tier filtering is when the data source does not support
any filtering or sorting capability (for example, a spreadsheet).
13.
Click Next
as you do not want to apply any filters to the query results.
14.
In the Header
and Footer Text section, enter Department Details
in the Title field.
15.
Enter Data
retrieved using the SQL data source in the Footer Text
field.
16.
Ensure that the Show
Footer Text check box is selected.
17.
Deselect the Show
Header Text check box.
18.
In the Layout
Style section, select the Form layout for the
portlet data.
19.
In the Caching
section, select the Don’t Cache the Portlet Content
option button. When you select this option, the OmniPortlet does not cache
the portlet content and displays dynamic content.
20.
Click Next.
21.
In the Column
Layout section, enter the details as shown in the following table:
Name
Column Label
Column
Label
Display As
Action
Field1
Department Number
DEPTNO
Left
Text
None
Field2
Department Name
DNAME
Left
Text
None
Field3
Location
LOC
Left
Text
None
22.
Click Finish.
The OmniPortlet displays the results of your SQL query on your portal
page.
An event is a specific action that the portlet can perform.
Portlet events model the page navigation and the data output of a portlet when
a user clicks a link or submits a form. An OmniPortlet can raise events, and
you can use these events to send one or more parameters to a page. This feature
enables you to create dynamic pages that are based on each user’s interaction
with the page. You can configure up to three OmniPortlet events. Each event
can pass up to three parameters. Each parameter can be a portlet parameter,
such as Param1, or a data source field.
Earlier, you configured an OmniPortlet to display data in
a Form layout from a SQL statement. In this section, you set up your SQL OmniPortlet
to raise an event when the user clicks a Department Number
link. After the user clicks the link, the OmniPortlet retrieves the department
number for the selected department, and passes that value to the event parameter,
Event1Param1. Events are configured using the Events
tab when you select the Edit Defaults function for the OmniPortlet.
1.
Click the Edit
icon for the Department Details OmniPortlet.
2.
Click the Layout
tab.
3.
In the Column
Layout section, define an action for the DEPTNO column.
Select Event1 from the Action list.
This setting triggers a predefined event called Event1
for the Department Number field.
4.
Click the Events
tab.
5.
In the Event
Outputs section, select DEPTNO from the Event1Param1
list.
6.
Click OK.
OmniPortlet events enable you to generate interportlet communication.
Now, when Event1 is raised, the department value is passed
to the page parameter, Param1, on the target page. Later,
you pass this page parameter, Param1, to another OmniPortlet
on the same page
Later in this lesson, you configure another instance of the OmniPortlet
to receive a value from a public portlet parameter and send this value
to its data source. You personalize this OmniPortlet by mapping its portlet
parameter to the page parameter, Param1, so that the
second OmniPortlet responds to this raised event.
XML is increasingly used as a method of providing controlled
access to data sets over the intranet and the Internet. You can use XML as a
data source with an OmniPortlet and specify the URL to XML content. An OmniPortlet
requires that your data be in a <Rowset>/<Row>
format or a tabular format. However, the names of various tags used in the XML
file need not be <Rowset>/<Row>.
If the XML data source does not exactly match this format,
you can specify the URL to an Extensible Style Sheet Language (XSL) filter to
transform the data to the required format. Regardless of the format of the XML
file, the OmniPortlet introspects the XML data source to determine the column
names that are used to define the layout. However, you can specify this information
by using the URL of an XML schema file, which defines the structure of the XML
data to be used by the OmniPortlet.
In this section, you add and define an OmniPortlet to publish
data by using an XML data source. Add another instance of the OmniPortlet to
the Key Indices tab on your portal page by using the steps
listed in Adding an OmniPortlet to an OracleAS
Portal Page.
1.
After adding an
OmniPortlet to your page, click the Define link for the new portlet.
2.
Select the XML
option button.
3.
Click Next.
4.
Enter /htdocs/omniPortlet/sampleData/employees.xml
in the XML URL field.
5.
Click Next.
6.
You use this
page to filter the data that appears in your OmniPortlet. You configure
this page later in the lesson.
Click Next.
7.
In the Header
and Footer Text section, enter Data retrieved using the
XML data source in the Title field.
8.
Deselect the Show
Footer Text check box.
9.
In the Layout
Style section, select the Tabular layout for
the portlet data.
10.
Click Next.
11.
In the Column
Layout section, enter the details as shown in the following table:
Public portlet parameters enhance your portlets’ flexibility
by enabling you to reuse your portlets on multiple pages. Because of this, you
need not make changes to the portlet code when adding the portlet to different
pages. Using public portlet parameters, any portlet on a page can easily receive
its value from the mapped page parameter, regardless of the portlet parameter
names.
An OmniPortlet can accept parameters and render results in
any format, including HTML, depending on the parameter values. The OmniPortlet
can receive up to five parameters. Each parameter is specified as ##ParamX##,
where X is an integer between 1 and 5 (for example, Param1).
The OmniPortlet parameters are passed as name-value pairs. You must specify
a default value in the Portlet Parameters section or specify a value at run
time. You can configure an instance of the OmniPortlet to receive a specific
parameter and send this parameter to a data source.
In this section, you add a parameter to the Employee Details
OmniPortlet created by using the XML data source. You use this parameter value
to filter the results returned by the XML data source. Instead of showing the
data for all departments, your OmniPortlet displays the information for the
department number indicated in the parameter you used, and the header text is
updated accordingly.
1.
Click the Edit
icon for the OmniPortlet created by using the XML data
source.
2.
Access the Source
tab. In the Portlet Parameters section, enter the following
details:
Field
Value
Parameter Name
Param1
Default Value
10
Customizable
Selected
Customize Page Label
Department Number
Customize Page Description
This is a public portlet parameter.
You can use the Portlet Parameters
section to add interactivity to the OmniPortlet. You can also parameterize
the credential information used to access secure data.
3.
Click the Filter
tab.
4.
Enter the following
filter condition in the Conditions section:
Field
Value
Match all
Selected
Column
DEPARTMENT_NO
Operator
Equals
Value
##Param1##
By specifying the filter value to ##Param1##, you set
the portlet to use the value of Param1 for the value
of the DEPARTMENT_NO column. For example, if Param1
is 10, then the filter condition evaluates to DEPARTMENT_NO Equals
10.
5.
In the Order
Section, select EMPLOYEE_ID as the first column to order
the results by.
Select Ascending for the sort order.
6.
Click the View
tab.
7.
Enter Employee
Details in Department ##Param1## in the HeaderText field.
8.
Ensure that the
Show Header Text check box is selected and the Show
Footer Text is deselected.
9.
Click OK.
10.
You have specified
10 as the default value for the portlet parameter, Param1.
The OmniPortlet uses the value of portlet parameter to filter the data.
Now, you see the details of employees in Department10.
Integrating an OmniPortlet
Event with Page Parameter
After creating the portlet parameter and event, you must set
the page parameters and events to relate the two portlets together on your portal
page. You can create page parameters by using a declarative user interface.
The purpose of creating page parameters is to map external parameters to portlet
parameters. Page parameters and events can be used with an OmniPortlet to create
a cohesive application. You can pass parameters between portlets residing on
the same page or on different pages by using page parameters and events. This
powerful technology permits unrelated portlets to work together easily.
In this section, you integrate the portlet parameter with
your page parameter and event. At the end of this section, when you click the
Department Number link on the Department Details
OmniPortlet, an event is raised that sends a DEPTNO parameter
to all the portlets on that page. The Employee Details OmniPortlet uses the
value of this parameter to display information about the employees in the selected
department.
To do this, you set a value by using a page parameter and
map this page parameter to the portlet parameter, Param1.
1.
To create a department
parameter on the <YourName> OBE Home Page, click
the Page Properties link.
2.
Click the Parameters
tab.
Note: The Parameters and Events
tabs show for all pages that are owned by a page group that has parameters
and events enabled. Parameters and events are enabled by default in
OracleAS Portal.
3.
In the New
Page Parameter section, enter department in the Parameter
Name field.