问题描述
|
我正在开发一个使用mura标签插入组件并在页面上使用它的Mura插件。本质上,我的插件需要调用
$.dspObject(\'component\',Arguments.componentid)
。由于mura范围在plugin方法中不可用,因此我猜测我需要引入一个组件bean,但是我不知道该怎么做。
<cffunction name=\"showPlayer\" access=\"public\" output=\"false\" returntype=\"String\">
<cfargument name=\"component\" type=\"string\" required=\"true\" hint=\"The ID of the component that contains the playlist.\" />
<!--- Create the body content --->
<cfsavecontent variable=\"bodycode\">
<cfoutput>#$.dspObject(\'component\',Arguments.component)#</cfoutput>
</cfsavecontent>
</cffunction>
那是该方法的简化版本(完整的eventHandler可以在GitHub上找到。
那么,我将如何重写我的代码以拉出组件Bean(或我需要为此做的任何事情)?
解决方法
有几种可能的方法:
<cfargument name=\"$\">
要么
var $=application.ServiceFactory.getBean(“muraScope”);
要么
var $=getServiceFactory().getBean(“muraScope”);
要么
var $=getBean(“muraScope”);
请参阅《 MuraCMS程序员指南》和cfobject.cfc