|
Mike,
Fuses
are quite different conceptually from fuseactions. A fuseaction is fundamentally
a request to do something: validateUser, for example. This request must be
translated into code, of course. These code files are called fuses. The smaller
and more discrete the fuse is, the easier it is to debug, maintain, and reuse.
So in the above example, the fuseaction, validateUser would translate into
perhaps two fuses: qry_FindUser.cfm and
act_ValidateLogin.cfm.
The
job of qry_FindUser.cfm would be to simply return a recordset of user
information based on information passed to it -- userName and password, say. The
job of act_ValidateLogin.cfm is to read this record set and decide what to if
the recordset returned any rows (in which case, the validation succeeded) or no
rows (failure).
Here's
the code:
<cfcase value="validateLogin">
<cfinclude template="qry_FindUser.cfm" />
<cfinclude template="act_ValidateLogin.cfm" />
</cfcase>
Sometimes a fuseaction needs to accomplish something that is already done
by another fuseaction. Often the code for that fuseaction may lie in another
circuit. (A circuit can be thought of as a grouping of like-minded
fuseactions.) Rather than duplicate this code, or attempt to directly access the
fuses, the primary fuseaction can simply ask the other fuseaction to
perform an action. Here is an example of doing this by calling the Fusebox as a
custom tag:
<cfcase value="checkout">
<cfmodule
template="#Fusebox.rootPath##self#"
fuseaction="Inventory.checkStock"
item="#attributes.chosenItem#"
/>
<cfinclude template="act_Checkout.cfm"
/>
</cfcase>
This
can also be handled a bit differently by using the Techspedition core file. In
that case, you just add the fuseactions into a queue, like
this:
<cfcase value="checkout">
<cfset AddToQ( 'Inventory.checkStock' ) />
<cfset AddToQ( 'Checkout.getUserInfo' ) />
</cfcase>
Either
way will work perfectly fine for you. I use them both, depending on whether I
want to define a sort of workflow (in which case I use the FuseQ stuff) or just
want to run out and do something immediately, suspending current processing (in
which case I use the <cfmodule> call). The latest edition of "ColdFusion
Developer's Journal" has an article I wrote on calling the Fusebox recursively
-- that is, as a custom tag.
|
Title: Message
- CFMODULE vs CFINCLUDE Mike
- Re: CFMODULE vs CFINCLUDE Lee Borkman
- Re: CFMODULE vs CFINCLUDE Mike
- Re: CFMODULE vs CFINCLUDE hal helms
- Re: CFMODULE vs CFINCLUDE Mike
- RE: CFMODULE vs CFINCLUDE Xavi
- Re: CFMODULE vs CFINCLUDE Lee Borkman
- Re: CFMODULE vs CFINCLUDE John Quarto-vonTivadar
- RE: CFMODULE vs CFINCLUDE hal helms
- Re: CFMODULE vs CFINCLUDE Lee Borkman
- Re: CFMODULE vs CFINCLUDE Evan Wilders
- Re: CFMODULE vs CFINCLUDE Lee Borkman
