档案分页实现

1.ListEditor.java

package nc.ui.cjkcmg.cjyxdk.ace.view;

import nc.ui.bd.pub.view.BDBatchBillTable;
import nc.ui.pub.bill.BillEditEvent;


public class ListEditor extends BDBatchBillTable {

  private static final long serialVersionUID = -142763374250987142L;

  @Override
  public boolean beforeEdit(BillEditEvent e) {
    return super.beforeEdit(e);

  }

  @Override
  public void initUI() {
    super.initUI();
//    this.getBillCardPanel().setBodyMultiSelect(true);
  }

  @Override
  protected void doAfterEdit(BillEditEvent e) {
    super.doAfterEdit(e);
  }

  @Override
  protected void renderTable() {
  }

}

2.ListSplitPanel.java

package nc.ui.cjkcmg.cjyxdk.ace.view;

import nc.ui.bd.pub.SplitePanelWithLocation;
import nc.ui.uif2.AppEvent;
import nc.ui.uif2.AppEventListener;
import nc.ui.uif2.components.AutoShowUpEventSource;
import nc.ui.uif2.components.IAutoShowUpComponent;
import nc.ui.uif2.components.IAutoShowUpEventListener;
import nc.ui.uif2.components.ITabbedPaneAwareComponent;
import nc.ui.uif2.components.ITabbedPaneAwareComponentListener;
import nc.ui.uif2.components.TabbedPaneAwareCompnonetDelegate;
import nc.ui.uif2.model.BatchBillTableModel;

/**
 * 列表分页控件
 * 
 */
public class ListSplitPanel extends SplitePanelWithLocation implements IAutoShowUpComponent,
        ITabbedPaneAwareComponent, AppEventListener {

    private static final long serialVersionUID = -7861961191556958739L;

    private IAutoShowUpComponent autoShowUpComponent;

    private BatchBillTableModel model = null;

    private ITabbedPaneAwareComponent tabbedPaneAwareComponent;

    public ListSplitPanel() {
        super();
        this.autoShowUpComponent = new AutoShowUpEventSource(this);
        this.tabbedPaneAwareComponent = new TabbedPaneAwareCompnonetDelegate();
    }

    @Override
    public void addTabbedPaneAwareComponentListener(ITabbedPaneAwareComponentListener l) {
        this.tabbedPaneAwareComponent.addTabbedPaneAwareComponentListener(l);
    }

    @Override
    public boolean canBeHidden() {
        return this.tabbedPaneAwareComponent.canBeHidden();
    }

    public BatchBillTableModel getModel() {
        return this.model;
    }

    @Override
    public void handleEvent(AppEvent event) {
        this.showMeUp();
    }

    @Override
    public boolean isComponentVisible() {
        return this.tabbedPaneAwareComponent.isComponentVisible();
    }

    @Override
    public void setAutoShowUpEventListener(IAutoShowUpEventListener l) {
        this.autoShowUpComponent.setAutoShowUpEventListener(l);
    }

    @Override
    public void setComponentVisible(boolean visible) {
        this.tabbedPaneAwareComponent.setComponentVisible(visible);
    }

    public void setModel(BatchBillTableModel model) {
        this.model = model;
        model.addAppEventListener(this);
    }

    @Override
    public void showMeUp() {
        this.autoShowUpComponent.showMeUp();
    }

}


3.ListModelDataManager.java

package nc.ui.cjkcmg.cjyxdk.model;



import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.ArrayUtils;


import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.itf.cjkcmg.ICjyxdkMaintain;
import nc.ui.bd.pub.BillBatchPaginationDelegator;
import nc.ui.pubapp.uif2app.query2.model.IModelDataManager;
import nc.ui.querytemplate.filter.IFilter;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.ui.uif2.components.pagination.IPaginationModelListener;
import nc.ui.uif2.components.pagination.PaginationModel;
import nc.ui.uif2.model.AbstractBatchAppModel;
import nc.ui.uif2.model.ModelDataDescriptor;
import nc.vo.cjkcmg.cjyxdk.Cjyxdk;

public class ListModelDataManager implements IModelDataManager,
    IPaginationModelListener {

  private BillBatchPaginationDelegator delegator;

  private AbstractBatchAppModel model;

  private PaginationModel paginationModel;

  private IQueryScheme queryScheme;

  public BillBatchPaginationDelegator getDelegator() {
    return this.delegator;
  }

  public AbstractBatchAppModel getModel() {
    return this.model;
  }

  public PaginationModel getPaginationModel() {
    return this.paginationModel;
  }

  public IQueryScheme getQueryScheme() {
    return this.queryScheme;
  }

  @Override
  public void initModel() {
    this.model.initModel(null, new ModelDataDescriptor());
  }

  @Override
  public void initModelByQueryScheme(IQueryScheme scheme) {
    this.setQueryScheme(scheme);

    Map<String, String> conds = this.getCondMap(scheme);
    try {
      List<String> pkList = new ArrayList<String>();
      Cjyxdk[] vos = this.getService().query(scheme);
      for (int i = 0; i < vos.length; i++) {
    	  Cjyxdk CpyclfzsxVO = vos[i];
		pkList.add(CpyclfzsxVO.getPk_yxdk());
	}
      this.getPaginationModel().setObjectPks(
          pkList.toArray(new String[pkList.size()]), new ModelDataDescriptor());
    }
    catch (Exception ex) {
      Logger.error(ex.getMessage(), ex);
    }
  }

  @Override
  public void onDataReady() {
    this.getDelegator().onDataReady();

  }

  @Override
  public void onStructChanged() {
  }

  @Override
  public void refresh() {
    this.initModelByQueryScheme(this.queryScheme);
  }

  public void setDelegator(BillBatchPaginationDelegator delegator) {
    this.delegator = delegator;
  }

  public void setModel(AbstractBatchAppModel model) {
    this.model = model;
  }

  public void setPaginationModel(PaginationModel paginationModel) {
    this.paginationModel = paginationModel;
    this.paginationModel.addPaginationModelListener(this);
  }

  public void setQueryScheme(IQueryScheme queryScheme) {
    this.queryScheme = queryScheme;
  }

  private Map<String, String> getCondMap(IQueryScheme scheme) {
    if (scheme == null) {
      return null;
    }

    IFilter[] filters = (IFilter[]) scheme.get("filters");
    if (ArrayUtils.isEmpty(filters)) {
      return null;
    }

    Map<String, String> conds = new HashMap<String, String>();
    for (IFilter filter : filters) {
      if (filter == null) {
        continue;
      }
      conds.put(filter.getFilterMeta().getFieldCode(), filter.getSqlString());
    }

    return conds;
  }

  private ICjyxdkMaintain getService() {
    return NCLocator.getInstance().lookup(ICjyxdkMaintain.class);
  }

}


4.ListModelService.java

package nc.ui.cjkcmg.cjyxdk.model;



import org.apache.commons.lang.ArrayUtils;

import nc.bs.framework.common.NCLocator;
import nc.itf.cjkcmg.ICjyxdkMaintain;

import nc.ui.uif2.components.pagination.IPaginationQueryService;
import nc.ui.uif2.model.IBatchAppModelService;
import nc.vo.bd.meta.BatchOperateVO;
import nc.vo.cjkcmg.cjyxdk.Cjyxdk;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.uif2.LoginContext;

public class ListModelService implements IBatchAppModelService, IPaginationQueryService {

    @Override
    public BatchOperateVO batchSave(BatchOperateVO batchVO) throws Exception {
    	BatchOperateVO batchSave = getService().batchSave(batchVO);
        return batchSave;
    }

    @Override
    public Object[] queryByDataVisibilitySetting(LoginContext context) throws Exception {
        return null;
    }

    @Override
    public Object[] queryObjectByPks(String[] pks) throws BusinessException {
    	Cjyxdk[] vos = null;
        try {
            if (ArrayUtils.isEmpty(pks)) {
                return null;
            }
            vos = this.getService().queryDataByPks(pks);
            return vos;
        }
        catch (Exception ex) {
            ExceptionUtils.wrappException(ex);
        }

        return null;
    }

    private ICjyxdkMaintain getService() {
        return NCLocator.getInstance().lookup(ICjyxdkMaintain.class);
    }

}

5.ICjyxdkMaintain.java

package nc.itf.cjkcmg;

import nc.bs.dao.DAOException;
import nc.itf.pubapp.pub.smart.ISmartService;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.cjkcmg.cjyxdk.Cjyxdk;
import nc.vo.pub.BusinessException;

public interface ICjyxdkMaintain extends ISmartService{

	 public Cjyxdk[] query(IQueryScheme queryScheme)
      throws BusinessException, Exception;
	 
	 public Cjyxdk[] queryDataByPks(String[] pks) throws DAOException;
}

6.CjyxdkMaintainImpl.java

package nc.impl.cjkcmg;

import java.util.List;

import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.impl.pub.ace.AceCjyxdkPubServiceImpl;
import nc.impl.pubapp.pattern.database.IDQueryBuilder;
import nc.impl.pubapp.pub.smart.BatchSaveAction;
import nc.itf.cjkcmg.ICjyxdkMaintain;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.bd.meta.BatchOperateVO;
import nc.vo.cjkcmg.cjyxdk.Cjyxdk;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.pub.SqlBuilder;

public class CjyxdkMaintainImpl extends AceCjyxdkPubServiceImpl
		implements ICjyxdkMaintain {

	@Override
	public Cjyxdk[] query(IQueryScheme queryScheme) throws BusinessException {
		return super.pubquerybasedoc(queryScheme);
	}

	@Override
	public BatchOperateVO batchSave(BatchOperateVO batchVO) throws BusinessException {
		BatchSaveAction<Cjyxdk> saveAction = new BatchSaveAction<Cjyxdk>();
		BatchOperateVO retData = saveAction.batchSave(batchVO);
		return retData;
	}

	@Override
	public Cjyxdk[] queryDataByPks(String[] pks) throws DAOException {
		// TODO 自动生成的方法存根
		SqlBuilder sqlBuilder = new SqlBuilder();
		sqlBuilder.append("select * from cj_yxdk where dr = 0 ");
		sqlBuilder.append(new IDQueryBuilder().buildSQL(" and pk_yxdk ", pks));
		@SuppressWarnings("unchecked")
		List<Cjyxdk> list = (List<Cjyxdk>) getDao().executeQuery(sqlBuilder.toString(), new BeanListProcessor(Cjyxdk.class));
		return list == null || list.size() == 0 ? null:list.toArray(new Cjyxdk[0]);
	}
	
	private BaseDAO dao;
	private BaseDAO getDao(){
		if(dao == null){
			dao = new BaseDAO();
		}
		return dao;
	}
}

7.Cjyxdk_config.xml



DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

	
	<bean id="context" class="nc.vo.uif2.LoginContext">bean>

	

	
	
	<bean id="batchModelModelService" class="nc.ui.cjkcmg.cjyxdk.model.ListModelService">
		
	bean>
	
	
	<bean id="BOAdapterFactory" class="nc.vo.bd.meta.GeneralBDObjectAdapterFactory">
		<property name="mode" value="MD"/>
	bean>

   
	

	
	
	<bean id="batchModel" class="nc.ui.pubapp.uif2app.model.BatchBillTableModel">
		<property name="context"><ref bean="context"/>property>
		<property name="service"><ref bean="batchModelModelService" />property>
		<property name="businessObjectAdapterFactory"><ref bean="BOAdapterFactory"/>property>
	bean>

	
	
	
	<bean id="batchModelModelDataManager" class="nc.ui.cjkcmg.cjyxdk.model.ListModelDataManager">
		<property name="model"><ref bean="batchModel"/>property>
		
		<property name="paginationModel" ref="paginationModel" />
		<property name="delegator" ref="paginationDelegator" />

	bean>

	
	


    

	


	
	<bean id="templateContainer" class="nc.ui.pubapp.uif2app.view.TemplateContainer"  init-method="load">
		<property name="context" ref="context"/>
		<property name="nodeKeies">
			<list>
				<value>btvalue>
			list>
		property>
	bean>


	
	
	<bean id="viewa" class="nc.ui.pubapp.uif2app.view.OrgPanel" init-method="initUI">
		<property name="model"><ref bean="batchModel" />property>
		<property name="dataManager" ref="batchModelModelDataManager" />
	bean>



	
	
	<bean id="batchBillTable" class="nc.ui.cjkcmg.cjyxdk.ace.view.ListEditor" init-method="initUI">
		<property name="model"><ref bean="batchModel" />property>
		<property name="nodekey" value="bt" />
	bean>

	
	
	<bean id="container" class="nc.ui.uif2.TangramContainer" init-method="initUI">
		<property name="tangramLayoutRoot">
					<bean class="nc.ui.uif2.tangramlayout.node.VSNode">
				<property name="up">
					<bean class="nc.ui.uif2.tangramlayout.node.CNode">
						<property name="component">
							<ref bean="viewa" />
						property>
					bean>
				property>
				<property name="down">
					<bean class="nc.ui.uif2.tangramlayout.node.CNode">
						<property name="component">
							
							<ref bean="listContainerWithPaginationBar" />
						property>
					bean>
				property>
				<property name="dividerLocation" value="74.0f" />
				<property name="name" value="" />
			bean>

		property>
		<property name="actions">
			<list>
				
				<ref bean="queryAction" />
				<ref bean="dkAction" />

			list>
		property>
		
		<property name="editActions">
			<list>
				<ref bean="batchSaveAction" />
				<ref bean="batchCancelAction" />
				<ref bean="batchAddLineActiona" />
				<ref bean="batchDelLineActiona" />
				
			list>
		property>
		<property name="model" ref="batchModel" />	
		
	bean>
	
	
	<bean id="InitDataListener" class="nc.ui.pubapp.uif2app.model.DefaultFuncNodeInitDataListener">
		<property name="model" ref="batchModel"/>
		<property name="context" ref="context">property>
		<property name="voClassName" value="nc.vo.cjkcmg.cjyxdk.Cjyxdk"/>
	bean>



	


	
	<bean id="batchModelEventMediator" class="nc.ui.pubapp.uif2app.model.AppEventHandlerMediator">
		<property name="model" ref="batchModel" />
		<property name="handlerGroup">
			<list>
				
			    <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup">
			     <property name="event" value="nc.ui.pubapp.uif2app.event.card.CardBodyBeforeEditEvent"/>
			     <property name="handler">
			      <bean class="nc.ui.cjkcmg.cjyxdk.ace.handler.CjyxdkBeforeEditHandler"/>
			     property>
			    bean>  
			    
			    <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup">
			     <property name="event" value="nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent"/>
			     <property name="handler">
			      <bean class="nc.ui.cjkcmg.cjyxdk.ace.handler.CjyxdkAfterEditHandler"/>
			     property>
			    bean> 
			list>
		property>
	bean>

	





	
	
	<bean id="batchEditAction" class="nc.ui.pubapp.uif2app.actions.batch.BatchEditAction">
		<property name="model"><ref bean="batchModel"/>property>
		<property name="exceptionHandler"><ref bean="exceptionHandler" />property>
	bean>

	
	<bean id="batchRefreshAction" class="nc.ui.pubapp.uif2app.actions.batch.BatchRefreshAction">
		<property name="model"><ref bean="batchModel"/>property>
		<property name="modelManager"><ref bean="batchModelModelDataManager"/>property>
		<property name="exceptionHandler"><ref bean="exceptionHandler" />property>
	bean>

	
	<bean id="batchAddLineAction" class="nc.ui.cjkcmg.cjyxdk.action.CjyxdkAddLineAction">
		<property name="model"><ref bean="batchModel"/>property>
		<property name="voClassName" value="nc.vo.cjkcmg.cjyxdk.Cjyxdk" />
		<property name="exceptionHandler"><ref bean="exceptionHandler" />property>
	bean>

	
	<bean id="batchDelLineAction" class="nc.ui.pubapp.uif2app.actions.batch.BatchDelLineAction">
		<property name="model"><ref bean="batchModel"/>property>
		<property name="batchBillTable"><ref bean="batchBillTable"/>property>
		<property name="exceptionHandler"><ref bean="exceptionHandler" />property>
	bean>
	
	<bean id="queryTemplateContainer" class="nc.ui.uif2.editor.QueryTemplateContainer">
		<property name="context" ref="context">property>
		<property name="nodeKey" value="qt">property>
	bean> 
	
	<bean id="queryAction" class="nc.ui.cjkcmg.cjyxdk.action.QueryAction">
		<property name="model"><ref bean="batchModel" />property>
		<property name="templateContainer"><ref bean="queryTemplateContainer" />property>
		<property name="nodeKey" value="qt"/>
		<property name="dataManager"><ref bean="batchModelModelDataManager" />property> 
		
	bean>
	
	
	<bean id="dkAction" class="nc.ui.cjkcmg.cjyxdk.action.DkAction">
		<property name="model" ref="batchModel" />
		<property name="editor" ref="batchBillTable" />
		<property name="dataManager" ref ="batchModelModelDataManager"/>
		<property name="exceptionHandler"><ref bean="exceptionHandler" />property>
	bean>

	
	<bean id="batchSaveAction" class="nc.ui.pubapp.uif2app.actions.batch.BatchSaveAction">
		<property name="model"><ref bean="batchModel"/>property>
		<property name="editor"><ref bean="batchBillTable"/>property>
		<property name="validationService"><ref bean="batchBillTableValidateService" />property>
		<property name="exceptionHandler"><ref bean="exceptionHandler" />property>
	bean>

	
	<bean id="batchCancelAction" class="nc.ui.pubapp.uif2app.actions.batch.BatchCancelAction">
		<property name="model"><ref bean="batchModel"/>property>
		<property name="editor"><ref bean="batchBillTable"/>property>
		<property name="exceptionHandler"><ref bean="exceptionHandler" />property>
	bean>

	
	<bean id="batchAddLineActiona" class="nc.ui.cjkcmg.cjyxdk.action.CjyxdkAddLineActiona">
		<property name="model"><ref bean="batchModel"/>property>
		<property name="voClassName" value="nc.vo.cjkcmg.cjyxdk.Cjyxdk" />
		<property name="exceptionHandler"><ref bean="exceptionHandler" />property>
	bean>

	
	<bean id="batchDelLineActiona" class="nc.ui.pubapp.uif2app.actions.batch.BatchDelLineAction">
		<property name="model"><ref bean="batchModel"/>property>
		<property name="batchBillTable"><ref bean="batchBillTable"/>property>
		<property name="exceptionHandler"><ref bean="exceptionHandler" />property>
	bean>

    
	<bean id="exceptionHandler" class="nc.ui.uif2.DefaultExceptionHanler">
		<constructor-arg><ref bean="container"/>constructor-arg>
		<property name="context"><ref bean="context" />property>
	bean>
	
	
	
    <bean id="batchBillTableValidateService" class="nc.ui.uif2.model.DefaultBatchValidationService">
    	<property name="editor"><ref bean="batchBillTable" />property>
    bean>
    
     
	<bean id="paginationDelegator" class="nc.ui.bd.pub.BillBatchPaginationDelegator">
		<property name="paginationModel" ref="paginationModel" />
		<property name="billModel" ref="batchModel" />
		<property name="editor" ref="batchBillTable" />
	bean>
	
	<bean id="paginationModel" class="nc.ui.uif2.components.pagination.PaginationModel"
		init-method="init">
		<property name="paginationQueryService" ref="batchModelModelService" />
		<property name="pageSize" value="500" />
	bean>

	<bean id="paginationBar" class="nc.ui.uif2.components.pagination.PaginationBar"
		init-method="registeCallbak">
		<property name="paginationModel" ref="paginationModel" />
		<property name="context" ref="context" />
	bean>
	
	<bean name="listContainerWithPaginationBar" class="nc.ui.cjkcmg.cjyxdk.ace.view.ListSplitPanel">
		<property name="component1" ref="batchBillTable" />
		<property name="component2" ref="paginationBar" />
		<property name="divideLocation" value="30" />
		<property name="model" ref="batchModel" />
	bean>
beans>

你可能感兴趣的:(培训,java)