For developers who want quick solutions to build components,
OracleAS Portal provides wizards that guide them step-by-step through the process
of creating a portlet. This lesson describes how to create portlets in OracleAS
Portal without the need to write any code. It then describes how portlets can
be mapped together by using parameter values and events to create a fully functional,
integrated page.
OracleAS Portal includes a declarative environment
and extensibility features that make it easy for developers to expose enterprise
data as portlets. PortalTools is a part of the Oracle
Application Server Portal Developer Kit (OracleAS PDK), and contains
new portlets designed to capture and integrate data from multiple data sources
including Web services, spreadsheets, Extensible Markup Language (XML), and
Web sites. Portlet developers can also use the local database providers, including
13 data-driven components, to create portlets that interact with enterprise
data in an Oracle database or other data sources.
OmniPortlet and Web Clipping portlets shift the
customization and integration of portal development from information technology
(IT) departments to nontechnical users using self-service interfaces. OmniPortlet,
which is a subcomponent of OracleAS Portal, is specifically targeted at enabling
content contributors and content managers to quickly and easily publish data
from various data sources by using a Web-based wizard. Web Clipping is an intuitive,
straightforward tool to speed up the creation of portlets by using existing
Web-based content and functionality. Web clippings are sections of existing
Web content that can be reused in Portal pages.
Parameters and Events
In addition to publishing data, portlets can also
use OracleAS Portal's page parameters and events. In OracleAS Portal, you can
pass parameters between portlets residing in the same page or on different pages
by using page parameters and events. This powerful technology enables portlets
to easily work together, thus helping to create a cohesive application.
A page parameter in a portlet can drive the content
and display of other portlets and pages. Page parameters enable you to declare
a public data input interface to a page. This interface can then be used to
transmit data from page to portlet in a standardized method that is directly
supported by OracleAS Portal. 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. Public portlet parameters enhance your portlet's
flexibility by enabling you to reuse your portlets on multiple pages.
An event is a specific action that a 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. A portlet 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.
OmniPortlet in OracleAS Portal enhances your experience
in publishing content. You can use OmniPortlet to quickly and easily publish
data from various data sources and render the results in varied formats. You
can format your data in a tabular layout, chart, news layout, bulleted list,
form layout, and other custom layouts. OmniPortlet provides you with a wizard-based
portlet creation experience and supports content caching to improve performance.
You can build simple but powerful applications in OracleAS Portal by combining
OmniPortlet, the Simple Parameter Form portlet, and the page parameters and
events model.
In this lesson, you will use OmniPortlet to publish
the data contained in a comma-separated value (CSV) file as a pie chart. You
will use the CSV file that you added to
your portal using the WebDAV client in the Publishing
and Searching Content lesson.
Adding an OmniPortlet
to the HR Tab
1.
Click the HR
tab.
2.
In the empty region
directly under the tabs, click the Add Portlet icon.
3.
In the Portlet
Repository section, click the Portlet Builders link.
4.
Click the OmniPortlet
link to move it to the Selected Portlets section.
5.
Click OK.
OmniPortlet utilizes a develop-in-place model that lets you place a
shell portlet on the page. After placing this shell portlet on the page,
you can configure this portlet to meet your requirements by using a
wizard. This feature of developing portlets in-place enables you to
create, edit, and manage portlets while building a portal page.
Copying the URL for the Data Source
Before you edit the portlet to define its contents, you need
to have all the required information to specify the data source for OmniPortlet.
For CSV data sources, you must know the URL for the CSV. The CSV that you will
use in this lesson is one of the files that you copied in the WebDAV section
of Publishing and Searching Content. To
find the URL for this file, navigate to the page containing the file and copy
its URL.
1.
Click <YourName>
Oracle By Example in the Path field.
2.
Click the OBEWebDAV
link.
3.
Right-click the
dept link and select the Open in New Window menu
option.
4.
Copy the URL
from your browser's Address field into the clipboard,
and close this browser window
5.
Access your OracleAS
Portal application. You are in the OBEWebDAV page.
6.
Click <YourName>
Oracle By Example in the Path field.
7.
Click the <YourName>
OBE Home Page link.
Developing Portlets In-Place
Now, you will develop the portlet in-place based on the department
spreadsheet (dept.csv).
1.
Click the Define
link to define the contents of this OmniPortlet.
2.
Select the Spreadsheet
- A text file with comma separated values (CSV)
option button.
OmniPortlet allows for a variety of different data sources. Later in
this lesson, you create another OmniPortlet that uses a Web service
as a data source
3.
Click Next
to move to the Define your OmniPortlet page in the wizard.
4.
In the CSV URL
field, paste the URL for the dept
file.
If the data source required any connection information, such as to
a database, you would provide that information here.
5.
Click Next.
Use the Filter page to further refine, filter, or sort
the data being returned from the specified data source.
6.
Click Next.
You can specify the display settings for the OmniPortlet on the View
page.
7.
Enter Departments
in the Title field.
8.
Clear the Show
Header Text check box.
9.
Clear the Show Footer
Text check box.
10.
In the Layout
Style section of the page, click the Chart option button.
11.
Click Next.
12.
Select Pie for
the chart style.
13.
In the Legend
field, select Bottom from the list.
Specify the settings for the Column Layout section
as shown below.
Select <None> for the Group field.
Select Department for the Category field.
Select pct for the Value field.
14.
Click Finish.
15.
Click the Edit
Region icon for the region that contains the pie chart. You
configure the display settings for the portlet added to this region.
16.
In the Region
Display Options section, set the value in the Number of Columns
field to 2.
17.
Specify the settings
for the Portlet Display Options section as shown
below.
Set the value in the Space Between Portlets field
to 6 pixels.
Set the value in the Space Around Portlets field
to 4 pixels.
A portlet provider is an entity that manages one
or more portlets and acts as a conduit for communication between OracleAS Portal
and the portlets. Providers abstract the actual implementation of portlets from
the portal, allowing for a simpler portal architecture.
Providers can be broadly categorized into two groups:
Web providers and database providers. Web providers are deployed to a Java 2,
Enterprise Edition (J2EE) application server or remotely from OracleAS Portal
and communicate with OracleAS Portal using HTTP. The database providers are
implemented in PL/SQL and deployed in the Oracle database where OracleAS Portal
is installed. The database providers are beneficial when you want to perform
data-intensive operations, because OracleAS Portal offers a rich set of portlet-building
tools and environments.
A database provider may contain one or more portlets;
there is no limit on the number of portlets a provider may contain. In this
lesson, you will create a database provider to contain reusable portlets.
1.
Click the Navigator
link at the top right of the screen.
2.
Click the Providers
tab.
3.
Click the Locally
BuiltProviders link.
4.
Click the Database
Provider link in the Create New... field.
5.
In the Portal
DB Provider Name field, enter <YourName>Provider.
6.
In the Portal
DB Provider Display Name field, enter <YourName>
DB Provider.
7.
Select HR
from the Portal DB Provider Schema drop-down list.
Next, you will create a portlet within the provider
you just created. The portlet queries the HR.EMPLOYEES
table and shows the employees for a given department.
1.
Click the <YourName>
DB Provider link.
2.
Click the Report
link in the Create New... field.
3.
Click the Reports
From SQL Query link.
4.
In the Name field,
enter empRpt.
5.
In the Display
Name field, enter <YourName>
Employee Report.
6.
In the Portal
DB Provider list, ensure <YourName>PROVIDER
is selected.
7.
Click Next.
8.
Enter the following
SQL statement:
select first_name
|| ' ' || last_name, hire_date
from hr.employees
where department_id = :deptno
Note the bind parameter, deptno,
is used to dynamically update the report in the portal page.
9.
Click Next.
10.
Select the Tabular
option for the report layout.
11.
Click Next.
12.
Change the Column
Heading Text from the concatenated name to Employee Name.
13.
Click Next.
14.
In the Formatting
Conditions section, set the condition as shown below:
Column Names
Values
Column
HIRE_DATE
Condition
<
Value
01-jan-1980
Row/Col
<ROW>
Color
Blue, Cadet
15.
Click Next.
16.
Click Next
to skip through the Display Options section.
17.
In the Customization
FormDisplay Options section, you see an entry for
each bind variable in your SQL statement. For the deptno bind variable,
assign a default value of 10, and select the Make Public
check box.
Note: Checking
the Make Public check box exposes and allows you to set this
parameter on the page on which this portlet is displayed.
18.
Click Next
through the remainder of the wizard pages to see what other options can
be set or click Finish now.
19.
Click Close.
20.
Click the Navigator
link at the top right of the page.
21.
Click the Page
Groups tab.
22.
Ensure that your
path is Path: Page Groups > <YourName> Oracle
By Example > Pages.
Click the Edit link to the right of <YourName>
OBE Home Page. Ensure that the HR tab is selected.
23.
Click the Add
Portlet
icon to add another portlet in the region containing the OmniPortlet pie
chart.
24.
In the Search
field, enter <YourName>
and click Go.
When you build portlets and providers using the built-in tools in OracleAS
Portal, such as the Portlet Builder, OracleAS Portal automatically registers
the provider for you. After you have created your portlet, it is automatically
displayed in the Portlet Repository.
25.
In the Portlet
Repository Search Results section, click the <YourName>
Employee Report link to move it to the Selected Portlets
section.
26.
Click OK.
Note: The report
shows the employees in department 10 because you gave the report deptno
parameter a default value of 10.
Integrating Portlets
Using Page Parameters and Events
We now have a pie chart that shows departments, and an employee
report that shows employees based on department. You will now map these two
portlets together so that when a user clicks on a pie slice, the Employee report
updates to show the number of employees in the department associated with that
pie slice. You will create a page parameter to hold the department number, which
will be passed between the two portlets.
1.
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 dept
in the Parameter Name field.
4.
Click Add.
5.
The dept
parameter now shows in the Page Parameter Properties
section.
In the Default Value field, enter 30.
You can see how parameter values passed from the page override the default
values of the Report portlet.
6.
You have a parameter
with the value of 30. Next, you need to pass this parameter
value to the Employee report.
In the Portlet Parameter Values section, click the
HR : <YourName> Employee Report portlet link.
7.
When defining the
Report portlet, you made the deptno
parameter public. You can use this portlet parameter to pass a value from
the page.
In the drop-down list, select Page Parameter.
8.
This causes another
list to appear. In this list, you select the page parameter to bind to
the portlet parameter.
Select dept. Now, you have mapped the deptno
portlet parameter to the dept page
parameter.
9.
Click OK.
Note: There are
more values showing in the Employee report. This is because you are
passing the value 30 (the page parameter default value) to the Employee
report. You can see more employees in department 30 than in department
10.
Defining an Event Action
Next, you create an event. In this lesson, the event is clicking
on a pie slice. When you click a pie slice, the department number for that pie
slice is raised. This value is passed to the Employee report using the page
parameter, which, in turn, causes the Employee report to refresh with the new
value.
1.
Click the Edit
icon for the Pie chart OmniPortlet.
2.
Click the Layout
tab.
3.
In the Chart
Drilldown section, select Event1 from the list.
This setting triggers a predefined event called Event1 when a pie
slice is clicked.
4.
Click the Events
tab.
5.
In the Event
Outputs section, select Department from the Event1Param1
drop-down list. Click OK.
Now, when Event1 is raised, the department value is
passed to the Param1 parameter.
7.
Portlets are self-contained
content on a page. Now that the portlet is raising an event, you need
to configure the page to respond to this event.
Click the Page Properties link at the top of the page.
8.
Click the Events
tab.
9.
In the Portlets
Events section, click the HR : OmniPortlet link.
Note: If you are not able to access
the OmniPortlet event in the Page Properties, refresh your OmniPortlet
Provider. To refresh your OmniPortlet Provider, access the Navigator
in Portal. Click the Providers tab. Click the Locally
Built Providers link. You should be able to see OmniPortlet
Provider. Click the Refresh link.
10.
Click Event1.
Earlier, you specified in the OmniPortlet settings that this event
should be raised when a pie slice is clicked. Now, you need to specify
what should happen when this event is raised. In this lesson, you refresh
the OBE Home Page with the new parameter value.
11.
The section on the
right of the page refreshes to set the event information. Click the Go
to page option button.
12.
Click the List
of Values icon to the right of the Go to page field.
13.
Find <YourName>
Oracle By Example page group in the list.
Click the plus icon to expand your page group.
14.
Click the Return
Object link to the right of <YourName> OBE
Home Page.
15.
Next, you need to
specify the values that should be passed to the
page from the output of the portlet.
In the Page Input
section, select Event Output from the list.
16.
Select Event1Param1
from the second list.
This maps the event output to the dept
page parameter.
17.
Click OK.
Notice how clicking on different pie slices changes the value
of the Employee report.
To summarize the steps that you have performed:
In the properties for the pie
chart, you specified this portlet would raise an event and pass out the
value of the department.
In the page properties, in the Events tab,
you set the page to listen for the event, which the pie chart raises and
place the output of the event into the page parameter called department.
In addition, in the page properties, you
set the page to refresh itself when the event was raised. When the page
is refreshed, the new value in the page parameter is passed to the Employee
report.
Creating a Portlet Using a Web Service
as a Data Source
Web services provide a means of encapsulating business services
and publishing them on a network. A Web service is a discrete business service
that is platform and language independent and can be programmatically accessed
over a network by using standard protocols, such as Simple Object Access Protocol
(SOAP) and HTTP. A Web service can be described, published, discovered, and
invoked in a distributed computing environment. A number of business functions,
such as currency exchange rates, stock quotes, and global weather, are available
as Web services.
A Web service can be used as a data source with OmniPortlet.
In this lesson, you will add an Omniportlet on the Key Indices
tab. This Omniportlet uses Web services as a data source. This Web service exposes
the DEPT and EMP tables of the Oracle Database SCOTT schema as Web services.
1.
Click the Key Indices
tab.
2.
Click the Add Portlet icon.
3.
Click Portlet Builders.
4.
Click the OmniPortlet
link to move it to the Selected Portlets section.
Click Show Methods to see what methods are available
from this Web service.
10.
In the Web Service
Methods section, select the OTNDeptEmp.getEmpXML
method from the Available Methods for this Web Service
list. This Web service method returns all the employees of the Employee
table as XML.
Note: The methods exposed in a Web
service enable you to interact with the Web service. Some methods expose
parameters.
11.
Click Show
Parameters to check whether the OTNDeptEmp.getEmpXML
method accepts any parameters.
12.
You could note
that the selected method does not accept any parameters.
Now, click Next to filter the data returned from the data source.
In this lesson, you restrict the returned data to only one department
from the Employee table.
13.
In the Conditions
section, select DEPTNO from the Column list, Equals
from the Operator list, and enter 20
for the Value field.
14.
Click Next.
15.
Enter Employees
in Department 20 in the Title field.
16.
Deselect
the Show HeaderText check box.
Enter OmniPortlet using
Web services as data source in the Show Footer
Text field.
Ensure that the Show FooterText check box
is selected.
17.
Select the Tabular
option button for Layout Style section and click Next.
18.
In the Tabular
Style section, select the Alternating option
button.
In the Column Layout section, enter the details as
shown in the following table:
Name
Column Label
Column
Label
Display As
Action
Field1
Employee Number
EMPNO
Left
Text
None
Field2
Employee Name
ENAME
Left
Text
None
Field3
Job Title
JOB
Left
Text
None
Field4
Salary
SAL
Left
Text
None
Field5
Department Number
DEPTNO
Left
Text
None
19.
Click Finish.
You can see the details of all the employees in department 20
being dispalyed in a tabular format.
In this lesson, you were introduced to the declarative environment
for building portlets. You used OmniPortlet to create a chart and published
it as a portlet on your Portal page. You created a Portal database provider
and used the OracleAS Portal wizards to build a report portlet to display data
from a database. You also learned how to use parameters and events to integrate
these two portlets on a page.