Skip Headers
Oracle® WebCenter Framework Building a WebCenter Application Step by Step
10g (10.1.3.2.0)

Part Number B31073-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

8 Building a Dashboard Page

In this chapter, you will build a dashboard page for your WebCenter application. A dashboard page is an easy-to-read user interface that organizes and presents metrics and key performance indicators related to business activity and business intelligence.

In this sample dashboard, your end user will be able to view site statistic information and search customer contacts and view volume distribution for each day. The end user can also view information about customers that are the most active, customer details, most productive customers, and products with the most requests, as shown in Figure 8-1.

Figure 8-1 Overview of the Dashboard Page

Description of Figure 8-1 follows
Description of "Figure 8-1 Overview of the Dashboard Page"

This chapter shows you how to build a page and use OmniPortlet to create the dashboard page shown in Figure 8-1 and includes the following sections:

Step 1: Creating the Dashboard Page

This section shows you how to build the page on which you will place your portlets to create the dashboard page. Before you begin, ensure that you have the required sample files and initialized your preconfigured OC4J, as described in the install.html file located in the sample files.

  1. Create a new JSF JSP page, ensuring that you select the following options in the Create JSF JSP Wizard:

    Note:

    To access the Create JSF JSP Wizard, from the File menu, choose New, and in the New Gallery dialog box, under Web Tier, choose JSF.
    • Step 1 of 4: Name the page SRDashboard.jspx, point the directory path to UserInterface\public_html\app\management\, and select the JSP Document (*.jspx) type.

    • Step 2 of 4: Select the Automatically Expose UI Components in a New Managed Bean option and leave the remaining defaults on this page.

      Note:

      Make sure that the name of the New Managed bean is app_management_SRDashboard.
    • Step 3 of 4: Ensure that the following libraries are listed in Selected Libraries:

      • JSF Core

      • JSF HTML

      • ADF Faces Components

      • ADF Faces HTML

      • ADF Portlet Components

      • Customizable Components Core

    Note:

    For information on building and populating a page, refer to the Populating Pages chapter in the Oracle WebCenter Framework Developer's Guide.
  2. Once you have completed the wizard and created your page, expand SRDemoSample_Starter, UserInterface, and WEB-INF\template folders of your application.

  3. Right-click SRDemoTemplate.jspx and choose Open.

  4. Click the Source tab, then copy the source code from the SRDemoTemplate.jspx page and paste it into the source of your new SRDashboard.jspx page, replacing all the existing code in your new page.

  5. Search for _PAGE_NAME_ and replace it with srdashboard so that the panelPage tag looks like:

    <af:panelPage title="#{res['srdashboard.pageTitle']}">
    
  6. To provide a translatable page title for the new page, expand SRDemoSample_Starter, UserInterface, Application Sources, oracle.srdemo.view, resources, and then open the UIResources.properties file.

  7. In the UIResources.properties file, add the following lines to the end of file:

    #WC_DashboardPage
    srdashboard.pageTitle=Dashboard
    
  8. In the WEB-INF folder of the UserInterface project, open faces-config.xml.

  9. If necessary, click the Source tab.

  10. At the end of the file, before the closing </faces-config> tag, add the managed bean shown in Example 8-1 to the existing code to instantiate the bean that manages the menu item for the Dashboard subtab.

    Example 8-1 Managed Bean for the Dashboard Subtab

    <managed-bean>
        <managed-bean-name>subMenuItem_Manage_Dashboard</managed-bean-name>
        <managed-bean-class>oracle.srdemo.view.menu.MenuItem</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
          <property-name>label</property-name>
          <value>#{resources['srdemo.menu.manage.dashboard']}</value>
        </managed-property>
        <managed-property>
          <property-name>shown</property-name>
          <value>#{userInfo.manager}</value>
        </managed-property>
        <managed-property>
          <property-name>viewId</property-name>
          <value>/app/management/SRDashboard.jspx</value>
        </managed-property>
        <managed-property>
          <property-name>outcome</property-name>
          <value>Dashboard</value>
        </managed-property>
    <!-- ADF Authorization -->
        <managed-property>
          <property-name>targetPageDef</property-name>
          <value>app_management_SRDashboardPageDef</value>
        </managed-property>
    <!-- End ADF Authorization -->
    </managed-bean>
    
  11. Save the file.

  12. Add the following line to the end of the UIResources.properties file:

    srdemo.menu.manage.dashboard=My Dashboard
    
  13. Open the faces-config.xml file and search for <managed-bean-name>menuItem_Manage.

  14. Now that you have created the subtab, you must add it as a menu item to the parent menu. You can do so by adding the following to the list-entries tag:

    Example 8-2 Code for Adding the Dashboard Subtab to the Management Page

    <value>#{subMenuItem_Manage_Dashboard}</value>
    
  15. Link the new dashboard menu item to the JSPX page by adding the code shown in Example 8-3 to the navigation rule.

    Example 8-3 Code for Linking the Dashboard Subtab to the Dashboard.jspx page

    <navigation-rule>
       <from-view-id>/app/management/SRManage.jspx</from-view-id>
       <navigation-case>
          <from-outcome>Dashboard</from-outcome>
          <to-view-id>/app/management/SRDashboard.jspx</to-view-id>
       </navigation-case>
    </navigation-rule>
    
  16. Save the page.

Step 2: Creating the Page Layout

This section shows you how to use customizable components, specifically the PanelCustomizable component, to design the layout of your page. For more information on using customizable components, refer to the Customizable Components section in Chapter 7, "Building a Page and Adding Components".

You can view the code of the completed page by opening the SRDashboard.jspx page in the completed demo and viewing its source.

  1. To add the first row of the dashboard, first open the source of your SRDashboard.jspx file.

  2. Search for the text "Please Insert Main Page Content Here!" and place your cursor below this line.

  3. From the Component Palette, choose Customizable Components Core.

  4. On the Customizable Components Core list, click PanelCustomizable to add a PanelCustomizable component to your page. The code displays as shown in Figure 8-2.

    Figure 8-2 Placement of the First PanelCustomizable

    Description of Figure 8-2 follows
    Description of "Figure 8-2 Placement of the First PanelCustomizable"

  5. In the Structure Pane, select the cust:panelCustomizable you just added, and set the IsMovable property in the Property Inspector to false.

  6. Add a second PanelCustomizable below the one you just created.

  7. In the Structure Pane, select the cust:panelCustomizable you just added, and set the following properties in the Property Inspector:

    • DisplayHeader to true

    • Id to panelCustomizable2

    • Layout to horizontal

    • Text to Business Analysis

    • IsMovable to true

    • IsSeededInteraction to true

    The source code of your page should now look like Figure 8-3.

    Figure 8-3 PanelCustomizable in the Source Code

    Description of Figure 8-3 follows
    Description of "Figure 8-3 PanelCustomizable in the Source Code"

  8. Create a ShowDetailFrame component below the PanelCustomizable you just created by choosing ShowDetailFrame from the Customizable Components Core Component Palette.

  9. Set the Text property for the new ShowDetailFrame to Customer Contracts. The code displays as shown in Figure 8-4.

    Figure 8-4 ShowDetailFrame in the Source Code

    Description of Figure 8-4 follows
    Description of "Figure 8-4 ShowDetailFrame in the Source Code"

  10. Insert a spacer after the ShowDetailFrame component you just created. To do so, choose ADF Faces Core from the Component Palette, then select ObjectSpacer. The code displays as shown in Figure 8-5.

    Figure 8-5 ObjectSpacer in the Source Code

    Description of Figure 8-5 follows
    Description of "Figure 8-5 ObjectSpacer in the Source Code"

  11. Add a second row to your page by creating a second PanelCustomizable component with the following properties:

    Property Value
    DisplayHeader false
    Layout horizontal
    Text Service Requests Volume
    IsMovable true
    IsSeededInteractionAvailable true

  12. Add a ShowDetailFrame with the Text property set to Service Requests Volume.

    The source code of your page should now look like Figure 8-6.

    Figure 8-6 Source Code of Dashboard Page Containing Two Customizable Components

    Description of Figure 8-6 follows
    Description of "Figure 8-6 Source Code of Dashboard Page Containing Two Customizable Components"

  13. Next, you will add a horizontal panel inside the ShowDetailFrame called "Customer Contracts."

    To do so, place your cursor on the line after the ShowDetailFrame. From the Component Palette, choose ADF Faces Core, then choose PanelHorizontal from the list.

  14. Next, add an Input Text field inside the PanelHorizontal.

    To do so, place your cursor on the line after the PanelHorizontal you just added, then choose InputText from the Component Palette.

  15. Select the InputText component in your source.

  16. In the Property Inspector, set the Label property to Customer.

  17. Set the Value property to: "%".

  18. Set the Binding property to: #{backing_app_management_SRDashboard.inputText1}. Figure 8-7 shows the Property Inspector with the appropriate values.

    Figure 8-7 Property Inspector for the Input Text Field

    Description of Figure 8-7 follows
    Description of "Figure 8-7 Property Inspector for the Input Text Field"

    The resulting code should look like the source shown in Figure 8-8.

    Figure 8-8 Input Text Field Source Code

    Description of Figure 8-8 follows
    Description of "Figure 8-8 Input Text Field Source Code"

  19. Next, add a command button that will enable users to search for customer contracts.

    To do so, place your cursor below the InputText component, then choose CommandButton from the Component Palette.

  20. Set the Text property to Search.

  21. Set the Action property to: #{backing_app_management_SRDashboard.commandButton_action}.

  22. In the Property Inspector, set the Binding property to: #{backing_app_management_SRDashboard.commandButton1}.

  23. In the Source, add a Disabled property with the definition: #{!bindings.search.enabled}.

    Your code should now look like Figure 8-9.

    Figure 8-9 Source of the Input Text Field and Command Button

    Description of Figure 8-9 follows
    Description of "Figure 8-9 Source of the Input Text Field and Command Button"

  24. Add a table below the InputText and CommandButton, so that the various portlets display horizontally across the page.

Step 3: Adding Instances of OmniPortlet to Your Page

In this section, you will add instances of OmniPortlet to the page layout. You will define the portlets in the later steps of this chapter, and, finally, wire the portlets together.

  1. Now that you have created your layout, you can add the portlets to your page.

    In the source of your page, place your cursor after the ShowDetailFrame called "Customer Contracts," and before the ObjectSpacer you created, then, place your cursor on the first PanelCustomizable in the Structure view.

  2. From the Component Palette, choose OmniPortlet Producer, then click OmniPortlet. You should now see the source code of your page, as shown in Figure 8-10.

    Figure 8-10 OmniPortlet in the Source Code of Your Page

    Description of Figure 8-10 follows
    Description of "Figure 8-10 OmniPortlet in the Source Code of Your Page"

    Note:

    If you do not see the OmniPortlet Producer listed in the drop-down list of the Component Palette, you may need to register the producers associated with this example.
  3. Select the OmniPortlet and, in the Property Inspector and set the ID to customerContracts.

  4. In the source of your page, place your cursor after the OmniPortlet you just added, then add a second instance of OmniPortlet, and change the ID to mostProductiveEmployees.

  5. In the Structure pane, below the third PanelCustomizable, select the ShowDetailFrame and add an OmniPortlet, then set the ID to serviceRequestVolume.

  6. In the Structure pane, select the third PanelCustomizable and add another OmniPortlet, then set the ID to mostRequestedProducts.

  7. Select the third PanelCustomizable again and add another OmniPortlet, then set the ID to customerDetails.

Step 4: Adding a SelectOneChoice Component for the Service Request Volume Portlet

In this section, you will add a SelectOneChoice component for the Service Request Volume portlet.

  1. In the Structure view, below the third PanelCustomizable, select the ShowDetailFrame, then add a SelectOneChoice component from the ADF Core Component palette.

  2. Set the following properties for the SelectOneChoice component:

    • ID = dayPicker

    • label = Volume for last

    • default value = 360

    • items = 1,2,3,5,10,30,60,90,180 and 360 days

    • autoSubmit = true

    The following code should appear in the JSPX:

    <af:selectOneChoice label="Label 1" value="360" autoSubmit="true"
    id="dayPicker">
    <af:selectItem label="1 day" value="1"/>
    <af:selectItem label="2 days" value="2"/>
    <af:selectItem label="3 days" value="3"/>
    <af:selectItem label="5 days" value="5"/>
    <af:selectItem label="10 days" value="10"/>
    <af:selectItem label="30 days" value="30"/>
    <af:selectItem label="60 days" value="60"/>
    <af:selectItem label="90 days" value="90"/>
    <af:selectItem label="180 days" value="180"/>
    <af:selectItem label="360 days" value="360"/>
    </af:selectOneChoice>
    
  3. In the Structure view, select the ShowDetailFrame from the second PanelCustomizable.

  4. In the first tab, select Create list to fill the content of the drop-down list.

  5. Click Add Item.

  6. In the Item label field, type 1 day and in the Item Value field, type 1.

  7. Repeat the previous step for the following days: 2, 3, 5, 10, 30, 60, 90, 180, and 360.

  8. Click the Common Properties Tab.

  9. In the Label field, type Volume for last.

  10. In the Value field, enter 360.

  11. In Advanced Properties tab, for the autoSubmit option, enter true.

  12. Click OK to create the component.

  13. In the Property view, for SelectOneChoice, update the id to dayPicker.

  14. Within the ShowDetailFrame, drag and drop the dayPicker component above the OmniPortlet.

Step 5: Adding a Search for Customer Contracts

In the following steps, you will add a component that allows your users to search for existing customer contracts.

  1. In the page source, locate the ShowDetailFrame called "Customer Contracts" and place your cursor under the PanelHorizontal that is located under the ShowDetailFrame.

  2. In the Data Control palette, expand the ContentRepository data control, then expand Search.

  3. Drag and drop the Search method as an ADF Command Button below the PanelHorizontal.

  4. In the Structure Pane, select the Search method.

  5. In the Action Binding Editor, specify "/contracts" as the path.

  6. Set isRecursive to true, then click OK.

  7. In the Data Control palette, under Search, expand Parameters.

  8. Drag and drop the NamePattern method as an Input Text with Label component before the Search Button.

  9. In the Structure Pane, select the InputText component you just added and set the Label property to Name (use % as wildcard).

  10. In the Data Control palette, under Search, drag and drop the Return method as an ADF Read Only table below the PanelHorizontal.

  11. Save the page.

Step 6: Defining the Most Productive Employees Portlet

In the following steps, you will define your OmniPortlets. Then, at the end of the chapter, you will wire them together to create interactivity.

In this section, you will define the portlet that displays the most productive employees in the organization. To define your OmniPortlet instances, you must first run your JSPX page to your browser, then use the OmniPortlet wizard to define the portlets.

Note:

For more information on using the OmniPortlet wizard, refer to the "Creating Portlets with OmniPortlet" chapter in the Oracle WebCenter Framework Developer's Guide.
  1. Run the SRDashboard.jspx page to your browser.

  2. Click the Define link for the first portlet, and choose SQL as the data type, then click Next.

  3. On the Source tab, enter the SQL statement shown in Example 8-4.

    Example 8-4 SQL Statement for the Most Productive Employees Portlet

    select count(SH.CREATED_BY) as NB_REQ, SH.CREATED_BY,U.FIRST_NAME, U.LAST_NAME
    FROM SERVICE_HISTORIES SH INNER JOIN USERS U ON U.USER_ID = SH.CREATED_BY WHERE
    SH.SVH_TYPE = 'Technician' OR SH.SVH_TYPE = 'Hidden' GROUP BY SH.CREATED
    BY,U.FIRST_NAME,U.LAST_NAME ORDER BY NB_REQ DESC
    
  4. Click Next, then click Next again.

  5. On the View tab, select Tabular, then click Next.

  6. On the Layout tab, update the following options:

    Title: Most Productive Employees

    Layout: Service Request (NB_REQ)

    First Name (FIRST_NAME)

    Last Name (LAST_NAME)

  7. Click Finish.

Step 7: Defining the Service Request Volume Portlet

The steps in this section will show you how to display information about the service requests in a pie chart.

  1. In your browser, on the SRDashboard.jspx page, click the Define link for the second portlet.

  2. On the Type tab, select SQL, then click Next.

  3. On the Source tab, in the SQL Statement field, enter the following:

    Example 8-5 SQL Statement for the Service Request Volume Portlet

    select count(SVR_ID) as NB_REQ, STATUS FROM SERVICE_REQUESTS
    WHERE REQUEST_DATE > (SYSDATE - ##Param1##)
    GROUP BY STATUS ORDER BY NB_REQ
    
  4. Set up a global connection to the database.

    Under Connection, click Edit Connection.

  5. In the Connection Name field, type SRDemo.

  6. In the Username field, type hr.

  7. In the Password field, type hr. These are the username and password for the SRDemo schema you installed when you downloaded the sample files.

  8. In the Connection String field, type the path to your database, for example mydemo.mycompany.com:1522:XE, then click OK. You should now see the connection information in the Connection section of the Source tab.

  9. Create a portlet parameter called Param1 with the default value of 360, then click Next.

  10. On the Filter tab, click Next.

  11. On the View tab, select Chart, then click Next.

  12. On the Layout tab, select Pie, and enter 300 for the Width and 200 for the Height.

  13. Set the Legend to Right and check the 3D effect checkbox.

  14. From the Group list, choose None.

  15. From the Category list, choose Status.

  16. From the Value list, choose NB_REQ, then click Finish.

Step 8: Defining the Most Requested Products Portlet

The steps in this section show you how to define the portlet that displays the most requested products using a SQL statement to access the data in a database.

  1. In your browser, on the SRDashboard.jspx page, click the Define link for the third portlet.

  2. On the Type tab, select SQL, then click Next.

  3. On the Source tab, in the SQL statement field, enter the following:

    Example 8-6 SQL Statement for the Products Most Requested Portlet

    select count(SR.SVR_ID) as NB_REQ, SR.PROD_ID, P.NAME FROM
    SERVICE_REQUESTS SR INNER JOIN PRODUCTS P ON SR.PROD_ID = P.PROD_ID
    GROUP BY SR.PROD_ID, P.NAME ORDER BY NB_REQ DESC
    
  4. Click Next.

  5. On the Filter tab, click Next.

  6. On the View tab, choose Chart, then click Next.

  7. On the Layout tab, choose Bar, then set the following options:

    Width: 300

    Height: 250

    Group: Name

    Category: <none>

    Value: NB_REQ

  8. Click Finish.

Step 9: Defining the Most Active Customers Portlet

The steps in this section will show how to define a portlet that displays the most active customers.

To create the two portlets in the Customer Information section of your page:

  1. In your browser, on the SRDashboard.jspx page, click the Define link for the fourth portlet.

  2. On the Type tab, choose SQL, then click Next.

  3. On the Source tab, enter the following SQL statement, then click Next.

    Example 8-7 SQL Statement for the Most Active Customers Portlet

    select count(SH.CREATED_BY) as NB_REQ, SH.CREATED_BY , U.FIRST_NAME, U.LAST_NAME
    FROM SERVICE_HISTORIES SH INNER JOIN USERS U ON U.USER_ID = SH.CREATED_BY WHERE
    SH.SVH_TYPE = 'Customer' GROUP BY SH.CREATED_BY,U.FIRST_NAME,U.LAST_NAME ORDER BY
    NB_REQ DESC
    
  4. On the Filter tab, make no changes and click Next.

  5. On the View tab, choose the HTML Layout and enter a title: Most Active Customers, then click Next.

  6. On the Layout tab, choose the Sortable Template, then click Apply.

  7. Leave the default code in the Heading Section.

  8. In the Repeating Section, update the code so that it looks like the following:

    <tr class="portlet-section-alternate opRowColorPI1146522302846_##OP_ROWNUM_MOD2##">
    <td class=PortletText1>##NB_REQ##</td>
    <td class=PortletText1>##CREATED_BY##</td>
    <td class=PortletText1>##FIRST_NAME##</td>
    <td class=PortletText1><a href="/SRDemo/faces/app/management/SRDashboard.jspx?
    customerID=##CREATED_BY##" target="_top">##LAST_NAME##</a></td>
    </tr>
    
  9. In the Footer Section, update the code so that it looks like the following:

    </tbody></table><font class=PortletText1>Total Rows: ##OP_ROWNUM##</font>
    
  10. Click Finish.

Step 10: Defining the Customer Details Portlet

In this section, you will define a portlet that displays details about a particular customer.

  1. In your browser, on the SRDashboard.jspx page, click the Define link for the fifth portlet.

  2. On the Type tab, choose SQL, then click Next.

  3. On the Source tab, enter the following SQL statement:

    Example 8-8 SQL Statement for the Customer Details Portlet

    select * from USERS where USER_ID = '##Param1##')
    
  4. Set Param1 to the default value 320, then click Next.

  5. On the View tab, choose the HTML Layout and enter a title: Customer Details, then click Next.

  6. On the Layout tab, clear the fields.

  7. Choose Sortable Table from the Template drop-down list, and enter the following code in the Heading Section:

    <TABLE BORDER='0' WIDTH="100%">
    
  8. Replace the code in the Repeating Section with the following:

    <TR CLASS='PortletText1'>
    <TD CLASS='PortletHeading1'>ID</TD>
    <TD>##USER_ID##</TD>
    </TR>
    <TR CLASS='PortletText1'>
    <TD CLASS='PortletHeading1'>Email</TD>
    <TD>##EMAIL##</TD>
    </TR>
    <TR CLASS='PortletText1'>
    <TD CLASS='PortletHeading1'>First Name</TD>
    <TD>##FIRST_NAME##</TD>
    </TR>
    <TR CLASS='PortletText1'>
    <TD CLASS='PortletHeading1'>Last Name</TD>
    <TD>##LAST_NAME##</TD>
    </TR>
    <TR CLASS='PortletText1'>
    <TD CLASS='PortletHeading1'>Street</TD>
    <TD>##STREET_ADDRESS##</TD>
    </TR>
    <TR CLASS='PortletText1'>
    <TD CLASS='PortletHeading1'>City</TD>
    <TD>##CITY##</TD>
    </TR>
    <TR CLASS='PortletText1'>
    <TD CLASS='PortletHeading1'>State</TD>
    <TD>##STATE_PROVINCE##</TD>
    </TR>
    
  9. Replace the code in the Footer Section with the following:

    </tbody>
    </table>
    <font class=PortletText1>Total Rows: ##OP_ROWNUM##</font>
    
  10. Click Finish.

Step 11: Wiring the Page Content Together

The steps in this section show you how to add interactivity to the portlets you've just created. In this section, you will create a page parameter and portlet parameters, then wire the portlets together on the page.

  1. To create the page parameter, return to Oracle JDeveloper and open the file SRDashboardPageDef.xml.

  2. Create a page parameter called custID.

    To do so, in the Structure Pane, right-click Parameters, then insert a new page parameter with the following:

    <parameter id ="custID" value="$param.customerID)"/>

  3. Open the source for the SRDashboard.jspx page you created.

  4. Add a portlet parameter to the Customer Details portlet.

  5. For Param1 set the value to the page parameter value from the bindings.custID (set the default value to 320 so that at least a customer shows up and the page is activated and no customers are selected):

    <parameter name="Param1" value="${(bindings.custID == null || bindings.custID == '') ? 320 : bindings.custID }"/>
    
  6. Add a parameter for the Service Request Volume portlet so that the portlet is refreshed when the value is selected from the SelectOneChoice.

    In the Structure view, right-click parameters.

  7. Select Insert Inside Parameters, then select parameter.

  8. Set the value of Param1 to 360. By default we use 1 year or 360 days to show all the results.

  9. Select OmniPortlet3_1_Param1 within executables/variables of the page defs.

  10. In the Property Inspector, in the DefaultValue field, type the following:

    ${( app_management_SRDashboard.dayPicker.value == null) ? 360 : app_management_SRDashboard.dayPicker.value}
    
  11. In the Structure pane, choose the fifth portlet, the Most Active Customers portlet.

  12. In the Property Inspector, set the SubmitUrlParameters property to true. Doing so enables the portlet to submit the parameter through a URL to the page.

  13. Save your page.

  14. Run the SRDashboard.jspx page to your browser to view the portlets you just added.

Summary

The steps in this chapter showed you how to build a dashboard page for your WebCenter application. You learned how to create a page using customizable components and ADF Faces Core components to create the layout. You also learned how to create portlets that display related information and wire them together on a page, so that your end users can easily view information about their customers for a single entry point.