Returns: range-based (not absolute) index within the current range

/**
   * This method is for use with UI Table addRows buttons that require the
   * addition of multiple rows; given a RowIterator (such as a VO) and the
   * number of rows the caller needs to add, this method figures out where
   * the caller should start adding rows in order to comply with the BLAF
   * standard that newly added rows should go into the bottom of the current
   * table range (which is the same as the RowIterator range if things are
   * set up properly), pushing rows into the next range if necessary
   *
   * Returns: range-based (not absolute) index within the current range
   */
  public static int getStartIndexForMultiInsert(RowIterator rowIt, int numRowsToAdd)
  {
    int numRowsInRange = rowIt.getRowCountInRange();
    int rangeSize = rowIt.getRangeSize();
    int firstIndexAtWhichToAdd = 0;
    int numOpenSlotsInRange = (rangeSize - numRowsInRange);

    if (rowIt.getRangeSize() < rangeSize)
    {
      rowIt.setRangeSize(rangeSize);
    }

    if (numOpenSlotsInRange < numRowsToAdd)
    {
      firstIndexAtWhichToAdd = rangeSize - numRowsToAdd;
    }
    else
    {
      firstIndexAtWhichToAdd = numRowsInRange;
    }

    return firstIndexAtWhichToAdd;
  }

调用: 
 int indexForRowInserts = getStartIndexForMultiInsert(vo, 1);
  vo.insertRowAtRangeIndex(indexForRowInserts,row);
原文地址:https://www.cnblogs.com/huanghongbo/p/5274640.html