1.ListEditor.java
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
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
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
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
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
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
xml
<?xml version="1.0" encoding="GBK"?>
<!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.pubapp.pub.smart.SmartBatchAppModelService"> -->
<bean id="batchModelModelService" class="nc.ui.cjkcmg.cjyxdk.model.ListModelService">
<!-- <property name="serviceItf" value="nc.itf.cjkcmg.ICjyxdkMaintain" />
<property name="voClass" value="nc.vo.cjkcmg.cjyxdk.Cjyxdk" /> -->
</bean>
<!-- 对象转换器工厂,由此获取操作对象的特征信息 -->
<bean id="BOAdapterFactory" class="nc.vo.bd.meta.GeneralBDObjectAdapterFactory">
<property name="mode" value="MD"/>
</bean>
<!-- 层次结构构造策略 -->
<!-- 模型元素 -->
<!--========= 模型元素:[PUBAPP单表模型(BatchBillTableModel)实例对象] ==========-->
<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.pubapp.uif2app.model.BatchModelDataManager"> -->
<bean id="batchModelModelDataManager" class="nc.ui.cjkcmg.cjyxdk.model.ListModelDataManager">
<property name="model"><ref bean="batchModel"/></property>
<!-- <property name="service"><ref bean="batchModelModelService" /></property> -->
<property name="paginationModel" ref="paginationModel" />
<property name="delegator" ref="paginationDelegator" />
</bean>
<!-- Mediator,模型之间监听关系部分 -->
<!-- 组织面板//newadd -->
<!-- 卡片界面的工具栏和返回按钮 -->
<!-- 模板容器,负责对模板的统一装载 -->
<bean id="templateContainer" class="nc.ui.pubapp.uif2app.view.TemplateContainer" init-method="load">
<property name="context" ref="context"/>
<property name="nodeKeies">
<list>
<value>bt</value>
</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>
<!--====== 视图元素:[PUBAPP单表编辑控件(BatchBillTable)实例对象] ==============-->
<!--<bean id="batchBillTable" class="nc.ui.pubapp.uif2app.view.ShowUpableBatchBillTable" init-method="initUI">-->
<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="batchBillTable" /> -->
<ref bean="listContainerWithPaginationBar" />
</property>
</bean>
</property>
<property name="dividerLocation" value="74.0f" />
<property name="name" value="" />
</bean>
</property>
<property name="actions">
<list>
<!-- <ref bean="batchEditAction" />
<ref bean="batchRefreshAction" />
<ref bean="batchAddLineAction" />
<ref bean="batchDelLineAction" /> -->
<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" />
<!--
<property name="model">
<ref bean="$vmObject.topActionDependModel"/>
</property>
-->
</bean>
<!-- 打开节点监听 newadd-->
<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>
<!-- ClosingListener 编辑态关闭节点时提示是否保存//newadd***************************************************-->
<!-- 事件监听newadd -->
<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>
<!--懒加载信息配置*******************************************************-->
<!-- Action部分 ***********************************************************-->
<!--======= 动作:[newActions] [修改] ===========-->
<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>
<!--======= 动作:[newActions] [刷新] ===========-->
<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>
<!--======= 动作:[newActions] [新增] ===========-->
<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>
<!--======= 动作:[newActions] [删除] ===========-->
<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>
<!--======= 动作:[newActions] [查询] ===========-->
<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>
<!--======= 动作:[newActions] [打卡] ===========-->
<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>
<!--======= 动作:[newActions] [保存] ===========-->
<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>
<!--======= 动作:[newActions] [取消] ===========-->
<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>
<!--======= 动作:[newActions] [新增] ===========-->
<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>
<!--======= 动作:[newActions] [删除] ===========-->
<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>