1 Reply Latest reply: Nov 8, 2012 9:16 AM by santiago_nc RSS

    Dynamic Pivot Table programatically


      I need add to a JSF Page a Pivot Table from a Temporary Table wich I will fill in a Procedure PL/SQL (in the last version, now I put a sample data) and I could select the Alias Name for each column. (It's possible that I dont need show all columns in the pivot table, then I need hide or remove them)

      I have tried this:

      - First, I have added the Entity Object for the Temporary Table into the Model.

      - Create a view Object for the previous Entity Object.


      - Create a JSF Page with two regions (Top and Down)

      - In the down region I drag and drop the view objet how a Pivot Table and I create the "Dummy" Pivot table, because I'll need modify it.

      - In the top region I drag a Button. In the action I create a new backing bean with a method refresh. In this method I search for the Pivot Table. After that I could modify

      Now I have the next problem. I don't Know How I can modify the structure of the Pivot Table.

      In the file PivotTablePageDef.xml is located the parameters of my Pivot Table after use the wizard, but in the properties of "*pt*" object, I don't find nothing to set this.

      Backing Bean Code:
      package view.backing;
      import java.util.Iterator;
      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import oracle.adf.view.faces.bi.component.pivotTable.HeaderCellSelectionSet;
      import oracle.adf.view.faces.bi.component.pivotTable.UIPivotTable;
      import oracle.adf.view.faces.bi.model.PivotTableModel;
      import oracle.adf.view.faces.bi.model.DataModel;
      import view.utils.*;
      public class ChangePivotTable {
          public ChangePivotTable() {
          public String refresh() {
              // Add event code here...
              UIComponent uiPT = Utils.getComponent("MyPivotTable");            
              UIPivotTable pt = (UIPivotTable)uiPT;
              PivotTableModel ptm = new PivotTableModel();
              return null;
      The table:
        ROWNUM     NUMBER,
        C1               VARCHAR2(4000 BYTE),
        C2               VARCHAR2(4000 BYTE),
        C3               VARCHAR2(4000 BYTE),
        C4               VARCHAR2(4000 BYTE),
        C5               VARCHAR2(4000 BYTE),
        C6               VARCHAR2(4000 BYTE),
        C7               VARCHAR2(4000 BYTE),
        C8               VARCHAR2(4000 BYTE),
        C9               NUMBER,
        N1               NUMBER,
        N2               NUMBER,
        N3               NUMBER,
        N4               NUMBER,
        N5               NUMBER,
        N6               NUMBER,
        N7               NUMBER,
        N8               NUMBER,
        N9               NUMBER,
      P.S.: In http://www.packtpub.com/sites/default/files/downloads/4828EN_Appendix_More_on_ADF_Business_Components_and_Fusion_Page_Runtime.pdf I rode about the dynamic Views Object and use it in the UI with the <af:each> of <af:table>.

      Is possible use this for the <dvt:pivotable>?

      PS. Sorry for my English.

      Edited by: user12855703 on 07-nov-2012 7:07

      Edited by: user12855703 on 08-nov-2012 7:43
        • 1. Re: Dynamic Pivot Table at Runtime
          Now I'm trying create a new Pivot Table programmatically. Is this possible?

          My current code:
              public String newPivotTable() {
                  // Add event code here...
                  UIComponent pgl2 = Utils.getComponent("pgl2");
                  UIPivotTable ui = new UIPivotTable();
                  PivotTableModel ptm = null;
                  ui.createDataModel(ptm, arg1); //Here
                  Utils.addComponent(pgl2, ui);
                  return null;
          I think the key is in the method: ui.createDataModel(ptm, arg1);
          But my problem is: I don't know how create a DataModel and I have no idea wich is the second parameter.

          At present, I can't find documentation or examples for that.

          This will be my homeworks for today. Any advance I get, it will post here.