This discussion is archived
5 Replies Latest reply: Nov 21, 2012 6:20 AM by 862820 RSS

Create programatically a Pivot Table

santiago_nc Newbie
Currently Being Moderated
Hi

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);
    }
Thanks.
  • 1. Re: Create programatically a Pivot Table
    862820 Newbie
    Currently Being Moderated
    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.

    Thanks
    Sachin
  • 2. Re: Create programatically a Pivot Table
    santiago_nc Newbie
    Currently Being Moderated
    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
    862820 Newbie
    Currently Being Moderated
    Well,

    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"
    value="#{backingBeanScope.pivotTable.dataModel}"
    summary=" dummy pivot" emptyText="NO DATA"
    contentDelivery="immediate" var="cellData"
    varStatus="cellStatus"
    sizingManager="#{backingBeanScope.pivotTable.sizingManager}"
    styleClass="AFStretchWidth">



    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.

    Thanks
    Sachin
  • 4. Re: Create programatically a Pivot Table
    santiago_nc Newbie
    Currently Being Moderated
    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
    862820 Newbie
    Currently Being Moderated
    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.

    Sachin

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points