3 Replies Latest reply on Oct 16, 2007 12:12 AM by kruse

    Fusebox and MVC

    kruse Level 1
      HI, I'm new to fusebox and want to start to use it in my newest project.
      I will also implement the design pattern MVC (Model-View-Control).
      But I have some questions about this.

      1. I will have the fusebox to call a start circuit (Control). But in the name of MVC how should the structure be?


      Should I then have sub directory in these like


      Should it be /Control/Entry and then an entry in the circuit
      Should it be /Control and then an entry in that Circuit (without the entry circuit subdirectory)

      3. What about the structure of a login?
      I think that the entry circuit should test if the user is loggedin (Control dir ?) and then call /View/dsp_login.cfm or /View/login/dsp_login.

      4. When and how should sub dirs used?

      5. Calling a model. I uses cfc's for database access. I have a cfc called food that handles all the select, update and deletes of foods. But where should that cfc be located? I know that it should be in the dir /Model. But Should it be in /Model/Food???)

      I think that some of the questions may be a little uncleare. But maby will an answer for one of the questions answer the rest of my questions.
        • 1. Re: Fusebox and MVC
          Steve Sommers Level 4
          Ahh, the fun of system design and structure. This is a very difficult question to answer. I've organized it in different ways and have not found one method I am 100% satisfied with. The best way I have found is by function like: usercp, inventory, shoppingcart, shipping, etc. I would check out the fusebox.org site and forums, you'll probably get more responses to fusebox specific questions like these.
          • 2. Re: Fusebox and MVC
            craigkaminsky Level 3

            Like Steve notes, it's a tough question to answer. I thought I would chime in with a note on how I structure my FB (versions 5) applications:

            In the root of the application, I have my Fusebox initialization files, fusebox.xml file, index page, application cfm/cfc file, and a variety of folders*:
            1. controller -- contains my circuit.xml and, sometimes subfolders. When I have a secure site, I have a child folder here called "login" that contains another circuit.xml file.
            2. model -- typically, I have a circuit.xml file in the root and two subfolders: actions (where I keep a few action fuses) and com (where I keep CFCs)
            3. view -- contains a circuit.xml file and several child folders. Typically, displays (for display fuses), layouts (for layout fuses), and public (contains the images, javascript, css, etc. necessary for the display of the site -- all nested in appropriately named folders, of course!).

            *There are often a few other folders in the root directory, alongside my MVC setup:
            errortemplates, lexicon, verbs, plugins, parsed).

            These come with the FB framework. On non-shared servers, I reference the framework files from their own directory, while on shared servers, I have the FB framework and these folders uploaded to the root directory as well.

            If you Google "Fusebox MVC" you will see a lot of tutorials and posts regarding using the MVC design patter with FB. It's pretty easy to get going with it.
            • 3. Fusebox and MVC
              kruse Level 1
              Thank you for your replies. It was much like that I was going to use.
              I already have googled fusebox and MVC for answer but I did not find an answer that did satisfy me.
              Also I have looked at all the tutorials on fusebox.org but I think that every single of them use Fusebox 4 and I use fusebox 5. Ofcause the basics is the same but there is also a lot of changes.

              I have now done my first fuse but am a little worried if this can be right.

              In the fusebox.xml.cfm I call the controller
              <parameter name="defaultFuseaction" value="app.foodList" />

              in the Controler circuit.xml.cfm I call the model to retrieve data and the view to output it
              <fuseaction name="foodList">
              <do action="m.getAllFood" />
              <do action="v.showFoodGrid" />

              In the model I have the circuit.xml.cfm which retrives a query from a cfc
              <fuseaction name="getAllFood">
              <instantiate object="Foods" class="foods" />
              <invoke object="Foods" methodcall="getFood()" returnvariable="qry_allFoods" />

              And in the View I have
              <fuseaction name="showFoodGrid">
              <include template="dsp_foodGrid" contentvariable="body" />

              Now when I have done this it don’t seams right to me. Because the one little function to show a list of foods in a grid is spread all over the application.
              The circuit.xml.cfm of booth model and view will contain a lot of different fuseactions. Is that right?

              I would prefer to have it all together like :
              <fuseaction name="showFoodGrid">
              <instantiate object="Foods" class="foods" />
              <invoke object="Foods" methodcall="getFood()" . . . >
              <include template="dsp_foodGrid" contentvariable="body" />

              To me the last one gives me a better overview how the show food works instead have to go into bouth the model and view circuits to see what happens.
              Is there a tool that can help with maybe displaying the fuse and circuit connections?