Welcome to ColdFusion Studio ColdFusion Studio is a powerful and flexible tool for building, testing, and deploying dynamic Web applications. It is also an easy to use tool to create and edit Web content, with support for a variety of scripting languages. Contents Intended Audience......................
Intended Audience Intended Audience The principal audience for this user guide is professional Web developers who have a working knowledge of HTML and Web server environments. The focus is on introducing you to Studio’s interface and development tools. Introduction to the ColdFusion 4.5 Web Application Server The ColdFusion 4.5 release focuses on fundamentals —...
Welcome to ColdFusion Studio Development Features in ColdFusion Studio 4.5 A wide range of features are available in ColdFusion 4.5 for application development and for creating Web content. Allaire FTP & RDS — Manage all your files from a single interface that integrates access to the Windows file system, ColdFusion server via Remote Development Servers (RDS), and FTP servers.
About ColdFusion Documentation About ColdFusion Documentation ColdFusion documentation is designed to provide support for all components of the ColdFusion development system. Both the print and online versions are organized to allow you to quickly locate the information you need. In addition to the book set, the documentation is provided in two other formats: HTML —...
Welcome to ColdFusion Studio xiii Using ColdFusion Studio Documents everything you need to know about using ColdFusion Studio, including features like projects, source control integration, as well as the Studio workspace and interface. Quick Reference to CFML A valuable quick reference to CFML tags, functions, and variables. ColdFusion Server online documentation To view the HTML documentation, open the following URL: http://127.0.0.1/...
Developer Resources Developer Resources This section is a brief listing of CFML resources. Allaire ColdFusion Developer Center The Developer Center at http://www.allaire.com/developer/referenceDesk/index.cfm contains all the latest information on ColdFusion and offers tutorials, technical articles, and links to other resources. ColdFusion Web Resources Following are just a few of many site dedicated to CFML development.
Welcome to ColdFusion Studio Contacting Allaire Please contact Allaire for sales and support information. Corporate headquarters Allaire Corporation 275 Grove Street Newton, MA 02446 Telephone: 617.219.2000 Fax: 617.219.2001 http://www.allaire.com Customer Service Contact Allaire customer service to inquire about product orders and to obtain corporate and product information and an Allaire username and password.
Page 17
H A P T E R Exploring the Workspace This chapter acquaints you with the main areas of the interface. It will also give you some pointers on customizing the workspace to make all your development work as productive as possible. Contents The Workspace Areas ....................
The Workspace Areas The term Workspace describes the user interface that you see when you first load the program. The workspace has four principal areas: Command area — At the top of the workspace is the title bar, which displays the file path of the current document.
Exploring the Workspace Setting workspace options Selecting Options > Settings (F8) opens the control center for user preferences. By navigating the feature tree in the left pane, you can view and change options for file management, coding, and testing applications and Web content. Working in the Resource Windows The Resource window is a multipanel interface that lets you switch easily among development resources as you build site content.
Creating and Browsing Files in the Document Window The Document window is where code and other content are entered and edited. Edit tab The Editor has many productivity features for creating and editing code, content, and navigation structures. You can easily insert tags, generate code, and add content from text files, Microsoft Office applications, or directly from the Web.
Exploring the Workspace Tracking Your Work in the Results Window The Results window presents the results of document operations in individual panels. It opens automatically when you run Search, Code Validation, Link Verification, Image Thumbnails, or Project Deployment. You can also open it from the View menu. Right-click in any of the panels to open a context menu.
Printing Help topics If you are using Internet Explorer as the internal browser, you can print a Help topic by right-clicking the document in Browse mode and selecting Print. The default internal browser does not support printing. Bookmarking Help topics You can get quick access to Help documents by bookmarking them.
Exploring the Workspace 2. Enter a word or phrase in the Enter the word(s) to find box. For information on using search operators, click the Search Tips button. 3. To limit the references searched, select the Search only in selected references option and select the check box next to one or more references.
Page 24
To create a new folder in the Help tree: 1. Open the Files panel in the Resources window. 2. Navigate to the Help folder of your installation. 3. Right-click in the files pane and select the Create Folder menu item to open a new folder box in the directory pane.
Exploring the Workspace Adding Help References to the booktree structure If you add a folder to the Help directory, the folder appears at the bottom of the Help References list. For most users, this is all you need. If, however, you want to control the display order of the Help References, you can edit the booktree.xml file in the Help root directory.
Adding media content You have considerable flexibility in adding supporting files (such as graphics, animations, video, and sound) to Help documents. One approach is to create a file structure in the Help tree that conforms to the media file references in your documents.
Page 27
H A P T E R Managing Files This chapter shows you how to work with folders and files. Contents About the Files Tab....................28 Working with Files..................... 29 Changing the File List Display.................. 31 Dragging Files from Windows Explorer ..............31 Building a Favorite Folders List................
About the Files Tab Creating a project is the best way to organize files when developing a Web site or Web applications (see “Using Projects for Site Management” on page 91), but for general file management chores, you work in the Files tab on the Resources window. The Files tab gives you access to servers, drives, directories, and files without having to go to Windows Explorer.
Managing Files Working with Files You can use the following procedures to work with files, regardless of their location (local drive, network drive, or remote server). Setting startup options Open Options > Settings > Startup to select which files and folders open when load the program.
Adding a link to an open file To create a link to a file: 1. Open the page you want to place the link in the Editor window. 2. Drag the file you want to create a link to from the file list to the page in the Editor window.
Managing Files Changing the File List Display You can arrange the file list to display exactly what you want. To filter the file list: 1. Right-click in the file list and choose Filter from the menu. 2. From the Filter submenu, choose the file type you want displayed: Web Documents displays Web documents only.
Building a Favorite Folders List You can build a list of favorite folders to make accessing their files easier. To add a folder to the favorites list: 1. Select the folder in the Directory List. 2. In the file list, right-click and choose Favorite Folders > Add Current Folder to Favorites.
Managing Files Working with Files on Remote Servers Working with directories and files on remote servers is virtually identical to working with them on local or network drives. The primary difference is that you need to establish a connection to a remote server before you can work with its files. The Allaire FTP &...
Downloading Web Pages You can download any HTML page and open it in the editor. These files cannot be saved back to the server. To open a page from a Web site: 1. Choose File > Open From Web. 2. Enter the URL for the page or select from your Bookmarks or Favorites list. 3.
Page 35
H A P T E R Configuring Web Browsers This chapter contains the procedures for configuring Web browsers for use by ColdFusion Studio. Contents Configuring the Internal Browser ................36 Configuring External Browsers ................38...
Configuring the Internal Browser The following sections describe the choices available for browsing documents and processing pages from within ColdFusion Studio. Setting the internal browser options You can use the internal browser to view documents in a Web browser within the program.
Page 37
Configuring Web Browsers Installing Mozilla 1. Downloading the Mozilla binaries. 2. Unzip the Mozilla files into a new directory. 3. Add the Mozilla bin directory to your PATH environment variable and reboot if necessary. If you are using Win 95/98 you may have to specify the short name version of the path, such as, c:\mozil~1\bin If your Mozilla bin directory does not contain a file named component.reg or if that file is smaller than 5KB, then delete it and run mozilla.exe.
Configuring External Browsers As part of the installation process, ColdFusion Studio creates a list of Web browsers that it detects on your system. You can manage the list by selecting the Options > Configure External Browsers menu command. You can easily Add, Edit, and Delete browsers using this dialog box.
Page 39
H A P T E R Connecting to Servers via FTP and HTTP ColdFusion Studio provides FTP server access and secure HTTP access via Remote Development Services (RDS). You can perform file transfers and other file management tasks using either FTP or RDS. To access data sources and to run the debugger, an RDS server connection is required.
Required Server Information You will need specific information about a remote server to connect to it, such as host name and user access requirements. If you do not have this information, you need to get it from the owner of that server, whether it is your IT group, an ISP , or another provider.
Page 41
Connecting to Servers via FTP and HTTP 3. Enter the following information for the server you want to connect to: Description — A descriptive name that will be displayed in the Files tab and in Windows Explorer. Host Name — The server’s domain name, such as allaire.com, or an IP address. Servers that include ftp as part of the domain name require that you enter the complete name, such as ftp.somesite.com.
Overview of Remote Development Services Remote Development Services (RDS) lets you communicate via HTTP with ColdFusion on the local machine and on any configured remote host. RDS features include: Secure server access Data source browsing and SQL query building Remote file access CFML debugging Managing ColdFusion security The ColdFusion installation configures basic security for the server and by default...
Connecting to Servers via FTP and HTTP Configuring an RDS Server Complete the following configuration procedure for each ColdFusion server you want to access. To configure an RDS server: 1. In ColdFusion Studio, click the Files tab at the bottom of the Resources window. 2.
Managing Servers You can easily change server configurations as needed. To view and edit the configuration for a server: 1. Right-click the server name in the Allaire FTP & RDS list and select Properties from the menu. 2. Make any changes necessary in the Configure Server dialog box and click OK. To delete a server: 1.
Page 45
H A P T E R Adding Server Mappings Development mappings are essential for working with files via Remote Development Services (RDS). Contents Understanding Development Mappings..............46 Understanding RDS Mappings ................47 Defining a Server Mapping..................50...
Understanding Development Mappings Development mappings serve two purposes: To enable server-based processing of pages from within ColdFusion Studio To enable debugging of application code on a remote server via RDS Mapping for page processing By default, when you browse a document in the internal or external browser, it is opened from the local file system or returned via FTP from a remote server.
Adding Server Mappings Understanding RDS Mappings File mappings ensure that ColdFusion Studio, the server, and your browser can properly resolve local paths into server paths and URLs. Studio Path — How does ColdFusion Studio see the directory? ColdFusion Path — How does the Web server/ColdFusion server see the directory? Browser Path —...
Page 48
Using drive mappings Developers often debug against a remote server across an internal network. In many cases, they use a network drive mapping. For example, a user may have a remote drive X:\ mapped to a network shared directory \\MYSERVER\WEBPROJECTS\ where WEBPROJECTS is the name of the shared directory in the network server MYSERVER.
Page 49
Adding Server Mappings ColdFusion Studio and the server need to understand how a file location appears to the parties involved. You therefore need to create a mapping for the App1 directory as follows: Studio accesses files on remote CF server using UNC paths/Network Neighborhood Studio path \\MYSERVER\WEBPROJECTS\App1\ Server path...
Defining a Server Mapping The debugger relies on these mappings to communicate the correct file paths of all files with breakpoints to the ColdFusion server. You create these mappings in the Mappings pane of the Remote Development Settings dialog box. To define a server mapping: 1.
Page 51
H A P T E R Writing Code and Web Content ColdFusion Studio can handle many different Web development tasks, from writing simple HTML pages to designing, testing, and deploying complex, dynamic sites. This chapter describes some basic techniques for creating Web content and application code.
Inserting Code The coding tools in ColdFusion Studio support the full range of writing styles, from typing to point-and-click, and you can set the level of support you want. For repetitive chores, you can use its productivity to quickly enter common code blocks and required text.
Writing Code and Web Content Selecting tags from the Tag Chooser The Tag Chooser contains tag sets for languages that are supported by tag editors, the Tag Inspector, Tag Insight, and Tag Tips. To use Tag Chooser: 1. Right-click in the editor and select Insert Tag, or press Ctrl+E to open Tag Chooser. The left pane in Tag Chooser contains a list of supported languages, the right pane shows the individual tags for the selected language folder.
Setting the supported file types for a scheme The color schemes for the supported languages are grouped by file extensions in the Color Coding pane. You can easily change the file types for a scheme. To modify file types for a scheme: 1.
Writing Code and Web Content Using Inline Tools to Enter Code You have a number of tools to help you easily insert new code and to edit existing code as you type. Each of these tools supports a distinct language element, such as tags, objects, and functions.
Writing Code and Web Content Use Design mode to prototype page layouts and to quickly create HTML tables and forms and set font and image formatting. Open Options > Settings > Design to display the Design tab. Add hyperlinks to Web images (gif, jpg) with the Image Map Editor. To get started, open the Tools >...
To copy text from a browser: 1. To strip the HTML formatting code from copied text, select the Treat HTML dropped from external application as plain text option in Options > Settings > Editor. 2. Select the text in the browser that you want to copy. 3.
Writing Code and Web Content Saving Code Blocks as Snippets With Code Snippets, you can easily store code blocks and content for reuse. Comment your snippets just as you would any code block. To create a code snippet: 1. Click the Snippets tab in the Resources window. Before adding a snippet, you need to create a folder.
Sharing snippets You can share code snippets with other developers by giving them access to a shared folder on your machine or on another network machine. To create a shared snippets folder: 1. Open Options > Settings > Locations. 2. Enter a folder path for Shared Snippets and click OK. The new folder appears in the Snippets list.
H A P T E R Accessing Data Sources This chapter describes how to use Studio’s visual tools to significantly accelerate development of data-driven ColdFusion applications. Contents Introduction to Database Tools ................62 Registering Data Sources ..................62 Connecting to Data Sources ..................63 Viewing Data Sources ....................
Introduction to Database Tools Studio’s visual database tools support application development using both local, network, and remote data sources. Access to data sources becomes transparent when a server is configured in Studio. Studio's database tools support: Remote database development Data source schema and data browsing Visual SQL statement building For a full discussion of developing ColdFusion applications using data sources, including requirements for native drivers, see Developing Web Applications with...
Accessing Data Sources Connecting to Data Sources Data sources registered in the ColdFusion Administrator are automatically accessible from Studio’s Database tab. You can also add remote ColdFusion servers (RDS) to connect to their data sources. To add a remote server: 1.
Using SQL Builder Studio provides a powerful visual tool to build, test, and save SQL statements for use in data queries. Select a query type from the SQL Builder toolbar or right-click in the Table pane and choose from the Query Type list. To open SQL Builder choose one of these methods: Right-click on a database or a table in the Database tab and choose New Query.
Accessing Data Sources The SQL Builder is divided into four sections: Toolbar — Contains icons for SQL keywords and commands. Table pane — Provides a view of the tables in your query and allows you to create joins between tables. Properties pane —...
Building a SELECT Statement SQL SELECT statements let you specify the data from which to build a recordset. This procedure begins with SQL Builder open. To optimize performance, tables are only retrieved on an as needed basis. To create a SELECT statement: 1.
Accessing Data Sources Testing a Query You can test your SQL code in SQL Builder before inserting it in a page. To run a query in the SQL Builder: 1. Click the Run Query button. 2. You are prompted to enter values for any CFML variables in the query. Note When you click the Run Query button, the SQL statement is actually processed.
Inserting SQL into a Page You can use any of the following methods to insert a query directly into a CFML page from the SQL Builder: If you open the SQL Builder from the CFQUERY tag editor, it prompts you to insert the query when you close the editor.
Page 69
H A P T E R Exchanging Data via XML You can now move complex data structures across the Web using Web Distributed Data Exchange (WDDX). This new capability is based on XML 1.0 and can be used to exchange data between CFML applications and other applications. Additionally, server-to-browser and browser-to-server JavaScript data exchanges can be instantiated using WDDX.
An Overview of Distributed Data for the Web Web Distributed Data Exchange (WDDX) is an Extensible Markup Language (XML) vocabulary for describing complex data structures such as arrays, associative arrays, and recordsets in a generic fashion so they can be moved between different application server platforms and between application servers and browsers using only HTTP.
Exchanging Data via XML versioning, allowing these and other enhancements to be folded into the specification as they become available without disrupting working applications. Working with Application-Level Data The real strength of WDDX is clear if the client and server are seen as a unified platform for applications.
In the CFML implementation, is a property of the CFWDDX useTimezoneInfo Action=Cfml2WDDX tag. In the COM implementation, is a property useTimezoneInfo of the IWDDXSerializer interface provided by the object . In the JS WDDX.Serializer.1 implementation (note the case-sensitivity of JS) is a property of the useTimezoneInfo WDDXSerializer object.
Exchanging Data via XML Converting CFML Data to a JavaScript Object The following example demonstrates the transfer of a CFQUERY result set from a CFML template executing on the server to a JavaScript object that is processed by the browser. The application consists of five principal sections: Running a data query Calling the WDDX JavaScript utility...
Page 74
o += "<table cellpadding=3pt><tr>"; for (i = 0; i < colNames.length; ++i) o += "<td>" + colNames[i] + "</td>"; o += "</tr>"; for (row = 0; row < nRows; ++row) o += "<tr>"; for (i = 0; i < colNames.length; ++i) o += "<td>"...
Exchanging Data via XML Transferring Data from Browser to Server This example serializes form field data, posts it to the server, deserializes it, and outputs the data. For simplicity, only a small amount of data is collected. In applications where complex JavaScript data collections are generated, this basic approach can be extended very effectively.
Page 76
Last name: <input type=text name=lastName><br> <p> <!--- Navigation & submission bar ---> <input type="button" value="Next" onclick="doNext()"> <input type="button" value="Serialize" onclick="serializeData(personInfo, document.personForm.wddxPacket)"> <input type="submit" value="Submit"> <p> <!--- This is where the WDDX packet will be stored ---> WDDX packet display:<p> <textarea name="wddxPacket" rows="10" cols="80" wrap="Virtual"><...
Page 77
H A P T E R Editing Pages Editing chores are made easier by a wealth of interface options and tools for updating code and content. Contents Setting Options on the Editor Toolbar..............70 Selecting Code and Text Blocks................70 Saving Text to the Multiple-Entry Clipboard ............
Setting Options on the Editor Toolbar The column between the Document window and the Resources window contains a set of handy toolbuttons for: Document handling Formatting Switching between open documents Toggling inline coding tools Displaying the document gutter for line numbers and bookmarks You can set bookmarks in the gutter by selecting the Edit >...
Editing Pages Customizing clipboard commands The clipboard buttons can be added to custom toolbars using the Options > Customize menu command. The buttons are located in the Edit toolbutton section. Keyboard shortcuts can be assigned to these features, as well. The shortcut descriptions are Show clipboard, Paste all, and Clear clipboard.
To work with collapsed text: Double-click a collapsed text marker to expand the text. To expand all collapsed text, right-click anywhere in a document and select Expand All from the popup menu. You can drag collapsed text just like regular text blocks. Collapsed text blocks can be nested within each other.
Page 81
Editing Pages 3. Click the Refresh button to update the Tag Tree as you edit the document. You can click the Collapse button on the Tag Tree toolbar to collapse the selected tag. Note that the tag body must be collapsed in the Tag Tree to collapse it in the document. The default set of profiles gives you a lot of options for filtering the outline, but you can easily customize profiles.
Editing code in the Tag Inspector The Tag Inspector lets you edit code in a property sheet interface that will be familiar to Visual Basic and Delphi programmers. Setting the display Buttons at the top of the Inspector pane control the way attributes and scripting events are displayed.
Editing Pages The best way to create a new tag definition file is modify an existing VTM file and save it with the tag’s name. You can also open \Extensions\TagDefs\TagDefTemplate.vtm to work with a skeleton definition file. To add online help for the tag, create an HTML file containing the help text and save it with the tag name in the appropriate language folder in \Extensions\Docs.
Preserving Code Formats with CodeSweepers The CodeSweeper feature automates the task of getting your code properly formatted. It can be very useful in a number of situations: To enforce coding styles for multiple developers. To clean up the formatting of existing code. To apply formatting rules when using Design mode to visually edit pages.
Editing Pages Running a CodeSweeper Open the Tools > CodeSweeper menu to select a CodeSweeper or click the CodeSweeper button on the Tools toolbar to run the default on the current document. Click the down arrow button next to the CodeSweeper button to select from the list of available CodeSweepers.
Managing CodeSweepers You can create new CodeSweepers, edit existing ones, and remove them as needed. To add a new CodeSweeper: 1. Click the New Profile button in the Allaire CodeSweepers panel. 2. Enter a name for the CodeSweeper and select its type: Allaire or HTML Tidy. 3.
Page 87
Editing Pages Tag-specific settings A wide range of options is available for the individual tags contained in an Allaire CodeSweeper. These settings cover spacing and indenting and allow you to leave the selected tag unchanged when invoking the CodeSweeper. If you are encountering problems parsing server-based script code, then enable the Preserve tag formatting option.
HTML Tidy settings Adding a profile Creating a custom HTML Tidy profile is much like creating one for an Allaire CodeSweeper. To create an HTML Tidy profile: 1. Click the New Profile button in the HTML Tidy CodeSweeper dialog box. 2.
Editing Pages Formatting Pages with Cascading Style Sheets Cascading Style Sheets (CSS) can be added at any point in a site’s development process, but ideally the design specification for a site will be implemented via style sheets, eliminating the need to code and maintain formatting for individual tags. More significantly, CSS lets developers and content providers focus on organizational and navigation issues by separating formatting from content.
H A P T E R Debugging Application Code from ColdFusion Studio Debugging information reported from the ColdFusion Application Server is often adequate for simple templates, but complex development tasks require a more powerful and immediate debugging interface. Studio’s Interactive Debugger runs against dynamic pages on the ColdFusion Server. You can set breakpoints and step through the code to isolate and correct problems.
Interactive Debugger Overview You can run the debugger against the ColdFusion application pages. The debugger lets you: Set breakpoints and watches Evaluate variables and expressions Step through lines of code Investigate the code stack Monitor recordsets Observe variables in all scopes Use the Debug menu or the Debug toolbar to run debugging processes.
Debugging Application Code from ColdFusion Studio Specifying Server Mappings The debugger relies on these mappings to communicate the correct file paths of all files with breakpoints to the ColdFusion server. See “Adding Server Mappings” on page for a full discussion. You create these mappings in the Mappings pane of the Remote Development Settings dialog box.
Running the Interactive Debugger Running the debugger helps you find problems in code by tracing the way ColdFusion evaluates the page, step by step. You do this by placing breakpoints in the page to stop execution of the page, and then step through subsequent lines of code, checking the values of variables and expressions to make sure the code is behaving as you’d expect.
Debugging Application Code from ColdFusion Studio 5. Enter a user name and password if necessary to access remote servers. The debugger starts, and it forwards your URL to the Browse view. When the ColdFusion server encounters the breakpoint, a blue bar appears at the breakpoint in the Edit view.
Debugging across multiple pages The debugger is active even after a page is loaded, and until you press the End button on the Debug toolbar or choose Debug > End. This enables you to debug applications across multiple HTML and CFML pages. For example, you can test the submittal of an HTML form and its subsequent processing by a ColdFusion application page.
Page 97
Debugging Application Code from ColdFusion Studio 3. Select Evaluate to find the value of the expression at the next breakpoint or line where the Debugger stops. The Evaluator window shows the results of the evaluation at the current point in processing the page.
Debugger Shortcut Keys Here is a complete listing of keyboard shortcuts. Debugger Keyboard Commands Command Start/Continue Ctrl + F5 Alt + F5 Step into Ctrl + F8 Step over Ctrl + F9 Step out Ctrl + F10 Run to cursor Ctrl + F11 Variables Alt + Q...
Page 99
H A P T E R Using Projects for Site Management This chapter describes how to use the project tools in ColdFusion Studio to create and maintain Web sites. Contents What is a Project? ...................... 92 Creating a Project ...................... 92 Working in the Project Resources Window .............
What is a Project? The project features allow you to create your own file system that contains only those files you need to develop your Web site. The benefits of projects include the following: Projects make it possible to have all of the files you need to build your Web site located in a central, easily accessible location.
Using Projects for Site Management Working in the Project Resources Window Click the Projects tab at the bottom of the Resources window to create new projects and to manage existing ones. The drop-down project list is at the top of the pane. The project toolbar is next to it. Below the projects list box are the folders and files panes.
Manual-inclusive and auto-inclusive physical folders Physical folders can be divided into auto-inclusive and manual-inclusive. Manual-inclusive folders require you to specify which files in the mapped directory should be included in the folder. For example, you might have a folder with ten files in it, only three of which are necessary for your Web site. You can create a manual-inclusive folder, add just those three files, and ignore the other seven.
Using Projects for Site Management Folder types The following table shows the icon for each folder type and a description of when you should use each folder type: Icon Folder Type Usage Virtual folder Use when you want to organize files from several different locations into one location.
To delete a project: 1. Right-click the project and select Delete Project from the menu or select Project > Delete Project. You are asked to confirm that you want the project deleted. 2. Click Yes. The project is removed from the Projects panel and the apf file is deleted from your computer.
Page 105
Using Projects for Site Management 4. Enter the path for the directory to be referenced in the Directory Path box or click the Browse button to locate the directory using the Select Directory dialog box. 5. Click OK. The folder is added to your project. In order to populate the folder with files, you will have to add them manually.
Working with files You can now begin to work with files. The methods for working with a file can vary slightly, depending on the type of folder that contains the file. Standard drag operations can be performed to move files from the Projects file list into Project folders.
Using Projects for Site Management Files in auto-inclusive folders You control the files that are included in an auto-inclusive folder by specifying the files types that are allowed. You can change the file types at any time to alter the included files.
To add a resource from the Projects tree: 1. Right-click Resources in the project folder pane and select Add Resource. 2. In the Add Resource Folder dialog box, enter a name for the resource in the Resource Name box. 3. Enter the file extension(s) of resource types in the Resource Filter box, separating multiple extensions with semicolons.
Using Projects for Site Management Working in a Source Control System An additional benefit of creating projects is that you can manage project files in a source control system. Why use source control? Version source control for Web site content is an essential for coordinating team development of complex projects.
Setting up a project in source control The following procedure takes you through the steps of creating Microsoft Visual SourceSafe project, and then adding ColdFusion Studio project files to source control. You can adapt this procedure to work in your particular development environment. Visual SourceSafe uses the term "project"...
H A P T E R Deploying Projects Deployment is the process of copying all of the files in your project to one or more host servers. You can specify a deployment path for the entire project or for individual folders. This chapter describes how to specify options and to deploy a project.
Setting Project Level Deployment You only need a path entry to set the deployment for a project. To specify a deployment path for the project: 1. Open the project in the Projects panel. 2. Right-click the project root and select Properties. The Edit Project Properties dialog box appears.
Deploying Projects Pathnames to remote servers use forward slashes. FTP servers do not use drive letters. An FTP example looks like this, MyDirectory/MySubdirectory. Typically, the pathname you enter does not include the server name for the host, so the program automatically appends the server name to the path when you select which servers you want to deploy to in the Deployment Wizard.
When you deploy your project, you select servers from this list. Note When you deploy to multiple servers, the project files are copied to identical locations on each server, so make sure that those servers contain the same directory structure. Running the Deployment Wizard You can use the Deployment Wizard to accomplish the following tasks: Deploy a project directly to one or to multiple host servers.
Deploying Projects Using deployment scripts You can create a deployment script that you can run at any time. The most powerful benefit of scripts is that, once they have been generated, they can be modified with custom code and saved. Deployment scripts are based on the Allaire Visual Tools Object Model (VTOM) and can be generated in either JScript or VBScript.
Managing deployment scripts Expand the Deployment Scripts node and right-click a script to edit it, run it, see its properties, or remove it. Saving deployment results You can review the results of the last deployment by selecting View > Results > Deployment.
Page 117
H A P T E R Testing and Maintaining Web Pages As your Web site develops, you will inevitably need to make changes and test its accuracy, completeness, and efficiency. HomeSite provides a full set of tools to accomplish these necessary tasks. Contents Working in the Results Window ................
Working in the Results Window The Results window is a tabbed interface that opens to view the results when you run any of the following commands: Extended Find and Replace Code Validation Link Verification Image Thumbnails Project Deployment You can use the Tab and Shift+Tab keys to move among the Results panes. Saving results Results for each of these operations are preserved when you move from panel to panel and when you close the Results window.
Testing and Maintaining Web Pages Using the Find and Replace Feature The Search menu gives you access to basic and extended searches and to automated replacement of extended characters and double-spacing. The Search tab in the Results window displays the results of extended operations. Search text selection options Selecting text in a document automatically inserts it in the Find what text box.
Page 120
2. Enter the text in the Find and Replace boxes. 3. Set the Match whole words and Match case options. In addition to the Up and Down Direction options, you can restrict the search to part of the document by highlighting a block of text in the editor and selecting Selection.
Page 121
Testing and Maintaining Web Pages Replacing extended and special characters Use the Search > Replace Extended Characters command to either replace extended characters with character entities, or replace character entities with the equivalent extended characters. This command works only in the current document. Replacing double-spaced lines Because of the way different operating systems treat carriage returns, text files saved on UNIX or Macintosh systems might become double-spaced when opened in Studio.
Page 122
Single-character regular expressions This section describes the rules for creating regular expressions. You can use regular expressions in the Search > Extended Find and Replace commands to match complex string patterns. The following rules govern one-character RegExp that match a single character: Special characters are: + * ? .
Page 123
Testing and Maintaining Web Pages The following table shows supported POSIX character classes: Character Class Matches alpha Any letter [A-Za-z] upper Any uppercase letter [A-Z] lower Any lowercase letter [a-z] digit Any digit [0-9] alnum Any alphanumeric character [A-Za-z0-9] xdigit Any hexadecimal digit [0-9A-Fa-f] space A tab, new line, vertical tab, form feed, carriage return, or space...
Page 124
Using back references HomeSite supports back referencing, which allows you to match text in previously matched sets of parentheses. You can use a slash followed by a digit n (\n) to refer to the n parenthesized subexpression. One example of how you can use back references is searching for doubled words, for example, to find instances of "is is"...
Page 125
Testing and Maintaining Web Pages Expression examples The following examples show some regular expressions and describe what they match Expression Description [\?&]value= A URL parameter value in a URL [A-Z]:(\\[A-Z0-9_]+)+ An uppercase DOS/Windows full path that (a) is not the root of a drive, and (b) has only letters, numbers, and underscores in its text [A-Za-z][A-Za-z0-9_]*...
Checking Spelling Open Options > Settings > Spelling to select a spell checker and to set options. To run the spell checker select one of these commands: Select Tools > Spell Check to process the active document or Tools > Spell Check All to process all open documents.
Testing and Maintaining Web Pages Validating Code You can use HomeSite code validation to check and report on syntax errors in HTML (including browser extensions), CFML, and SMIL. Double-click an error message to highlight it in the document. Using the default validator Open Options >...
Verifying Hyperlinks HomeSite makes the job of maintaining sites easier by testing each link in a selection and reporting any problems it finds. You can verify links to local HTML files, graphics and other media files and other Web sites. By default, all links in a selection are checked, but you can optionally skip specific links.
Page 129
Testing and Maintaining Web Pages To verify links in a project: 1. Right-click a project name in the Projects panel of the Resource window and select Verify Links. 2. In the Verify Links in Project dialog box, select a root URL option for the project files.
Customizing the Development Environment This chapter details the Allaire Visual Tools Markup Language (VTML), a tag-based language that is used internally by the Allaire Visual Tools — HomeSite, ColdFusion Studio, and JRun Studio — to generate tag-specific dialogs for editing HTML, CFML, JSP , JavaScript, and ASP language elements.
The Visual Tools Markup Language (VTML) The phrase "customizing the development environment" means that you can change the content and layout of tag editors by editing VTML files directly in the Allaire Visual Tools. This makes it easy to update tag syntax or change embedded Help text. You can also create your own editors.
Page 133
Two VTML tags, , let you customize the content of these dialog boxes:...
Dialog Definition Files The structure of the markuptags.vtm and expressionelements.vtm files is very simple. They both contain a set of category and element tags. Category tags can contain any number of elements or other nested category tags. <CAT … main category> <CAT …...
Element tag The E tag defines elements within a category. These elements populate the right pane in the Tag Chooser and the Expression Builder. The following table describes the tag. Element Tag <E …/> CAPTION The caption of the element. TYPE Used only for elements in Expression Builder which describe a function.
Creating a tag definition file You can customize existing tag definitions and create new tag definition files. Every tag editor file contains the following markup structure: <TAG> <ATTRIBUTES> … Defines tag attribute properties and behavior </ATTRIBUTES> <ATTRIBCATEGORIES> … Defines logical grouping for tag attributes </ATTRIBCATEGORIES>...
Defining attributes The ATTRIBUTES block defines attributes inside the main TAG block. The ATTRIBUTES block can only contain tags. The following example ATTRIB demonstrates the definition of four tag attributes: , and VALUE TITLE ALIGN <ATTRIBUTES> <ATTRIB NAME="VALUE"> <ATTRIB NAME="TITLE"> <ATTRIB NAME="ALT">...
Page 138
Defining enumerated values Enumerated values can be specified for attributes of TYPE="Enumerated." A subtag ATTRIBOPTION is used to specify such values: <ATTRIB NAME="CHARSET" TYPE="ENUMERATED"> <ATTRIBOPTION VALUE="iso-8859-1" CAPTION="Western" /> <ATTRIBOPTION VALUE="iso-8859-2" CAPTION="Central European (ISO)" /> <ATTRIBOPTION VALUE="iso-8859-8" CAPTION="Hebrew (ISO-Visual)" /> </ATTRIB> The optional CAPTION attribute specifies the form in which the option appears in the drop-down lists, while the VALUE attribute specifies the underlying value used by the attribute.
ATTRIB Tag Attributes (Continued) CACHEFAMILY (Optional) The name of the cache family associated with the attribute. Colors FontFaces FilePaths Styles Images URLs EventHandlers The following apply to ColdFusion Studio and JRun Studio attributes ONLY: QueryNames CFExpressions VerityCollections DataSources CFIncludes You can specify a custom cache family, such as CACHEFAMILY="NewCacheFamily"...
The following table describes the ATTRIBGROUP ATTRIBGROUP Tag Attributes NAME The name of the category. ELEMENTS The list of attributes included in the category. Building Tag Editors Defining a Tag Editor is composed of three tasks: Layout of dialog box controls Definition of how to populate controls with tag attributes Definition of the tag generation template Open the \Extensions\TagDefs\mytag.vtm file to see how these tasks are coded.
Defining controls This section contains only two kinds of tags: tags. CONTROL CONTAINER CONTROL tags represent graphical controls. The tags are identical in definition, with CONTAINER the exception that only tags have the capability to contain tags. CONTAINER CONTROL A Panel control is a good example of a control that can be a containing a CONTAINER , such as Labels or TextBoxes.
Page 142
The following table describes the tags. CONTROL CONTAINER CONTAINER/CONTROL attributes TYPE Available container types are: TabDialog TabPage Panel Type of the control/container. Available control types are: Label TextBox CheckBox RadioGroup DropDown TextArea FontPicker ColorPicker Image FileBrowser SQLTextArea ActiveX ListBox ImageMapTextArea StyleTextBox StyleTextArea NAME...
CONTAINER/CONTROL attributes (Continued) WIDTH Width of the control. Can be specified in three ways: In pixels (for example., WIDTH=200). As the name of another control (for example., WIDTH="SomeControl"). In this case the width of the specified control is used. The control must be already positioned.
you can have multiple tags with the same . This is common for more ATTRIB NAME complex tag editor dialog boxes where a single attribute value may have to be filled into multiple controls. Special ATTRIB tag variable names The following special variables can be used: $$TAGBODY —...
Special variables In addition to the variables, a few other parameters get sent to the tag layout CONTROL template: OPTIONLowerCaseTags — returns true or false. Specifies whether the tag should be generated using lowercase. EDITORTagIndentString — maintains indentation for tag attributes and body. OPTIONLinearLayout —...
Page 146
<MYTAG COLOR="$${clrBGColor}"$${Spacer}FACE="$${fontFace} "$${Spacer}SIZE="$${txtSize}"> </TAGLAYOUT> The template would generate a tag based on the following layout preference: LINEAR: <MYTAG COLOR="White" FACE="Arial" SIZE="10"> NONLINEAR: <MYTAG COLOR="White" FACE="Arial" SIZE="10"> Using TAGDATAUnknownAttributes tag contains the list of attributes that are contained TagDataUnknownAttributes in the original tag string but are not supported by the editor. For example, you can write an editor for the HTML tag .
Adding Tag Help You can associate an HTML-based Help document with a tag by embedding the Help text inside the block. TAGDESCRIPTION TAGDESCRIPTION example Here’s an example of a tag description block and the result in a Tag Editor: <TAGDESCRIPTION HEIGHT=100> <B>CFAPPLICATION</B>...
VTML Container/Control Reference This section contains the complete syntax, with examples, for VTML containers and controls. TabDialog container The following table describes the TabDialog container. <CONTAINER TYPE="TabDialog" …/> TabDialog control is a special container control, because it can only contain <CONTAINER TYPE="TabPage">...
Page 149
TabPage container The following table describes the Tab Page container: <CONTAINER TYPE="TabPage" …/> TabPage control is also special because it can only be contained inside a TabDialog CONTAINER control. NAME In the ATTRIBUTES section of a Tag Definition, a TabDialog can be bound as a CONTROL to an attribute named TYPE.
Page 150
Panel container The following table describes the Panel container. <CONTAINER TYPE="Panel" …/> Panel is the most common container control. Panel can contain any control or container except TabPage, which is restricted to TabDialog. CAPTION Caption displayed in the upper left corner of the panel boundary. Panel example <EDITORLAYOUT HEIGHT=225>...
Page 151
</CONTROL> </CONTAINER> <CONTAINER NAME="Panel2" TYPE="Panel" CAPTION=" Panel 2 " ANCHOR="Panel1" CORNER="SW" DOWN=5 WIDTH="MAXIMUM" HEIGHT=MAXIMUM </CONTAINER> </CONTAINER> <CONTAINER NAME="Advanced" TYPE="TabPage" CAPTION="Advanced"> </CONTAINER> </CONTAINER> </EDITORLAYOUT> Label control The following table describes the Label control: <CONTROL TYPE="Label" …/> A label can serve as a caption for an input control and can display extra information about the dialog.
Page 152
<CONTROL TYPE="Label" …/> TRANSPARENT YES/NO. Makes label transparent. ALIGN LEFT/CENTER/RIGHT. Specifies the horizontal alignment of text in the label. VALIGN TOP/CENTER/BOTTOM. Specifies the vertical alignment of text in the label. Label example <CONTROL NAME="lblSource" TYPE="Label" CAPTION="Source:" DOWN=17 RIGHT=10 WIDTH=50/> TextBox control The following table describes the Text Box control.
Page 153
<CONTROL TYPE="TextBox" …/> (Continued) CHARCASE NORMAL/UPPER\LOWER. Specifies whether entered text is automatically uppercase or lowercase. The default is NORMAL, preserving the entered case. VALIGN TOP/CENTER/BOTTOM. Vertical alignment of text in the label. TextBox example <CONTROL NAME="lblSource" TYPE="Label" CAPTION="Source:" DOWN=17 RIGHT=10 WIDTH=50/>...
Page 154
DropDown example <CONTROL NAME="lblAlign" TYPE="Label" CAPTION="Align:" ANCHOR="lblSource" CORNER="SW" DOWN=11 WIDTH=50/> <CONTROL NAME="dropAlign" TYPE="DropDown" ANCHOR="lblAlign" CORNER="NE" WIDTH=100> <ITEM VALUE="TOP" CAPTION="TOP" /> <ITEM VALUE="MIDDLE" CAPTION="MIDDLE" SELECTED/> <ITEM VALUE="BOTTOM" CAPTION="BOTTOM" /> </CONTROL> ListBox control The following table describes the ListBox control: <CONTROLTYPE="ListBox" …/> MULTISELECT The MULTISELECT attribute decides whether the user can select multiple items.
Page 155
FontPicker example <CONTROL NAME="lblFace" TYPE="Label" CAPTION="Font:" DOWN=17 RIGHT=10 WIDTH=50/> <CONTROL NAME="fontFace" TYPE="FontPicker" ANCHOR="lblFace" CORNER="NE" WIDTH="MAXIMUM"/> ColorPicker control The following table describes the ColorPicker control: <CONTROL TYPE="ColorPicker" …/> A simple drop-down color picker. Enables selection of a predefined color or special color code.
Page 156
CheckBox control The following table describes the CheckBox control: <CONTROL TYPE="CheckBox" …/> A simple check box control. Returns ‘true’ or ‘false’ . CAPTION Caption displayed next to the check box. CHECKED YES/NO. Specifies initial status.
Page 157
Checkbox example <CONTROL NAME="checkNoShading"TYPE="CheckBox" CAPTION=" No Shading" ANCHOR="numWidth" CORNER="NE" DOWN=4 RIGHT=20 WIDTH=MAXIMUM/ > RadioGroup control The following table describes the RadioGroup control: <CONTROL TYPE="RadioGroup" …/> A set of radio buttons. This tag requires <ITEM> sub-tags that specify the list of radio buttons.
Page 158
Replaces the existing file if name conflict occurs." /> <ITEM VALUE="MAKEUNIQUE" CAPTION="MAKEUNIQUE - Automatically generates a unique filename for the upload." /> </CONTROL> TextArea control The following table describes the Text Area control: <CONTROL TYPE="TextArea" …/> A simple multiline text entry control. SCROLLBAR NONE/HORIZONTAL/VERTICAL/BOTH.
Page 159
TextArea example <CONTROL NAME="txtContent" TYPE="TextArea" DOWN=5 RIGHT=5 WIDTH=MAXIMUM HEIGHT=MAXIMUM MAXWIDTHPADDING=5 MAXHEIGHTPADDING=5/> SQLTextArea control The following table describes the SQLTextArea control: <CONTROL TYPE="SQLTextArea" …/> (ColdFusion Studio and JRun Studio) A multi-line text entry control that allows the user to execute an SQL statement. The control contains a button that the user can use to invoke the query builder.
Page 161
FileBrowser control The following table describes the FileBrowser control: <CONTROL TYPE="FileBrowser" …/> A text box used to enter a file path. The control contains two toolbar buttons providing accessibility to local and remote file/directory browsing. FILTER The file filter that should be used by the file/directory browsing dialog boxes.
Page 162
<CONTROL TYPE="FileBrowser" …/> (Continued) FILENAMEONLY YES/NO. Specifies that only a file name should be entered into the text box when a file is specified in a local or remote file dialog box. By default the entire path would be pasted. The attribute is irrelevant when the DIRONLY attribute is used.
Page 163
Image control The following table describes the Image control: <CONTROL TYPE="Image" …/> An image control capable of containing BMP images. FILEPATH Specifies the relative path of the image file from the editor template. AUTOSIZE YES/NO. Automatically sizes the control to the image it contains. This option is overridden if WIDTH or HEIGHT are explicitly specified.
Page 164
The following table describes the Style Text Area control: <CONTROL TYPE="StyleTextArea" …/> SCROLLBAR NONE/HORIZONTAL/VERTICAL/BOTH. Specifies which scrollbars should be displayed. WRAP Enables wrapping of text. Disabled when a horizontal scrollbar is shown with SCROLLBAR="Horizontal" or SCROLLBAR="Both" even when the flag is present. INLINESTYLE YES/NO.
Building Custom Wizards This section describes how to give users an easy way to enter information that can then be published on the Web or used to drive ColdFusion applications. Wizards are an integral part of many software products today because they invite users to perform complex tasks in an orderly, comprehensible interface.
Creating Wizard Definition Pages The first step in building a custom wizard is to write a VTML file to define the interface and output parameters. This section describes the VTML tags used in this part of the process and presents an example definition file. VTML for Wizards tag summary The following is the hierarchy of the tag set for wizard definition files: WIZARD —...
Page 167
The following table describes the PARAM tag for the WIZARD tag. Attribute Description NAME Name of the parameter. VALUE Initial value of the parameter. REQUIRED Optional. The wizard manager will not enable the Finish button until all required parameters are entered. The following table describes the TEMPLATE tag.
The following table describes the PARAM tag for the PAGE tag. Attribute Description NAME Name of the parameter. VALUE Value of the parameter. REQUIRED True/False or YES/NO (can be the result of a dynamic expression). Determines whether a value for the parameter is required. The Wizard manager will not enable the Finish button until all required parameters are entered.
<PARAM NAME="RowsPerPage" VALUE="10" REQUIRED="$${ ParameterExists('Customize') }"> Or, to customize the OUTPUTFILE attribute of the TEMPLATE tag using a name attribute entered by the user, you would use the following syntax: OUTPUTFILE="$${Name}Admin.cfm"> The expression syntax supported within the wizard configuration file is the same as the one supported in wizard output templates (see the reference section for more details).
Creating Wizard Output Templates The Wizard Markup Language (WIZML) enables the customization of files produced by the wizards. WIZML is used inside the templates to dynamically create files based on the data provided by the wizard. For example, if a wizard generates a tag called with a single attribute , the template could look as simple as this: <GIZMO>...
String functions Compare CompareNoCase Find FindNoCase LTrim RTrim Trim LCase UCase Left Right RepeatString Runtime functions ParameterExists SetVariable Evaluate The syntax and behavior of all of these functions is identical to the equivalent functions in ColdFusion, except for , which takes a string argument ParameterExists rather than a direct variable reference.
Special considerations Strings used within an output template tag attribute use the C-language convention (\) for escaping special characters. For example, the following attribute uses a newline character to split the value into two lines: CAPTION="This is line one\nThis is line two" Other special characters of note include carriage-return (\r), tab (\t), and slash (\\).
Page 175
WIZLOOP Tag Attributes (Continued) Attribute Description (Continued) STEP Step value for each increment (can be positive or negative). CONDITION Conditional expression to control whether the loop should be exited. LIST A list of CommaText format. This is the format that a Delphi-based string list uses to store textual representations of itself.
Wizard Definition Page Library A set of seven page definition files is available in ColdFusion Studio and JRun Studio. The library can be used to quickly build data access capabilities into wizards. This section is included for HomeSite users who may want to upgrade to use these additional features.
Page 177
RemoveParams — Comma-delimited list of parameters that should be removed if user reselects the data source. Example <PAGE name="DataSource" type="SelectDataSource" caption="Data Source" image="..\\images\\SelectData.bmp"> <PARAM name="ListBoxLabel" value="Select data source:"> <PARAM name="ListBoxDescription" value="Choose the data source from which you would like to display data.\n\nIf your database is not registered as ODBC data source,...
Page 178
Example <PAGE name="Tables" type="SelectTables" caption="Tables" image="..\\images\\SelectTable.bmp"> <PARAM name="DataSource" value="$${DataSource}"> <PARAM name="ListBoxLabel" value="Select database tables:"> <PARAM name="ListBoxDescription" value="Please specify the tables which will be involved in this application. This should include any tables against which would like to search or tables containing data that will be displayed on either the Result or Detail pages.\n\nPress Ctrl or Shift together with the mouse click in order to select more...
Page 179
Example <PAGE name="Table" type="Table" caption="Table" image="..\\images\\SelectTable.bmp"> <PARAM name="DataSource" value="$${DataSource}"> <PARAM name="ListBoxLabel" value="Select database table:"> <PARAM name="ListBoxDescription" value="Records from this table will be displayed in the record viewer."> <PARAM name="RemoveParams" value="Table,ViewFields,EditFields, UniqueIdentifier"> <INPUT name="cbTables" param="Table" required="yes" validationMsg="You didn't select the table. Please select before proceeding.">...
Page 180
SelectFields This page displays all fields from the specified tables and lets the user select one or more of them. Exposes controls lstFields (dropdown) — The control lists fields in the tables specified in the Tables parameter. The control exchanges with the bound parameter a comma-delimited list of selected fields, where each item is in format "table.field=type,size,required".
Page 181
SelectField This page lets the user select one field from the list of fields. The list of fields contains all fields from the specified tables. Exposes controls cbFields (required) — The control lists fields in the tables specified in the Tables parameter.
Page 183
Scripting the Visual Tools Object Model This chapter describes how to program the Visual Tools Object Model to call functionality for their applications and how to write scripts to control HomeSite, ColdFusion Studio, and JRun Studio functions. Contents Writing and Executing Scripts in Allaire Visual Tools........... 192 Application Object ....................
Writing and Executing Scripts in Allaire Visual Tools The Allaire visual tools — HomeSite, ColdFusion Studio, and JRun Studio — expose an Object Model, enabling developers to manipulate program functionality from external applications. In addition, power users can create scripts using JScript or VBScript and execute them from within the visual tools environments to automate tasks.
Page 185
Executing scripts Once you have written a script, you can create a custom toolbutton to execute it from within the program. If you intend to write multiple scripts, you will want to create a toolbar for them. To create a toolbar for custom scripts: 1.
Application Object You can script the Application object’s child objects to perform common tasks and to create toolbars dynamically. General properties ActiveDocument (object, read-only) The active document. See “ActiveDocument Object” on page 218 for details. ApplicationType (integer, read-only) The current application type. 0 - HomeSite 1 - ColdFusion Studio 2 - JRun Studio...
Page 187
AppPath (OleString, read-only) Path to application executable. CurrentFolder (OleString) Path currently displayed in the local file list. CurrentView (ITCurrentViewType) Sets/gets the current view. Allowed values are: 1 - vwEditSource 2 - vwPreview (browse) 3 - vwDesign DocumentCache (array of objects, read-only) See “DocumentCache Object”...
Page 188
VersionText (OleString, read-only) Application name and version. Width (integer) Width in pixels of the main application window. You can use this property with the Height property to investigate the size of the main window as well as to resize the window.
Page 189
ExtractFilePath function ExtractFilePath(const wsFile: WideString): WideString Returns the path of the passed file (includes trailing ‘\’). GetApplicationSetting function GetApplicationSetting(nSettingID: Integer) Retrieves a specific application setting based on a SettingID. GetImageSize function GetImageSize(const wsImageFile: WideString; var nHeight, nWidth: Integer): WordBool Retrieves the size of the passed image. Returns False on error. GetMemoryStatus function GetMemoryStatus(iMemType) Returns an integer value.
Page 190
GetURL function GetURL(const wsURL: WideString): widestring Retrieves a URL and returns its contents. GetURLStatus function GetURLStatus(const wsURL: WideString; var vResponse: OleVariant): Integer Returns the HTTP status code for the passed URL. The text of the server response is returned in the second parameter. HideProgress procedure HideProgress() Hides the progress bar.
Page 191
InstallParserScript function InstallParserScript(const wsScriptFile, wsFileExtAssoc: WideString): WordBool Installs a parser (color-coding) script and associates it with the passed list of semi-colon separated file extensions. If an existing parser is assigned to any of these extensions, they are removed from the existing parser and assigned to the new one. The parser script is copied from the passed location to the application \Parsers subdirectory.
Page 192
OpenFile function OpenFile(const wsFile: WideString): WordBool Opens the passed file, returning True if successful. Return True if the file is already open. Passing an empty string to will display the "Open File" dialog box, OpenFile enabling the user select the file(s) to open. When using this method in JScript, you must escape backslashes inside a string.
Page 193
SetActiveResults procedure SetActiveResults(resType: TCurrentResultsType) Sets the active page in the results tab. Allowed values are: resSearch resValidator resLinks resThumbnails SetApplicationSetting procedure SetApplicationSetting(nSettingID: Integer ovSettingVal: OleVariant) Sets a specific application setting based on its SettingID. SetProgress procedure SetProgress(nProgress: Integer) Sets the position of the progress bar in the status area. Allowed values are 1-100. SetStatusText procedure SetStatusText(sMessage: OleString) Sets the text to be displayed in the status area.
Page 194
StatusError procedure StatusError(const wsMsg: WideString) Displays an error message in the status bar - message will appear on a red background and display for at least 5 seconds. StatusWarning procedure StatusWarning(const wsMsg: WideString) Displays a warning message in the status bar - message will appear on a blue background and display for at least 5 seconds.
Page 195
CloseProject function CloseProject(wbCloseOpenFiles: WordBool): WordBool Closes the active project, if any. If is True, then all open files are wbCloseOpenFiles closed. OpenProject function OpenProject(const wsProjectFile: WideString): WordBool Opens the passed project file, making it the active project. Pass an empty string to display the Open Project dialog box.
Page 196
AddScriptToolbutton function AddScriptToolbutton(wsToolbarName, wsScriptFile, wsHint, wsCaption, wsImageFile: WideString): WordBool Adds a script toolbutton (executes passed JScript or VBScript file when clicked) to the passed toolbar. Fails if toolbar doesn’t exist. Returns True if Toolbutton already exists, but doesn’t add duplicate button. AddTagToolbutton function AddTagToolbutton(wsToolbarName, wsTagStart, wsTagEnd, wsHint, wsCaption, wsImageFile: WideString): WordBool...
Page 197
ShowToolbar function ShowToolbar(wsToolbarName: WideString): WordBool Displays a toolbar if it’s not already showing. Fails if the toolbar doesn’t exist. The JScript example below creates a toolbar named "Apps" if one doesn’t exist already, and then adds two custom toolbuttons to it. The first toolbutton launches Windows Explorer, while the second one opens Windows Explorer at the current folder in the editor: function Main() {...
Table of CommandID Values The following table lists the set of currently exposed commands. For backward compatibility, these values will not change, but some value might become obsolete and be removed from the set. Command ID Value CMDID_cmdNone CMDID_cmdFileOpen CMDID_cmdFileClose CMDID_cmdFileCloseAll CMDID_cmdFileNew CMDID_cmdFileNewWizard...
Table of SettingID Values The following table lists currently exposed setting IDs. For backward compatibility, these values will not change, but some might become obsolete and be removed from the set. Setting ID Value Description SET_FLAG_READONLY_FILES flag read-only files in the file list SET_WARN_READONLY_OPEN warn when opening read-only files SET_RELOAD_TYPE...
Page 203
Setting ID (Continued) Value Description SET_FILE_FILTER file filter for file list SET_REMOTE_FILE_FILTER file filter for remote file list SET_TAG_INSIGHT use tag insight SET_INSIGHT_SHOWTAGLIST use tag insight for tags (immediately after < is hit) SET_TAG_COMPLETION toggle tag completion SET_TAGHELP_DELAY milliseconds to delay tag insight SET_LOWERCASE_TAGS lowercase inserted tags (see TCase) SET_HEX_COLORS...
Page 204
Setting ID (Continued) Value Description SET_PROXY_PORT set the proxy port for link verification and open from Web SET_CONNECT_TIMEOUT_MS timeout (in milliseconds) for link verification and open from Web SET_SAVE_FILE_FORMAT file format for saving (pc, unix, mac) SET_WEB_DOCUMENT_EXTENSIONS configure the extensions list for recognized Web document formats SET_WEB_IMAGE_EXTENSIONS configure the extensions list for recognized Web...
Page 205
Setting ID (Continued) Value Description SET_CHECK_UPDATE_TIMEOUT_SHORT timeout for update check at startup (milliseconds) SET_CHECK_UPDATE_TIMEOUT_LONG timeout for update check initiated by user SET_CHECK_UPDATE_LAST_DATE check date of last product update SET_CENTER_START_TAG start tag to use when align center toolbutton hit SET_CENTER_END_TAG end tag to use when align center toolbutton hit SET_USE_VTM_IMAGE_DIALOG use vtml image dialog SET_USE_VTM_ANCHOR_DIALOG...
Page 206
Setting ID (Continued) Value Description SET_DIR_TOOLBUTTON_IMAGES set location of images directory for toolbars when no path specified in TBR file SET_DIR_PARSERS set location of color coding parsers directory SET_DIR_STARTUP set location of startup directory SET_DIR_WIZARDS set location of wizard root directory SET_DIR_CUSTOM_TEMPLATES set location of custom templates directory SET_DIR_OLD_TEMPLATES...
Page 207
Setting ID (Continued) Value Description SET_DEFAULTAUTOFORMAT_FILE default formatting used by the codesweeper SET_VERITY_HELP_SEARCH_HELPFILE used to display search tips SET_STYLE_EDIT_WND_CLASS used to dynamically invoke a style editor (StyleEd or TopStyle) SET_STYLE_EDIT_OLE_OBJECT used to dynamically invoke a style editor (StyleEd or TopStyle) SET_EDITOR_FONTNAME set editor font name SET_EDITOR_FONTSIZE...
Page 208
Setting ID (Continued) Value Description SET_EDITOR_CHARSET set editor character set SET_EDITOR_OUTLINECURRLINE set outline on current line SET_SITEVIEW_GRADIENT set gradient fill for site view SET_SITEVIEW_SHOWTITLE toggle site view title SET_SITEVIEW_STYLE set tree or chart view SET_SITEVIEW_AUTONAV_TO_LINK navigate to the current link when user clicks on a node in site view SET_PROJECT_RESTORE_AT_START restore last opened project at startup...
DocumentCache Object It is very important to understand the DocumentCache object when using the Visual Tools Object Model. Although the visual tools enable you to open dozens of files at once, only the active document is kept in memory. When a document becomes inactive, that is, when the user switches to a different document in the Document tab, the previously active document is cached to conserve resources.
ActiveDocument Object The ActiveDocument object is used to refer to the document currently being displayed in the editor. To access an open document that isn’t active, use the Application.DocumentCache object. Properties CanRedo (WordBool, read-only) True if changes can be re-done. CanUndo (WordBool, read-only) True if changes can be undone.
Page 211
Methods BeginUpdate procedure BeginUpdate() Turns off screen updating for the active document. This is useful if your script needs to make several changes to the active document at once — turning off screen updating during the procedure might significantly speed up the process. To turn updating back on, use EndUpdate with caution.
Page 212
GetTagAtCursor function GetTagAtCursor(wbSelect: WordBool): WideString; Returns the tag in which the cursor is currently located in the editor. If a tag cannot be identified, the method returns an empty string. If wbSelect is True, the tag will be selected (highlighted) in the document. Example: // Displays a message box with the current tag function Main() {...
Page 213
InsertText procedure InsertText(InsertStr: OleVariant; wbOverwriteSelection: WordBool) Inserts the passed string at the current cursor position, overwriting the selection if is True. wbOverwriteSelection LastSavedDate function LastSavedDate() Returns the datetime value for the last save of the active document file. Print procedure Print(wbNoPrompt: WordBool) Prints the active document.
Page 214
SelectLine procedure SelectLine(Index: Integer) Highlights the passed line. SetCaretPos procedure SetCaretPos(x, y: Integer) Sets the current column/line. TextPosToEditorPos function TextPosToEditorPos() Takes the passed cursor position and subtracts the number of linefeeds the text contains. You can then pass the value to another VTOM function to position the cursor correctly.
DeploymentManager Object The DeploymentManager VTOM object is a scriptable interface into the Allaire Project Deployment engine. It provides a collection of methods and properties to allow you to write highly customized VTOM scripts to control the deployment process. Properties CreateFolder(Wordbool, read-write) Boolean property telling the deployment engine to create any missing folders on the target server.
Page 216
CheckServerFolders procedure CheckServerFolders(sServerName: WideString); Inserted in the generated VBScript/JScript deployment scripts at the appropriate points, it iterates through all of the assigned deployment folders for a project, verifying their existence on the target server ( ). If a folder does not exist, it is sServerName created.
Page 217
GetDeployState procedure GetDeployState(sServerName:WideString): WordBool Queries a specific deployment server to determine if it is enabled for deployment. GetDeployState is passed the server name as sServerName and returns a WordBool True or False result. GetDeployTargetName function GetDeployTargetName(const sServerName:Widestring, const sFolderName:Widestring, nFileIndex:Integer): WideString Calculates the target deployment file name using the passed-in server name, and folder name, and an integer representing the folder file to use.
Page 218
GetLastErrorMessage function GetLastErrorMessage(): WideString Tests the result of an UploadFile call by returning last associated RDS error message. IsFolderDeployable function IsFolderDeployable(const sFolderName:WideString): WordBool Returns the deployment status of the passed folder name. This method can be used to skip folders that have been designated as "Do Not Deploy" folders. OpenProject procedure OpenProject(const sProjectName: WideString) Opens the project specified in the passed OleString.
UploadProject procedure UploadProject(const sProjectName: WideString) Uploads an entire project based on the fully qualified project name passed as an OLE string. This triggers the default deployment engine processing loop which iterates through each server assigned to the project, each folder within the project, and uploads all the files contained within each folder.
HTTPProvider Object The HTTPProvider object is a general purpose HTTP protocol object. It can be used from VTOM scripts for low-level HTTP operations. The HTTPProvider was introduced as an alternative to simplified HTTP-related methods such as GetURL method of the main Application object which is limited in the number of customizable HTTP parameters.
Page 221
DocName (OleVariant; readonly) The document name segment from the requested URL. LastResponse (OleVariant; readonly) The most recent response content block when content stream is sent from the server in multiple responses. Location (OleVariant; readonly) The response-header field which defines the exact location of the resource that was identified by the Request-URI.
Page 222
ReasonPhrase (OleVariant; readonly) The Reason-Phrase element which is intended to give a short textual description of the Status-Code. The Status-Code is intended for use by automata and the Reason-Phrase is intended for the human user. The following are some of the Status-Code, Reason-Phrase pairs: 200 - OK 201 - Created 202 - Accepted...
Page 223
State (TAllaireHTTPProviderState; readonly) The state of the HTTPProvider object. The enumerated state values are: 0 - httpReady 1 - httpNotConnected 2 - httpConnected (browse) 3 - httpDnsLookup 4 - httpDnsLookupDone 5 - httpWaitingHeader 6 - httpWaitingBody 7 - httpAborting StatusCode (Integer; readonly) The HTTP request Status-Code element.
Page 225
Post procedure Post() Performs an HTTP POST method request. The following example illustrates a POST method by which three FORM variables are submitted to a ColdFusion page. function Main () { var app = Application; var httpPro = app.HTTPProvider; httpPro.URL = "http://127.0.0.1/httptest.cfm";...
Page 226
The following scripts illustrates a download of a ZIP file using SaveReceivedStreamToFile: function Main () { var hsOKInfo = 64; var app = Application; var httpPro = app.HTTPProvider; httpPro.URL = "http://127.0.0.1/test.zip"; httpPro.Get(); var bOverwrite = false; var sErrorMsg = httpPro.SaveReceivedStreamToFile("d:\\downloads\\test.zip", bOverwrite );...
ZIPProvider Object The ZIPProvider object is the general purpose PKZIP services object used by the visual tools for ZIP file composition and extraction. You can use this object in your VTOM scripts for low-level PKZIP operations from within the visual tools. Since Allaire uses a licensed control for its ZIP operations, you cannot use ZIPProvider outside of the visual tools.
Page 228
The following example uses the ZIPFile property to extract a file (somefile.exe) from another file (d:\\downloads\\test.zip): function Main () { var hsOKInfo = 64; var app = Application; var ZIPPro = app.ZIPProvider; ZIPPro.ExtractionDir = ‘d:\\ExtractHere\\’; ZIPPro.ZipFile = ‘d:\\downloads\\test.zip’; var ResultCode = ZIPPro.Extract(‘somefile.exe’); app.MessageBox( "Return Code :"...
Page 229
//Interpret and display the return code var sMessage = ‘’; if (nStatusCode == 0){sMessage = "Operation Succesful";} else if (nStatusCode == 10){sMessage = "General Warning";} else if (nStatusCode == 0){sMessage = "Success";} else if (nStatusCode == 10){sMessage = "WarningGeneral";} else if (nStatusCode == 30){sMessage = "WarningNoZipFile";} else if (nStatusCode == 40){sMessage = "WarningFilesSkipped";} else if (nStatusCode == 50){sMessage = "WarningEmptyZipFile";} else if (nStatusCode == 100){sMessage = "ErrorNoZipFile";}...
Page 230
Delete function Delete(Files: OleVariant): Integer Deletes files from an archive. The Files parameter can be used to narrow down the group of files to delete. You can specify a single file, a set of files delimited by line breaks or an entire directory using wildcards. If left an empty string all files will be extracted.
Page 231
FileName function FileName(nIndex: Integer): WideString Returns the name of an existing archive file element (file/directory/volume) by index. The index value can be from 0 to FileCount-1. The following code illustrates a loop over the content of the archive looking for a specific file name: function Main () { var hsOKInfo = 64;...
ActiveScripting examples JScript <html> <head> <title>JScript Example</title> </head> <body> <pre> //===================================================================== ActiveScripting example (JScript) //===================================================================== Displays a table containing the filenames of all open documents, whether or not each document has been modified, and whether each document is read-only. //===================================================================== function Main() { var newline = ‘\n’;...
Page 233
// is this document modified? if (app.DocumentCache(idx).Modified) sTable = sTable + ‘Yes’; sTable = sTable + ‘</td><td>’; // is this document read-only? if (app.DocumentCache(idx).ReadOnly) sTable = sTable + ‘Yes’; // close row sTable = sTable + ‘</td></tr>’ + newline; sTable = sTable + newline + ‘</table>’; // add a new document (False = don’t create from default template - blank) app.NewDocument(false);...
VBScript <html> <head> <title>VBScript Example</title> </head> <body> <pre> //============================================================= // Displays a table containing file information //============================================================ Sub Main dim app dim idx dim sTable dim newline, fname, br, tab dim nCurrentIdx newline = chr(13) + chr(10) br = "<br>" tab = chr(9) ‘...
Page 235
‘ is this document modified? if app.DocumentCache(idx).Modified then sTable = sTable + "Yes" sTable = sTable + "</td><td>" ‘ is this document read-only? if app.DocumentCache(idx).ReadOnly then sTable = sTable + "Yes" ‘ close row sTable = sTable + "</td></tr>" + newline next sTable = sTable + newline + "</table>"...
Third-Party Add-Ins At start-up, the program executes any scripts it finds listed in these Windows Registry keys: HKEY_CURRENT_USER\Software\Allaire\HomeSite45\RunOnce HKEY_CURRENT_USER\Software\Allaire\Studio45\RunOnce HKEY_CURRENT_USER\Software\Allaire\JRStudio3\RunOnce If you want to distribute an add-in for one or more of these programs, you can use the appropriate key to run a script that, for example, creates a toolbar for your application the next time the program starts.
Need help?
Do you have a question about the COLDFUSION STUDIO 4.5-USING COLDFUSION STUDIO and is the answer not in the manual?
Questions and answers