Initialization ColdFusion Help

Initialization takes place in Lines 4 through 9 (refer to Usting34.1). The logic here is fairly simple: If a branch to view is provided in the URL, then it should be assigned to the variable Branch. Similarly, if the root branch menu has been used and submitted, then the key selected. should be assigned to the variable Branch. This is performed after . checking the URL for a branch, so that use of the menu will always override a URL-provided branch.

Root Branch Menu

To make things easy, the root branch menu, outlined in Lines 10 through 20 (refer to Listing 34.1), is a simple select field in a form. Notice that the action of the form is to submit the form’s contents back to itself. In other words, the template displays the form and processes input from the form.

Querying the Registry and Displaying the Results

The bulk of the work is done after the form is displayed, starting with a test to see whether a branch has been specified by using the following:

The purpose of this initial test is to see whether a key has been specified, and the test is performed by checking whether the variable Branch exists. Looking at the template’s initialization section, it is clear that only if a branch is specified in the URL or through the root branch menu will this variable exist. This is important because you want to use the CFREGISTRYtag to access a branch only if a key has been specified. H the variable exists, then you query the registry and display a table of results in a manner similar to that shown when we discussed the use of the ACTION'””GetA11  attribute earlier in this chapter. A few pOints to note:
• The BRANCHattribute of the CFREGISTRYtag is specified as the value of the Branch. variable.
• In the CFOUTPUTsegment of the template where you are displaying the results of the CFREGISTRYquery, you check whether an entry is a key by testing the value of the Type column from the query. If you find a key, then the name of the entry is displayed as a link back to the template, with the branch specified as a combination of the Branch variable and the Entry column from the query.
• The CFELSEsegment displays a message if no branch is specified. Users will see this message the first time they open the template.

Where Do We Go from Here?

In the next three chapters, you will dive into some advanced administrative issues, considering everything from the ColdFusion Administrator to troubleshooting and performance optimization techniques. The next chapter provides details of the ColdFusion Administrator, which you have already seen in passing. Now, you will take a closer look at all its features, and how it can be used to keep your ColdFusion installation functioning properly, with a minimum of problems.

Posted on November 17, 2015 in Using the CFREGISTRY Tag

Share the Story

Back to Top