码迷,mamicode.com
首页 > 其他好文 > 详细

向多页TABLE中插入数据时,新增行总是在当前页的最后一行

时间:2016-02-16 11:28:23      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

CODE IN CO

OATableBean table = 
                (OATableBean)webBean.findChildRecursive("LineTable");
            int numOfRowsDisplay = table.getNumberOfRowsDisplayed();
            Serializable[] param01 = { new Number(numOfRowsDisplay) };
            Class[] classType = new Class[] { Number.class, };
            am.invokeMethod("addPlanLines", param01, classType);

CODE IN AM

public void addPlanLines(Number numOfDisplay) {
        OADBTransaction tsn = this.getOADBTransaction();

        CuxPosAuditPlanLinesFullVOImpl lineVO = 
            getCuxPosAuditPlanLinesFullVO();
        Number planId = getPlanId();

        lineVO.setMaxFetchSize(0);
        if (!lineVO.isPreparedForExecution()) {
            lineVO.setWhereClause(null);
            lineVO.executeQuery();
        }

        RowSet localRowSet = lineVO.getRowSet();

        int i = 1;
        int j = numOfDisplay.intValue();
        int rangeStart = localRowSet.getRangeStart();
        int rangeSize = localRowSet.getRangeSize();
        int rowCountInRange = localRowSet.getRowCountInRange();
        int i1;
        if (rowCountInRange + i <= j)
            i1 = rowCountInRange;
        else {
            i1 = j - i;
        }
        CuxPosAuditPlanLinesFullVORowImpl row = 
            (CuxPosAuditPlanLinesFullVORowImpl)lineVO.createRow();
        if (rangeSize < i1) {
            rangeSize++;
            localRowSet.setRangeSize(rangeSize);
            localRowSet.setRangeStart(rangeStart);
        }

        row.setPlanId(planId);
        Number pk = getSequenceValue("CUX_POS_AUDIT_PLAN_LINES_S");
        row.setLineId(pk);
        row.setOrgId(new Number(tsn.getOrgId()));
        row.setOrgName(getOrgName(tsn.getOrgId()));
        localRowSet.insertRowAtRangeIndex(i1, row);
        localRowSet.setCurrentRowAtRangeIndex(i1);
    }

 


方法二:

这种方法有点小问题:

仅仅在第一页有效,应该可以再修改修改,懒得改了

calculVO.insertRow(row);   
 int fetched = calculVO.getFetchedRowCount();
 fetched = fetched > 9 ? 9 : fetched;
 if (fetched > 0)
 {
   int current = fetched % 10;
   if (current == 0)
   {
     fetched = 9;
   } else
   {
     fetched = current > 9 ? 9 : current;
   }
 }
 calculVO.insertRowAtRangeIndex(fetched, row);

 

向多页TABLE中插入数据时,新增行总是在当前页的最后一行

标签:

原文地址:http://www.cnblogs.com/huanghongbo/p/5192006.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!