Forum Stats

  • 3,855,310 Users
  • 2,264,499 Discussions
  • 7,905,967 Comments

Discussions

Editing pivot table

Mo Koteiche
Mo Koteiche Member Posts: 46
edited Jan 20, 2014 9:37AM in JDeveloper and ADF

Hi guys,

Using Jdev 11.1.2.3,

I have a pivot table based on a programmatic VO (which is based on an Oracle View). In my VO, I have a transient attribute called Selection of type Boolean. It is represented by a checkbox in the pivot table.

A rough sketch of the table would be:

                 Circuit 1       Circuit 2     

Client 1      Number 1     Number 1

                 Number 2     Number 2

                 Selection     Selection

Client 2      Number 1     Number 1

                 Number 2     Number 2

                 Selection      Selection

The requirement is that the user should be able to select the blocks he wants, and then executes a business action that sends the corresponding Client and Circuit selected (it could be multiple ones)

My problem is that when I change the value of any of the Selection checkbox, nothing happens.

I tried some code I found on OTN, I put the following on my checkbox's valueChangeListener:

    public void onSelectChange(ValueChangeEvent event) {

UIPivotTable _pt = (UIPivotTable)event.getComponent().getParent().getParent();


DataCellIndex ci = (DataCellIndex)pt.getCellIndex();

DataModel dm = pt.getDataModel();
Object _rowKeys = null;
try {
// Get the rowkey
rowKeys = dm.getDataAccess().getValue(_ci.getRow(),_ci.getColumn(),DataMap.DATA_ROWKEY);
}
catch (Exception e) {
e.printStackTrace();
}

DataCellKey ck = (DataCellKey)pt.getCellKey();

QDR columnQDR = _ck.getColumnKey();

DCBindingContainer container = (DCBindingContainer)ADFContext.getCurrent().getRequestScope().get("bindings");
DCControlBinding b = container.findCtrlBinding("EmpView1");
ViewObject vo = b.getViewObject();
Row r = vo.getRow((Key)((List)_rowKeys).get(0));

r.setAttribute((String)columnQDR.getDimMember("DataLayer").getData(), event.getNewValue());

b.executeQuery();
}

This line returns null always.

rowKeys = dm.getDataAccess().getValue(_ci.getRow(),_ci.getColumn(),DataMap.DATA_ROWKEY);


I tried debugging and seeing what's happening, it was as if the index of the cell was wrong, but then at other times it wasn't the case which is very weird.

And it seems that this code works in versions before 11.1.2.0 (based on the post)

My questions are:

1- Is it possible to even edit a programmatic VO which is not based on a entity? (No Commit operation is required)

2- Am I complicating things? is there a better way of achieving what I want?

3- If not, what could be a workaround for this code?

Many thanks,

Mo

Answers

  • Frank Nimphius-Oracle
    Frank Nimphius-Oracle Member Posts: 29,689 Bronze Badge

    Hi,

    1- Is it possible to even edit a programmatic VO which is not based on a entity? (No Commit operation is required)

    No. Only views that are based on entities can be updated

    Frank

    Frank Nimphius-Oracle
  • Mo Koteiche
    Mo Koteiche Member Posts: 46

    Thank you for your input Frank,

    I managed to change my VO to an entity based one (I created a new entity based on the view in the database), and the following code executes properly:

        public void onOrigSelectChange(ValueChangeEvent event) {
            //UIPivotTable _pt = (UIPivotTable)event.getComponent().getParent().getParent();
                //I'm using the binding of my pivot Table. (pivotTable)
    
            DataCellIndex _ci = (DataCellIndex)pivotTable.getCellIndex();
    
            DataModel dm = pivotTable.getDataModel();
            Object _rowKeys = null;
            try {
            _rowKeys = dm.getDataAccess().getValue(_ci.getRow(),_ci.getColumn(),DataMap.DATA_ROWKEY);
            }
            catch (Exception e) {
            e.printStackTrace();
            }
            DataCellKey _ck = (DataCellKey)pivotTable.getCellKey();
    
            QDR rowQDR = _ck.getRowKey();
    
            DCIteratorBinding b = ADFUtils.findIterator("MagasinsPrepVIIterator");
            ViewObject vo = b.getViewObject();
            Row r = vo.getRow((Key)((List)_rowKeys).get(0));
    
            r.setAttribute((String)rowQDR.getDimMember("DataLayer").getData(), event.getNewValue());
            b.executeQuery();
        }
    

    Now the whole code executes, however when I go back to the page, the checkbox goes back to the original value, and the logs print the following:

    <BaseDataCell> <setData> Setting data not supported.

    I don't know if it's the problem Shay Shmeltzer highlighted in the following thread, but if it's so is there any workaround?

    Thank you for your time,

    Mo

This discussion has been closed.