步骤一:
编写联查实现类 ReportTraceDataOperator.java
注意事项:
实现接口:ItraceDataOperator,TraceDataInterface
说明:联查操作接口,也就是如何进行联查,目前定义了三个操作,主要需要实现前两个:
方法1:执行数据追踪 各业务模块根据需求执行追踪操作
public void traceData(Container container, TraceDataParam
param);
方法2:业务联查的菜单
public IMenuActionInfo getMenuItemInfo();
代码如下:
package nc.ui.bd.defdoc.freereport;
import java.awt.Container;
import javax.swing.Action;
import nc.funcnode.ui.FuncletInitData;
import nc.funcnode.ui.FuncletWindowLauncher;
import nc.pub.smart.data.IRowData;
import nc.pub.smart.tracedata.ITraceDataOperator;
import nc.pub.smart.tracedata.TraceDataInterface;
import nc.pub.smart.tracedata.TraceDataParam;
import nc.ui.pub.linkoperate.ILinkQueryData;
import nc.ui.pub.linkoperate.ILinkType;
import nc.ui.sm.power.FuncRegisterCacheAccessor;
import nc.vo.sm.funcreg.FuncRegisterVO;
import nc.vo.train.entity.QuotationHVO;
import com.ufida.report.free.userdef.DefaultMenu;
import com.ufida.report.free.userdef.IMenuActionInfo;
/**
* 联查单据的实现
*
* @author: zjb
*/
public class ReportTraceDataOperator implements ITraceDataOperator,
TraceDataInterface {
public final static String DEST_FUNC_CODE = "TR1001";
public final static String PK_HEAD = QuotationHVO.PK_SALEQUOTATION;
@Override
public Action[] ctreateExtensionActions() {
return null; // new Action[]{new MyAction()};
}
@Override
public ITraceDataOperator[] provideTraceDataOperator() {
return new ITraceDataOperator[] { new ReportTraceDataOperator() };
}
@Override
public void traceData(Container container, TraceDataParam param) {
// 获得选中表体行的PK
final IRowData rowData = param.getRowData();
String selItem0 = (String) rowData.getData(PK_HEAD);
final String selItem = (selItem0 == null) ? "" : selItem0;
// JOptionPane.showMessageDialog(container, "单据PK:" + selItem);
// 构造传递数据参数
FuncletInitData fid = new FuncletInitData();
fid.setInitType(ILinkType.LINK_TYPE_QUERY);
ILinkQueryData data = new ILinkQueryData() {
public String getBillID() {
return selItem;
}
public String getBillType() {
return null;
}
public String getPkOrg() {
return null;
}
public Object getUserObject() {
return rowData;
}
};
fid.setInitData(data);
// 获得功能VO参数
FuncRegisterVO vo = FuncRegisterCacheAccessor.getInstance()
.getFuncRegisterVOByFunCode(DEST_FUNC_CODE);
// 弹出目标单据
FuncletWindowLauncher.openFuncNodeInTabbedPane(container, vo, fid,
null, false);
}
@Override
public IMenuActionInfo getMenuItemInfo() {
return new DefaultMenu("Linkquery", "联查单据");
}
}
步骤二:
编写联查节点画面显示类:DemoFuncNodeInitDataListener.java
注意事项:
1.需要添加节点画面的xml配置,这个监听类要有原来监听类的功能,例子如下:
<!--
<bean id="InitDataListener"
class="nc.ui.bd.defdoc.DefdocFuncNodeInitDataListener">
<property name="datamanager" ref="modelDataManager" />
</bean>
-->
<!-- -->
<bean id="InitDataListener"
class="nc.ui.bd.defdoc.freereport.DemoFuncNodeInitDataListener">
<!-- 原来注册的 -->
<property name="datamanager" ref="modelDataManager" />
<!-- 必须添加 -->
<property name="model" ref="HAppModel"></property>
<property name="context" ref="context" />
<!-- VO的类名 -->
<property name="voClassName" value="nc.vo.bd.defdoc.DefdocVO"/>
<!-- 非必须 用来显示画面结果-->
<property name="ui" ref="billFormEditor" />
<property name="autoShowUpComponent" ref="billFormEditor"/>
</bean>
代码如下 其中画面显示的问题要自己写:
package nc.icd.test.freereport;
import nc.funcnode.ui.FuncletInitData;
import nc.pub.smart.data.IRowData;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillScrollPane.BillTable;
import nc.ui.pub.linkoperate.ILinkQueryData;
import nc.ui.pub.linkoperate.ILinkType;
import nc.ui.pubapp.uif2app.model.DefaultFuncNodeInitDataListener;
import nc.ui.pubapp.uif2app.view.ShowUpableBillForm;
import nc.vo.train.entity.QuotationBVO;
/**
* 业务联查打开单据的监听,类名需要配置到_config.xml
*
* @author: zjb
*/
public class DemoFuncNodeInitDataListener extends
DefaultFuncNodeInitDataListener {
public final static String PK_BODY = QuotationBVO.PK_SALEQUOTATION_B;
private ShowUpableBillForm ui;
public ShowUpableBillForm getUi() {
return ui;
}
public void setUi(ShowUpableBillForm ui) {
this.ui = ui;
}
@Override
public void initData(FuncletInitData data) {
super.initData(data);
// 联查处理
if (data != null && data.getInitType() == ILinkType.LINK_TYPE_QUERY) {
// 获得表体行PK
ILinkQueryData linkData = (ILinkQueryData) data.getInitData();
Object obj = linkData.getUserObject();
if (obj instanceof IRowData) {
IRowData rowData = (IRowData) obj;
String pkDetail = (String) rowData.getData(PK_BODY);
// 获得表体面板
BillCardPanel panel = ui.getBillCardPanel();
// 选中表体行
BillTable table = panel.getBodyPanel().getTable();
int iRowCount = table.getRowCount();
int iColCount = table.getColumnCount();
for (int i = 0; i < iRowCount; i++) {
String rowPkDetail = (String) panel.getBodyValueAt(i,
PK_BODY);
if (rowPkDetail != null
&& rowPkDetail.equalsIgnoreCase(pkDetail)) {
table.setRowSelectionInterval(i, i);
table.setColumnSelectionInterval(0, iColCount - 1);
break;
}
}
}
}
}
}
步骤三:
联查信息的注册
首先将接口TraceDataInterface
的实现类注册到iufo_tracedataregister
表中。
insert into iufo_tracedataregister
(CLASSNAME, CREATIONTIME, CREATOR, DR, MODIFIEDTIME, MODIFIER, MODULENAME, PK_GROUP, PK_ORG, PK_TRACEDATA, RESDIR, RESID, TRACEDATANAME, TS)
values ('nc.ui.bd.defdoc.freereport.ReportTraceDataOperator', '', 'fenggf ', 0, '', '', 'riamm', '', '', 'TRACEDATA10000000011', '', '', 'ReportTraceDataOperator', '2011-07-04 15:22:32');
需要填写的有四个地方,从左到右依次为:
CLASSNAME
: 联查的实现类StoreReqLinkQuery
MODULENAME
: 模块名【pu】(可大写小写)
PK_TRACEDATA
: 这条 联查记录对应的pk,必须写,位数跟我的保持一致即可,内容可以随便写
TRACEDATANAME
:联查记录对应的显示名,在语义模型那设置业务扩展联查时的显示名
步骤四:
语预模型中工具 =》 业务扩展 中添加联查实现类
自由报表添加隐藏字段:
然后报表联查节点就完成了,过程中的错误就需要自己调试。