Wednesday, February 27, 2013

Using insertRow Vs insertRowAtRangeIndex

Using insertRow Vs insertRowAtRangeIndex

Scenario 1

    OAViewObjectImpl pervo = getDataVO1();
    if(!pervo.isPreparedForExecution())
         pervo.executeQuery();
     Row prow = pervo.createRow();
     prow.setAttribute("field",fieldvalue);
     pervo.insertRowAtRangeIndex(0,prow);
     prow.setNewRowState(Row.STATUS_INITIALIZED);

Scenario 2
    OAViewObjectImpl pervo = getDataVO1();
    if(!pervo.isPreparedForExecution())
         pervo.executeQuery();
     Row prow = pervo.createRow();
     prow.setAttribute("field",fieldvalue);
     pervo.last();
     pervo.next();
     pervo.insertRow(prow);
     prow.setNewRowState(Row.STATUS_INITIALIZED);


If you use the first method, it will add a row to the first record of the current page. Whereas if you use the second method it will add to last record of the last page

if you use pervo.insertRowAtRangeIndex(pervo.getRowCount-1,prow); it will work when there is 1 page only, if it goes to second page it will throw error

No comments: