文章
· 四月 23 阅读大约需 2 分钟

BPL 中动态设置 <call>的目标

当我们在设计一个需要重复使用的BP时候,往往需要开发一个可配置<call>的对象的组件,我们将call的target 设置为

@process.TargetConfigName

即可实现。

下面是完整代码:

Property TargetConfigName As Ens.DataType.ConfigName;Parameter
SETTINGS = "TargetConfigName:Basic";
/// BPL Definition
XData BPL [ XMLNamespace = "http://www.intersystems.com/bpl" ]
{
<process language='objectscript' request='Ens.Request' response='Ens.Response' height='2000' width='2000' >
<sequence xend='200' yend='450' >
<call name='Call configurable target' target='@process.TargetConfigName' async='1' xpos='200' ypos='250' >
<request type='Ens.Request' >
<assign property="callrequest" value="request" action="set" />
</request>
<response type='Ens.Response' >
<assign property="response" value="callresponse" action="set" />
</response>
</call>
<sync name='Wait' calls='Call configurable target' type='all' xpos='200' ypos='350' />
</sequence>
</process>
}

另,为了在Production配置页面上也显示连接的样式,则需要添加下面代码

/// Return an array of connections for drawing lines on the config diagram
ClassMethod OnGetConnections(Output pArray As %String, pItem As Ens.Config.Item)
{
	Do ##super(.pArray,pItem)
	If pItem.GetModifiedSetting("TargetConfigNames",.tValue) {
		For i=1:1:$L(tValue,",") { Set tOne=$ZStrip($P(tValue,",",i),"<>W")  Continue:""=tOne  Set pArray(tOne)="" }
	}
}

其效果如下:

   

讨论 (0)1
登录或注册以继续