Fusebox invoking a fuse within the code

做~自己de王妃 提交于 2019-12-23 21:26:35

问题


Does anyone know if its possible to invoke a fuseaction within a coldfusion template?


回答1:


(You haven't specified which Fusebox version; this answer applies to Fusebox 5.x)

Your title and question is asking two different things - a fuse and a fuseaction are two distinct things. A fuse is simply a CFML template, whilst a fuseaction represents a bundle of logic that performs a particular action (similar to a function).

Fuses:

To invoke a fuse, simply include the file as you would normally - there's no special FB functionality required for this.

Fuseactions:

To invoke a fuseaction, use the do verb, like so:

<cfset myFusebox.do('circuit.fuseaction') />


To store the result, use the second argument for the content variable:

<cfset myFusebox.do('circuit.fuseaction',varname) />

This is the equivalent of this XML:

<do action="circuit.fuseaction" contentvariable="varname" />


There are other arguments available, see this Fusebox cheat sheet which contains plenty of other useful info too.




回答2:


With MVC, you should be working through a single entry-point. So only a single fuseaction should be called during your request.

BUT that fuseaction can call some of the other model and view templates as needed. And I believe that Fusebox allows you to refactor that logic into something that can be used by multiple actions. (I'm a bit rusty on my Fusebox functionality though, but I bet some Googling will lead you the way.)

As a dire last resort, you could use <cfhttp> to call a URL within your app that invokes that fuseaction. But why not just run some of the code directly without needing to burden your server with another HTTP call?



来源:https://stackoverflow.com/questions/14004014/fusebox-invoking-a-fuse-within-the-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!