Submitting Forms with Trees ColdFusion Help

When you submit a form containing a tree two form variables are created:

Form Tree Name node Contains the node the user has selected without the path to the node

Form. TreeName. path Contains the complete path to the selected node, such as root\nodel\node2\node3

You will probably notice that the root node is included in the Form. TreeName. path variable in the table, This is optional. By default/the path will exclude the root node. However, if the COMPLETE PAT attribute of the CFTREE tag is set to YES,then the root node will be included.

Referring back to your gender-grouped tree let’s consider the form variables that are created if the form is submitted with Doe Sue selected. As the tree is currently defined the variables will have values as follows:

Form.TreeTest.node Doe, Sue
Form.TreeTest.path F\Doe, Sue

Adding COMPLETEPATH=”YEtSo”the CFTREEtag changes the latter to Employees\F\Doe Sue

.Displaying Alternate Values

Sometimes, it will not be ideal to display the same value as is actually stored in a node of the tree. That is sometimes you need to have the value displayed for a node differ from the value submitted by that node

To do this, you use the DISPLAYattribute of the CFTREEITEMtag to indicate query fields to use for display purposes. Like the VALUE attribute this can be a comma-separated list.of values and should contain the same number of entries as the VALUE attribute in the same tag

Using URL swith Trees

As you saw with grids it is possible for tree items to be associated with URLs and to become dick able links. You do this by specifying a URL in the HREF attribute of the CFTREEITEM’tagF. or instance with the following tag

<CFTREEITEM VALUE=’Gender 1D’ DISPLAY = ‘ Gender Name’ QUERY=”Employees’ QUERYASROOT=’Yes’ IMG=”folder folder document’ HREF=’ ,,employeedetails.cfm”>

you link entries to an employee details template to produce results like those in Figure 15.45

Notice the use of commas in the HREF attribute. The HREF attribute indicates a URL for each level of the item, just as the IMG attribute indicates an image for each level of the item. To indicate that a level in the tree is not a link, simply leave its space blank. This explains why the HREF value has a list with the first two entries blank: Only the nodes at the bottom level of the tree (where the names are) need to be displayed as links. When these links arecreated a URL attribute called CFiREEITEM KEY is appended to the URL with the selected value as its value. This can be used in the template you link to for processing purposes.

Formatting Trees

Several attributes are available for the CFTREE tag that control the appearance of a tree. These are outlined in the following list:

FONT Specifies the font for the tree
FONTSIZE Specifies the font size for the tree in points
ITALIC Indicates whether the tree text should be in italics (possible values are YES and NO)
BOLD Indicates whether the tree text should be bold (possible values are ,!,ES;and,NO)
HEIGHT Indicates the height of the tree in pixels
WIDTH Indicates the width of the tree in pixels
VSPACE_ Indicates the vertical $pace around the tree in pixels
HSPACE“Indicates the horizontal space around the tree in pixels ,.
BORDER– hl.dtcates whether a border should be drawn around the tree (possible values are YES apd NO)
HSCROLL Indicates whether horizontal scrolling is allowed (possible values are YES and NO)
VSCROLl Indicates whether vertical scrolling is allowed (possible vales are YES and NO)

As with the other Java controls we have discussed the NOT SUPPORTED attribute can be used to specify custom text to be displayed for browsers that do not support Java.

Where Do We Go from Here?

This has been a large but essential chapter. In it, you learned how to integrate form seven the most basic HTML forms-fito ColdFusion to create useful, interactive templates. You also learned how ColdFusion extends forms with interactive [ava-based con- / trols that allow the creation of much more sophisticated forms.

In the next chapter you will take things one step further and look at form validation. Validation is a vital part of the effective use of forms. It is through validation that the data provided by a user is checked for integrity: Required fie~dsare checked to make sure they aren’t blank and fields requiring specially formatted data ar1″er..ked to make sure the entered data meets the required format. If the user has failed to enter data correctly, they are informed so that they can fix the problem.

Normally this is a tedious process combining tedious JavaScript programming with CGI-BIN scripting. ColdFusion eliminates most of this work and automates much of the validation process.

Posted on November 17, 2015 in Forms

Share the Story

Back to Top
Share This