5 Replies Latest reply on Nov 21, 2012 2:20 PM by 862820

    Create programatically a Pivot Table


      I need to create a Pivot Table an runtime by Java Code, and I decided to use a managed bean.

      In this managed bean I create a object of the class UIPivotTable. Now I need assign the DataModel, but I don't find information about this.

      I suposse that I can use the DataModel or the PivotTableModel class, but I dont Know how.

      This is my code:
          public void newPivotTable(ActionEvent actionEvent) {
              // Add event code here...
              // Add event code here...
              UIComponent pgl2 = Utils.getComponent("pgl2");
              UIPivotTable ui = new UIPivotTable();
              PivotTableModel ptm = null;
              String str = new String();
              ui.createDataModel(ptm, str); //????
              Utils.addComponent(pgl2, ui);
        • 1. Re: Create programatically a Pivot Table
          There are enough source code present at - http://www.oracle.com/technetwork/developer-tools/adf/downloads/index.html

          I was able to create a pivot with Managed bean, looking at any of the sample code.

          • 2. Re: Create programatically a Pivot Table
            Sorry, but I think that your answer is not helpful.
            You could post that I could get some of examples in google.com too.

            My question is how can I create a pivot table programatically and I didn't find nothing about it.
            • 3. Re: Create programatically a Pivot Table

              That is exactly what I said, for a programmatic (managed bean driven pivot), there are tons of example with source code on that link.

              To make it simple this is what I can have it from my code -

              <dvt:pivotTable binding="#{backingBeanScope.pivotTable.pt1}" id="pt1"
              summary=" dummy pivot" emptyText="NO DATA"
              contentDelivery="immediate" var="cellData"

              Pivot table bean has a method -

              public DataModel getDataModel() {

              if (_dataModel == null) {
              _dataModel = new PivotTableSampleModel(type);
              //System.out.println(" Finally data model " + _dataModel);
              return _dataModel;

              PivotTableSampleModel is what I build based on the type (defined in my class) to change the data for the pivot.

              It extends PivotTableModel class and returns an array of rowset for the data model.

              • 4. Re: Create programatically a Pivot Table
                Thanks a lot.

                My real problem is I dont know the structure for the PivotTableModel.

                I am new in ADF development and now I am doing tutorials, but I don't find any where the DataModel is created programatically. At present I resolve all with the drag & drop operations.

                By the way, about the link, do you refer to documentation tab ?
                • 5. Re: Create programatically a Pivot Table
                  The download tab, you need to accept the license agreement. Once you download, there is a war file, which has the source code. See if that helps you.