Part 2: Starting Using Graphic Components
In this section, you start adding a basic Bar chart based on warehouse information to the OrdersAndStocks page, then you enhance the bar chart characteristics with more sophisticated rendering.
show more or lessRead more...

Also, you use a gauge component to represent the quantity in stock and finally you add an Export to Excel functionality.

Step 1: Create a Basic Bar Chart in the Page

Based on the view WarehouseStockLevelsView, you add a bar chart to the MDOrders tab in the OrdersAndStocks page to render, for each product of a given order, the corresponding stock level in each warehouse location. The WarehouseStockLevelsView view is linked to the OrderItemsView via the productId attribute.
  1. Back to JDeveloper, expand the Model | Application Sources | oracle.fod.model and double click the WarehouseStockLevelsView view to open it in the editor.

    Model project in the Application Navigator
  2. In the editor click the Query tab, to display the SQL statement. Notice that the view returns the following columns: WAREHOUSE_ID, WAREHOUSE_NAME, PRODUCT_ID, and QUANTITY_ON_HAND, for any warehouse in the US that has the product.


    The WarehouseStockLevelsView query statement
  3. In the editor window, click the OrdersAndStocks.jsf tab to display the page.

    OrdersAndStocks page
  4. In the Data Controls panel, expand the OrdersView1 | OrderItemsView2 nodes. Select the WarehouseStockLevelsView1 node and drop it in the Structure pane within the showDetailItem - MDOrders.

    The Structure Pane
  5. From the Create context menu, select Graph option.

    context menu with the Graph option selected.
  6. In the Component Gallery dialog, select the Bar one as the Category and the Bar as the Graph Type. Notice that the Quick Start Layout offers various layout in each category. Leave the default quick layout selected.

    The Component Gallery

    Click OK.

  7. In the Create Bar Graph dialog, deselect Include Child Accessors if necessary, and then specify the following values:
    - Bars : click Add Add icon and select QuantityOnHand from the Available list.
    - X Axis: click Add Add icon and select WarehouseId from the drop down list.
    - X Axis: click Add Add icon and select City from the drop down list.
    Notice that you can also use drag and drop technique by selecting one component in the available list and dropping it into the Bars or X Axis fields.

    In the Attribute Labels section:

    Attribute Label
    QuantityOnHand Quantity (type the value)
    WarehouseId WarehouseName ( from the drop down list)
    City City ( from the drop down list)
    The Create Bar Graph dialog

    Click the Swap Bars button and then the Preview tab.

    the Create Bar Graph dialog
  8. After connecting to the database a Bar chart preview displays.

    The Graph Preview

    Click OK.

  9. In the Property Inspector for the dvt:barGraph component, in the Appearance node, set the 3D Effect property to true.

    The Property Inspector
  10. In the Image area, set the ImageFormat to Flash.

     Property Inspector
  11. In the Behavior node, next to the PartialTriggers field, select the Edit option.

     Property Inspector
  12. In the Edit Property dialog, shuttle table* - OrdItem to the right. This allows the Graph to become synchronized with the currently selected order item row.

    The Edit Property dialog

    Keep the window open.

  13. Expand the panelFormLayout | facet | panelGroupLayout nodes and shuttle all four commandButtons to the right, so that the Graph is also synchronized when you click a navigation control.

    The Edit Property dialog

    Click OK.

  14. The Partial Triggers property looks now like this:

    The Property pane
  15. Save your work, then right-click within the page and select Run from context.

    The Run option from context menu
  16. The page loads up in the Browser. Notice that for each bar, the legend on the right hand side displays the warehouse name and the city. Each bar is associated to a different color. Move the mouse over each bar to see the tooltip label (the warehouse name, city and quantity).

    The page running
  17. Select another row in the detail table to test the bar chart synchronization process.

    Page displayed in the browser
  18. Click the Next button to test the synchronization of the bar chart when changing order.

    Page displayed in the browser
  19. Close the browser window.

Step 2: Refine the Basic Bar Chart

In this section you enhance the bar chart by adding some animation features.

  1. Back to JDeveloper, select the dvt:barGraph component in the Structure pane, and in the Appearance section of the Property Inspector, set the SeriesEffect to SE_GRADIENT and SeriesRolloverBehavior to RB_HIGHLIGHT.

    The Structure pane
    Using the Find field to easily retrieve a property. Show more or lessRead more... To find a specific property in the Property pane, start typing a string corresponding to the name of the property. As you type in, the first corresponding string is retrieved and highlighted. Click the Find next / Find previous buttons to navigate through the matching properties.

    The Property Inspector
  2. In the Appearance | Animation section, set the AnimationOnDataChange to Auto, AnimationDuration to 3000 and AnimationOnDisplay to Auto.

    Property Inspector

    About animation parameters. Show more or lessRead more...

    If animationOnDisplay is auto, then the graph will animate when it is first displayed on the page.

    If AnimationOnDataChange is auto, then the graph will animate every time the data changes, which will also happen when you click on a row in the table.

    .

    AnimationDuration indicates the duration for the animation in milliseconds.
  3. In the Structure pane, expand the dvt:barGraph, select the dvt:legend Area. Then in the Property Inspector, set the Rendered property to Default (TRUE) and the AutomaticPlacement to AP_NEVER.

    Property Inspector
  4. Save you work and click the Run button Run icon to run the page (alternatively right-click within the page and select Run from context).

  5. The page displays in your browser window. Notice the animation of the bars until reaching the final value position.

    The bar chart in the browser

    The bar chart in the browser
  6. Move the mouse over a bar, notice the other bars appearing shadowed.

    The bar chart in the browser
  7. Select a different bar to change the highlighting process. Notice that the legend on the right hand side is also highlighted accordingly.

    The bar chart in the browser
  8. Click another row in the detail table to visualize what the stocks are for this new item. Again, notice the graph's data changes as the line item changes.

    The bar chart in the browser
  9. Click the Next button to change to a different order. The synchroziation continues.

    The bar chart in the browser

  10. You can also experiment highlighting a bar by selecting a warehouse name in the legend section.

    The bar chart in the browser
  11. Close the browser window.

Step 3: Display Stock Levels Using a Gauge

Based on the view WarehouseStockLevelsView, you add a Gauge graph reflecting the stock level in each warehouse

  1. Back in JDeveloper, on the OrdersAndStocks.jsf page in the editor window, right-click within the MDOrders tab and from context select Insert after Show Detail Item --> Show Detail Item.

    Context menu
  2. In the Property Inspector, using the Common node, set the Text to StockLevels.

    Property Inspector
  3. Click the StockLevels tab, then open the Data Controls accordion and select FODModuleDataControl | OrdersView1 | OrderItemsView2 | WarehouseStockLevelsView1. Drop it onto the StockLevels pane and select Table --> ADF Read-only Table.

    Dropping a Data Control onto the page
  4. In the Edit Table Column dialog, select Single Row and Enable Sorting check boxes. Delete the following attributes: WarehouseId, Address1, PostalCode.

    The Edit Table Columns dialog

    Click OK.

  5. In the Property Inspector, for the table component, in the Style group, using the Layout tab Layout Icon , set the width to 600 pixels and the Height to auto.

    The Property Inspector
  6. Using the Behavior group, click the down arrow next to the Partial Triggers field and select Edit.

    The Property Inspector
  7. In the Edit Property dialog, shuttle table* - OrdItem in the Selected pane.

    The Edit Property dialog

    Click OK.

    Using meaningful ids. Show more or lessRead more...

    This is why you changed the default naming to a more meaningful one, allowing you to retrieve it easily,based on naming conventions you may adopt for your projects.
  8. In the Component Palette, select the from the ADF Data Visualizations | Gauge library, select the Gauge component and drop it onto the QuantityOnHand column.

    Dropping a gauge onto the page design
  9. In the Create Gauge dialog, choose the Status Meter category and select the Horizontal Status Meter with Thresholds.

    The Create Gauge dialog

    Click OK.

  10. In the Structure pane, right click the outputText #{row.QuantityOnHand} and delete it.

    Property Inspector
  11. In the Structure pane, select the dvt:gauge component and in the Property Inspector, for the Common group set the Gauge type to STATUSMETER. Next to the Value field select Expression Builder from the list.

    The Property Inspector
  12. In the Expression Builder dialog, expand the JSP Objects | Row and double click QuantityOnHand to populate the Expression pane.

    The Expression Builder dialog

    Click OK.

  13. Still in the gauge component, within the Gauge Data group, type 0 for the MinValue and 1000 to the MaxValue assuming for our simple example that no stock level is ever greater that 1000 for a single product in a warehouse.

    Structure pane and Property Inspector
  14. Within the Style group, type 100 Percent for the Width and 80 Pixels for the Height.

    The Property Inspector
  15. Select the af:column above the Gauge component in the Structure pane and in the Property Inspector, for the Appearance group set the Width to 200.

    Structure pane and Property Inspector
  16. In the Structure pane expand the dvt:gauge | dvt:thresholdSet component.

    The Structure pane
    The thresholdset entry was created when choosing the Gauge type. Show more or lessRead more...

    Notice that 3 thresholds exist inside the Threshold Set..

    In the next few steps, you use the thresholds for the gauge, allowing you to specify in our example minimum and maximum stock level indicators.

  17. Select the first Threshold component in the Structure pane. In the Property inspector set the id field to t00, the ThresholdMaxValue to 30, and type mini for the Text.

    The Property Inspector
    30 corresponds to the minimum stock level alert you want to set for your products.
  18. Select the second Threshold component in the Structure pane. In the Property inspector set the id field to t01, and type maxi for the Text.

    The Property Inspector
    700 corresponds to the optimum stock level you want to set for your products.
  19. Select the the third Threshold component in the Structure pane. In the Property inspector leave the ThresholdMaxValue empty, and set the id field to t02.

    The Structure pane and the Property Inspector
  20. In the Structure pane right-click the tickLabel component, and select Insert inside dvt:tickLabel --> Number Format from context.

    Context menu from the Structure pane
  21. In the Property Inspector, for the Number Format tag, using the Scale group, set the ScaleFactor property to SCALEFACTOR_NONE.

    The Property Inspector
  22. In the Structure pane select the metricLabel component. Set the Position property to LP_INSIDE_GAUGE_RIGHT.

    The Structure pane and the Property Inspector
  23. In the Structure pane right click the metricLabel component, and select Insert inside dvt:metricLabel --> Number Format from context.

    Context menu from the Structure pane
  24. In the Property Inspector, for the Number Format tag, using the Scale group, set the ScaleFactor property to SCALEFACTOR_NONE.

    The Property Inspector
  25. The Page should look like this:

    The page in the Design editor
  26. Save your work and click the Run button Run icon to run the Page.

  27. Click the StockLevels tab to display the corresponding stock levels with the Gauge.

    The Page running in the Browser
    The stock level gauge shows how a product is doing in a warehouse regarding to the minimum and maximum alert levels.Show more or lessRead more...

    The stock levels are related to the product selected in the Master Detail form.
  28. Move your mouse over a gauge to display the corresponding quantity.

    The Page running in the Browser
  29. You can experiment switching back to the MDOrders tab to select a different order and then click the StockLevels tab to display the new gauge values.

  30. Close your Browser window.

Step 4: Add an 'Export to Excel' functionality

You add a button to your page that exports displayed data into an Excel type file.

  1. Back to the OrdersAndStocks page, add a Button and drop it onto the StockLevels component in the Structure pane.

    The Structure pane and the Component Palette
  2. In the Property Inspector Text field, type Export to Excel.

    The Property Inspector
  3. From the Component Palette in the Operations library, drag and drop an Export Collection Action Listener component onto the Export to Excel button in the Structure pane.

    The Structure pane and the Component Palette
  4. In the Insert Export Collection Action Listener dialog, next to the ExportedId field, select Edit from dropdown.

    The Insert Export Collection Action Listener dialog
  5. In the Edit Property, select table* - t1.

    The Edit Property

    Click OK.

  6. Back in the Insert Export Collection Action Listener dialog, the excelHTML should be defaulted as the type.

    The Insert Export Collection Action Listener dialog

    Click OK.

  7. In the Property Inspector, specify MyExcelData.xls as the filename and Excel Exported Data as the title.

    The Property Inspector
  8. Click Save All Save All icon icon on the JDeveloper menu bar, or select File | Save All.

  9. Click the Run button Run icon to run the page.

  10. The OrdersAndStocks page opens up in the browser, click the StockLevels tab.

    The Page in the browser
  11. Click the Export to Excel button.

    Displaying the gauge

    If you get a warning message about downloading files, right-click and select Download File to accept the operation.

    Displaying the gauge
  12. On the File Download dialog, click Save to save the file locally. (We are covering the save scenario, but you could also open the file.)

    The file download dialog
  13. In the Save As dialog, choose a directory to save your file (i.e. temp). Notice that the File Name is already populated from the values specified in the Action Listener to Excel operation.

    The Save As dialog

    Click Save.

  14. In the Download Complete dialog, click Open Folder.

    The Download Complete dialog
  15. In the opened folder, double-clik MyExcelData.xls to open the excel file.

    The Opened folder
  16. If you get an information dialog about a different format, click Yes to accept Excel to open it.

    Excel Information dialog
  17. The worksheet displays the warehouse stock levels, allowing you to work in an Excel environment.

    Worksheet in Excel
  18. Close your Excel window.

  19. Close your browser window.

Bookmark Print Expand all | Hide all
Back to top
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.