用友nc65 uap开发刷新按钮二次开发

用友nc65  uap开发刷新按钮二次开发

1.问题现象:卡片刷新,直接返回列表,且定位成第一条,且执行的是全部刷新
2.问题分析: 65向导生成的按钮,刷新按钮使用的同一个 nc.ui.pubapp.uif2app.query2.action.DefaultRefreshAction,统一执行列表全部刷新
3.解决方案: 新开发按钮 nc.ui.pr.pub.query.ListAndCardRefreshAction 来区分卡片和列表,执行不同刷新通过
4.使用方式:
在xml文件中修改
<!--======= 动作:[newActions] [刷新] ===========-->
	<bean id="defaultRefreshAction" class="nc.ui.pr.pub.query.ListAndCardRefreshAction">
		<property name="model"><ref bean="bmModel"/></property>
		<property name="dataManager"><ref bean="bmModelModelDataManager"/></property>
		<property name="cardEditor"><ref bean="billForm"/></property>
		<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
	</bean>

使用注意:支持实现的是配合最常见的 主子管理界面。配合下三个类型

private IModelDataManager dataManager = null;
private AbstractUIAppModel model = null;
private ITabbedPaneAwareComponent cardEditor;
如果是其他的类型,可以自己实现,重点:



按钮java类:

package nc.ui.crmbd.pub.query;

import java.awt.event.ActionEvent;

import nc.bs.framework.common.NCLocator;
import nc.bs.uif2.IActionCode;
import nc.itf.uap.IUAPQueryBS;
import nc.md.data.access.NCObject;
import nc.md.persist.framework.IMDPersistenceQueryService;
import nc.ui.ml.NCLangRes;
import nc.ui.pub.beans.progress.IProgressMonitor;
import nc.ui.pub.beans.progress.NCProgresses;
import nc.ui.pubapp.uif2app.query2.model.IModelDataManager;
import nc.ui.uif2.NCAsynAction;
import nc.ui.uif2.ShowStatusBarMsgUtil;
import nc.ui.uif2.ToftPanelAdaptor;
import nc.ui.uif2.UIState;
import nc.ui.uif2.actions.ActionInitializer;
import nc.ui.uif2.components.ITabbedPaneAwareComponent;
import nc.ui.uif2.components.progress.ProgressActionInterface;
import nc.ui.uif2.components.progress.TPAProgressUtil;
import nc.ui.uif2.model.AbstractUIAppModel;
import nc.ui.uif2.model.BatchBillTableModel;
import nc.ui.uif2.model.BillManageModel;
import nc.uif2.annoations.MethodType;
import nc.uif2.annoations.ModelMethod;
import nc.uif2.annoations.ModelType;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.SuperVO;

/**
 * 
 * 同时卡片和列表刷新,并且区别处理
 * 
 * 配合 IModelDataManager, * AbstractUIAppModel ITabbedPaneAwareComponent
 * cardEditor
 * 
 * 
 * 
 */
public class ListAndCardRefreshAction extends NCAsynAction implements
		ProgressActionInterface {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5881003422369583037L;

	private IModelDataManager dataManager = null;

	private AbstractUIAppModel model = null;
	private ITabbedPaneAwareComponent cardEditor;

	private TPAProgressUtil tpaProgressUtil;

	private boolean isTPAMonitor = true;

	private IProgressMonitor monitor = null;

	// 是否需要添加进度显示或蒙版,有些动作自己做了异步处理,可以将此开发关闭。
	private boolean isNeedProgress = true;
	private IUAPQueryBS uapQry;
	private IMDPersistenceQueryService mdQry;

	public ListAndCardRefreshAction() {
		super();
		ActionInitializer.initializeAction(this, IActionCode.REFRESH);
	}

	@Override
	public boolean beforeStartDoAction(ActionEvent actionEvent)
			throws Exception {
		boolean ret = true;
		if (!isNeedProgress())
			return ret;
		// 操作太频繁直接返回
		if (monitor != null && !monitor.isDone()) {
			return false;
		}
		// 设置等待界面
		if (isTPAMonitor()) {
			monitor = getTpaProgressUtil().getTPAProgressMonitor();
		} else {
			monitor = NCProgresses.createDialogProgressMonitor(model
					.getContext().getEntranceUI());
		}
		monitor.beginTask(
				NCLangRes.getInstance()
						.getStrByID("uif2", "RefreshAction-0000")/* 刷新中,请稍候... */,
				-1);
		monitor.setProcessInfo(NCLangRes.getInstance().getStrByID("uif2",
				"RefreshAction-0000")/* 刷新中,请稍候... */);
		return ret;
	}

	@Override
	public void doAction(ActionEvent e) throws Exception {
		if (!getCardEditor().isComponentVisible()) // 列表界面在显示
			this.getDataManager().refresh();
		else {
			// 卡片界面显示时,只刷新卡片数据;
			BillManageModel manageModel = (BillManageModel) getModel();
			int selectedRow = manageModel.getSelectedRow();
			if (selectedRow < 0)
				return;
			Object selectedObj = manageModel.getSelectedData();
			if (selectedObj instanceof SuperVO) {
				SuperVO oldBillVO = (SuperVO) selectedObj;
				Object newBillVO = getUapQry().retrieveByPK(
						oldBillVO.getClass(), oldBillVO.getPrimaryKey());
				if (newBillVO != null) {
					copyNewValueToOldObject((SuperVO) newBillVO, oldBillVO);
					manageModel.setSelectedRow(selectedRow);
				}
			}
			if (selectedObj instanceof AggregatedValueObject) {
				AggregatedValueObject aggVO = (AggregatedValueObject) selectedObj;
				SuperVO oldBillVO = (SuperVO) aggVO.getParentVO();
				NCObject newBillNCVO = getMdQry().queryBillOfNCObjectByPK(
						oldBillVO.getClass(), oldBillVO.getPrimaryKey());
				if (newBillNCVO != null) {
					AggregatedValueObject newBillAggVO = (AggregatedValueObject) newBillNCVO
							.getContainmentObject();
					aggVO.setParentVO(newBillAggVO.getParentVO());
					manageModel.setSelectedRow(selectedRow);
				}
			}
		}

	}

	@Override
	public boolean doAfterFailure(ActionEvent actionEvent, Throwable ex) {
		if (monitor != null) {
			monitor.done();
			monitor = null;
		}
		return true;
	}

	@Override
	public void doAfterSuccess(ActionEvent actionEvent) {
		if (monitor != null) {
			monitor.done();
			monitor = null;
		}
		this.showQueryInfo();
	}

	protected void showQueryInfo() {
		if (!getCardEditor().isComponentVisible()) // 列表界面在显示
		{
			int size = 0;
			if (this.getModel() instanceof BillManageModel) {
				size = ((BillManageModel) this.getModel()).getData().size();

			} else if (this.getModel() instanceof BatchBillTableModel) {
				size = ((BatchBillTableModel) this.getModel()).getRows().size();
			}
			if (size >= 0) {
				ShowStatusBarMsgUtil.showStatusBarMsg(
						nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
								"pubapp_0", "0pubapp-0266", null,
								new String[] { "" + size })/*
															 * @res
															 * "刷新成功,共刷新{0}张单据。"
															 */, this
								.getModel().getContext());
			}

		}else{
			ShowStatusBarMsgUtil.showStatusBarMsg(
					nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
							"pubapp_0", "0pubapp-0266", null,
							new String[] { "" + 1 })/*
														 * @res
														 * "刷新成功,共刷新{0}张单据。"
														 */, this
							.getModel().getContext());
		}
	}

	@Override
	protected boolean isActionEnable() {
		return getModel().getUiState() == UIState.INIT
				|| getModel().getUiState() == UIState.NOT_EDIT;
	}

	@ModelMethod(modelType = ModelType.AbstractUIAppModel, methodType = MethodType.GETTER)
	public AbstractUIAppModel getModel() {
		return model;
	}

	@ModelMethod(modelType = ModelType.AbstractUIAppModel, methodType = MethodType.SETTER)
	public void setModel(AbstractUIAppModel model) {
		this.model = model;
		this.model.addAppEventListener(this);
	}

	public boolean isTPAMonitor() {
		return isTPAMonitor
				&& getTpaProgressUtil().getContext().getEntranceUI() instanceof ToftPanelAdaptor;
	}

	public void setTPAMonitor(boolean isTPAMonitor) {
		this.isTPAMonitor = isTPAMonitor;
	}

	public TPAProgressUtil getTpaProgressUtil() {
		if (this.tpaProgressUtil == null) {
			tpaProgressUtil = new TPAProgressUtil();
			tpaProgressUtil.setContext(getModel().getContext());
		}
		return tpaProgressUtil;
	}

	public void setTpaProgressUtil(TPAProgressUtil tpaProgressUtil) {
		this.tpaProgressUtil = tpaProgressUtil;
	}

	public boolean isNeedProgress() {
		return isNeedProgress;
	}

	public void setNeedProgress(boolean isNeedProgress) {
		this.isNeedProgress = isNeedProgress;
	}

	private void copyNewValueToOldObject(SuperVO newBillVO, SuperVO oldBillVO) {
		String[] attributeNames = oldBillVO.getAttributeNames();
		for (String attribute : attributeNames) {
			oldBillVO.setAttributeValue(attribute,
					newBillVO.getAttributeValue(attribute));
		}
	}

	public IModelDataManager getDataManager() {
		return dataManager;
	}

	public void setDataManager(IModelDataManager dataManager) {
		this.dataManager = dataManager;
	}

	public void setCardEditor(ITabbedPaneAwareComponent cardEditor) {
		this.cardEditor = cardEditor;
	}

	public ITabbedPaneAwareComponent getCardEditor() {
		return cardEditor;
	}

	public IUAPQueryBS getUapQry() {
		if (uapQry == null) {
			uapQry = NCLocator.getInstance().lookup(IUAPQueryBS.class);
		}
		return uapQry;
	}

	public IMDPersistenceQueryService getMdQry() {
		if (mdQry == null) {
			mdQry = NCLocator.getInstance().lookup(
					IMDPersistenceQueryService.class);
		}
		return mdQry;
	}
}



工具介绍 本工具软件服务于U8产品,其工作成果只能在U8中使用。此工具的运行必须依赖于U8产品安装后的环境。 【工具目标】 支持业务部门的应用开发,提高应用部门的开发效率。 支持客户个性化的应用要求,提供客户个性化定义的平台。 支持二次开发的应用,利用此工具可以制作行业插件。 支持产业链,支持用友的合作伙伴能利用此系统进行扩展功能的开发和针对个别客户的开发。 【应用角色】 开发人员 包括一次开发二次开发人员。开发人员通过此工具对底层的元数据进行定义和预置。他们可以进行物理数据库、代码等比较专业化的预置工作。 实施人员 实施人员也可通过此工具预置复杂的逻辑,甚至预置与编码相关的内容,但他们与开发人员所不同的是他们不能修改某些被开发人员锁定的预置内容。 客户化人员 对系统进行各种配置和管理的人员,通常为企业中的信息部人员。 【应用范围】 应用开发工具用角色是水平产品的业务开发人员。 插件开发工具 利用此工具可以开发插件,作为插件开发工具对新功能的开发将不受限制,但对已有功能的扩展将有一定限制。 二次开发工具 利用此工具可以对某客户进行二次开发。 客户化工具 客户可以利用此工具进行个性化的定制,对已有功能的扩展将受到一定限制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值