Cheers Lee,
Just what I needed.  It's gunna be a good weekend for some module experimenting :)
 
Thanx
Drew
 
 
----- Original Message -----
Sent: Friday, April 19, 2002 8:01 AM
Subject: Re: Moduling circuits

Hi guys,
 
We have a few issues here:
  1. Do we need to modify the FB3 app being called?
  2. How do we call it?
  3. "Bottoming out"
  4. Global variables
Do we need to modify the FB3 app being called?
 
If we want an FB3 app to be used both as a stand-alone app (something a normal CustomTag doesn't do) and as a helper module for other apps, then we may need to put a little conditional logic in somewhere.  The two areas you that may need to change are layout and return-scope.
 
If your app/module outputs HTML, then you may want to strip out the extraneous layout so that the calling app can do its own stuff.  The simplest way is probably to check the isCustomTag API variable in your fbx_layouts:
<cfif fusebox.isCustomTag>
  <cfset fusebox.layoutfile="">
<cfelse>
  <cfset fusebox.layoutfile="lay_medown.cfm">
</cfif>

If your app/module returns pure data, then you have to return the data in the caller scope, so that the calling app can use it.  There are a few ways to so this, but as Hal says, it's enough to check isCustomTag in your fbx_setting, and set a #scope# variable on that basis.

How do we call it?

We use CFMODULE to call the app.  You need to specify the TEMPLATE, which will always be an index.cfm file for FB3 apps.  Then you add attributes to your call.  The most important of these is, of course, FUSEACTION.  In other words, you are calling an FB application that has a number of publically accessible functions called "fuseactions".  You have to tell it which one you want.  After that, you can pass any extra attributes that might be required by the fuseaction you are requesting:

<cfmodule
  template="/utilities/index.cfm"

  fuseaction="security.authenicateuser"
  username="#attributes.username#"
  password="#attributes.password#">

"Bottoming out"

Recursion is a piece of code calling itself.  Whenever you use recursion in any context, no matter what the language, platform or architecture, you have to plan to "bottom out" somewhere.  That means that you eventually have to reach some circumstance where you no longer make the recursive call.  In order for this to happen, you need two things:  You need conditional code; and you need some condition to actually change ;-)

If you don't do this, you will inevitably get an infinite loop.

Global Variables

If your calling app, and your helper module share the same variable space, then the helper might overwrite variables that the calling app needs.  This may be what you want, or it may not.  In ColdFusion and FB3, we need to take particular care of request-scope variables (although session, client, application, cookies are obviously a problem too).  That is why the FB3 core code has stepped away from using request-scope to hold important internal variables, and that is why FB3 is so robust when using helper modules.  The rule here is simple: Think about your variables.

 

Okay, I think that's about all you need.  The rest is just practice.  Have a look at Hal's MVC example.  Have a look at my Basic Portal.  Both of these use recursive calls.  I'm not aware of any examples out there that use cfmodule calls to external applications (ie apps outside the current home app), but I certainly use them at work.  They're just not the kind of thing you are likely to see in a stand-alone sample application, for obvious reasons ;-)

Hoping that helps some,

See ya,

LeeBB

----- Original Message -----

 

Thanx Chad,
  I tried that, which actually created an infinate loop somehow hehe.  I
would've had a better idea of why that happened if I hadn't taken out Lee's
debugger code a week or so back.  The circuit works fine as is (when the
user just goes to it), yet because I tried cfmoduling it from within one of
my layout files I thought that could've been the reason for the loop.

Cheers again
Drew


----- Original Message -----
From: <[EMAIL PROTECTED]>

> I hope this question gets a lot of attention. I would think that this
should
> be the hallmark of FB3 but it seems to me to be more cumbersome to
implement
> then it should be. Most people on this list prefer to just drop the
circuit
> into place, I guess only because it is much easier to do.
>
> Try something like this:
> <CFMODULE template="#fusebox.rootPath#/index.cfm"
fuseaction="fs.ShowForm">
>
>
> To be fair I stopped struggling with it at a time I was just learning FB3
so
> maybe I tried to make it do something it couldn't do or perhaps it could
> have been done in a better way.
>
>
> Chad Kemp
>
> -----Original Message-----
> From: Drew Parker [mailto:[EMAIL PROTECTED]]
>
> Hi Ppls,
>    Can spmeone direct me to where I can read up on the 'How to do's' of
> using Cfmodule to call certain circuits?
> I have a circuit that performs a certain function and rather than
> copying the whole circuit into every directory where I need to use this
> functionality, I thought a cfmodule call to the circuit would save me
> heaps of space.  Just how this is done and getting the circuit to
> function properly when called as a module, I have no idea.
>
==^================================================================
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?bUrFMa.bV0Kx9
Or send an email to: [EMAIL PROTECTED]

T O P I C A -- Register now to manage your mail!
http://www.topica.com/partner/tag02/register
==^================================================================

Reply via email to