Extending DWMX2004
Extending DWMX2004
Trademarks
Add Life to the Web, Afterburner, Aftershock, Andromedia, Allaire, Animation PowerPack, Aria, Attain, Authorware,
Authorware Star, Backstage, Bright Tiger, Clustercats, Cold Fusion, Contribute, Design in Motion, Director, Dream Templates,
Dreamweaver, Drumbeat 2000, EDJE, EJIPT, Extreme 3D, Fireworks, Flash, Fontographer, FreeHand, Generator, HomeSite,
JFusion, JRun, Kawa, Know Your Site, Knowledge Objects, Knowledge Stream, Knowledge Track, LikeMinds, Lingo, Live
Effects, MacRecorder Logo and Design, Macromedia, Macromedia Action!, Macromedia Flash, Macromedia M Logo & Design,
Macromedia Spectra, Macromedia xRes Logo and Design, MacroModel, Made with Macromedia, Made with Macromedia Logo
and Design, MAGIC Logo and Design, Mediamaker, Movie Critic, Open Sesame!, Roundtrip HTML, Shockwave, Sitespring,
SoundEdit, Titlemaker, UltraDev, Web Design 101, what the web can be, and Xtra are either registered or trademarks of
Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product
names, logos, designs, titles, words or phrases mentioned within this publication may be trademarks, servicemarks, or tradenames
of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally.
Third-Party Information
This guide contains links to third-party websites that are not under the control of Macromedia, and Macromedia is not
responsible for the content on any linked site. If you access a third-party website mentioned in this guide, then you do so at your
own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia
endorses or accepts any responsibility for the content on those third-party sites.
Third Party Software Notices and/or Additional Terms and Conditions can be found at www.macromedia.com/go/thirdparty/.
Opera ® browser Copyright © 1995-2002 Opera Software ASA and its suppliers. All rights reserved.
Apple Disclaimer
APPLE COMPUTER, INC. MAKES NO WARRANTIES, EITHER EXPRESS OR IMPLIED, REGARDING THE
ENCLOSED COMPUTER SOFTWARE PACKAGE, ITS MERCHANTABILITY OR ITS FITNESS FOR ANY
PARTICULAR PURPOSE. THE EXCLUSION OF IMPLIED WARRANTIES IS NOT PERMITTED BY SOME
STATES. THE ABOVE EXCLUSION MAY NOT APPLY TO YOU. THIS WARRANTY PROVIDES YOU WITH
SPECIFIC LEGAL RIGHTS. THERE MAY BE OTHER RIGHTS THAT YOU MAY HAVE WHICH VARY FROM
STATE TO STATE.
Copyright © 1997-2003 Macromedia, Inc and its licensors. All rights reserved. This manual may not be copied,
photocopied, reproduced, translated, or converted to any electronic or machine-readable form in whole or in part without
prior written approval of Macromedia, Inc. Part Number ZDW70M300
Acknowledgments
Senior Management: Sheila McGinn
Project Management: Robert Berry
Writing: Robert Berry, David Jacowitz
Editing Management: Lisa Stanziano
Editing: Mary Kraemer, Noreen Maher
Production Management: Patrice O’Neill
Media Design and Production: Adam Barnett, Aaron Begley, Chris Basmajian, John Francis, Jeff Harmon
Special thanks to Jay London, Jeff Schang, Lori Hylan-Cho, Hisami Scott, Sam Mathews, Jake Cockrell, Russ Helfand, Randy
Edmunds, George Comninos, Rosana Francescato, Charles Nadeau, and the entire Dreamweaver engineering and QA teams.
First Edition: September 2003
Macromedia, Inc.
600 Townsend St.
San Francisco, CA 94103
CONTENTS
CHAPTER 1: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Background. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Installing an extension. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Additional resources for extension writers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
What’s new in Extending Dreamweaver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Documentation Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Macromedia Press. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Removed Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Errata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Conventions used in this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
PART I: Overview
3
Changing the default file type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Customizing the interpretation of third-party tags . . . . . . . . . . . . . . . . . . . . . . 34
Working with browser profiles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
About browser-profile formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Creating and editing a browser profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Changing FTP mappings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Extensible document types in Dreamweaver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Opening a document in Dreamweaver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4 Contents
PART II: Extension APIs
Contents 5
Menu Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Modifying the Commands menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
How menu commands work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
The Menu Commands API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
canAcceptCommand() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
commandButtons() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
getDynamicContent() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
isCommandChecked() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
receiveArguments() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
setMenuText() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
windowDimensions() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
A simple menu command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Creating the menu items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Writing the JavaScript code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Placing the command file in the Menu folder . . . . . . . . . . . . . . . . . . . . . . . . . 164
A dynamic menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Creating the dynamic menu items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Writing the JavaScript code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
6 Contents
file="command_file_path" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
domRequired="true" or "false" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
enabled="script" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
checked="script". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
value="script" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
update="update_frequency_list". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
command="script" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
arguments="argument_list" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
The toolbar command API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
canAcceptCommand() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
getCurrentValue(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
getDynamicContent() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
getMenuID() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
getUpdateFrequency() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
isCommandChecked() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
isDOMRequired() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
receiveArguments(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
showIf() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
A simple toolbar command file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Creating the text box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Writing the JavaScript code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Placing the files in the Toolbars folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Contents 7
CHAPTER 12: Property Inspectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
How Property inspector files work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
The Property inspector API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
canInspectSelection() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
displayHelp() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
inspectSelection() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
8 Contents
deleteServerBehavior() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
displayHelp() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
findServerBehaviors() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
inspectServerBehavior() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
pasteServerBehavior() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Server behavior implementation functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
dwscripts.findSBs(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
dwscripts.applySB() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
dwscripts.deleteSB() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Editing EDML files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Regular expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Notes about EDML structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Group EDML file tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
<group> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
<group> attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
<title>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
<groupParticipants> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
<groupParticipants> attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
<groupParticipant>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
<groupParticipant> attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Participant EDML files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
<participant> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
<participant> attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
<quickSearch> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
<insertText> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
<insertText> attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
<searchPatterns> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
<searchPatterns> attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
<searchPattern> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
<searchPattern> attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
<updatePatterns> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
<updatePattern> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
<updatePattern> attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
<delete> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
<delete> attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
<translator> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
<searchPatterns> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
<translations> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
<translation> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
<translation> attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
<openTag> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
<attributes> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
<attribute> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
<display> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
<closeTag> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Server behavior techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Finding server behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Updating server behaviors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Deleting server behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Avoiding conflicts with share-in-memory JavaScript files . . . . . . . . . . . . . . . . 292
Contents 9
CHAPTER 16: Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
How data sources work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
The Data Sources API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
addDynamicSource() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
deleteDynamicSource(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
displayHelp() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
editDynamicSource() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
findDynamicSources() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
generateDynamicDataRef() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
generateDynamicSourceBindings() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
inspectDynamicDataRef() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
A simple data source example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Creating the data source definition file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Creating the EDML file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Creating the JavaScript file that implements the Data Sources API functions . 301
Creating the supporting command files for user input . . . . . . . . . . . . . . . . . . 303
Using the new data source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
10 Contents
CHAPTER 19: Server Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
How customizing server models works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
The Server Model API functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
canRecognizeDocument(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
getFileExtensions() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
getLanguageSignatures() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
getServerExtension(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
getServerInfo() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
getServerLanguages() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
getServerModelExtDataNameUD4() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
getServerModelDelimiters() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
getServerModelDisplayName() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
getServerModelFolderName(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
getServerSupportsCharset() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
getVersionArray() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Contents 11
JSObject *JS_NewArrayObject() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
long JS_GetArrayLength() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
JSBool JS_GetElement(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
JSBool JS_SetElement() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
JSBool JS_ExecuteScript() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
JSBool JS_ReportError() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
File Access and Multiuser Configuration API . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
JS_Object MM_GetConfigFolderList() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
JSBool MM_ConfigFileExists() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
int MM_OpenConfigFile() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
JSBool MM_GetConfigFileAttributes() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
JSBool MM_SetConfigFileAttributes(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
JSBool MM_CreateConfigFolder(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
JSBool MM_RemoveConfigFolder() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
JSBool MM_DeleteConfigFile() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
Calling a C function from JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
12 Contents
CHAPTER 1
Introduction
This book describes the Macromedia Dreamweaver MX 2004 framework and application
programming interface (API) that lets you build extensions to Dreamweaver. Extensions typically
perform the following types of tasks:
• Automating changes to the user’s current document, such as inserting HTML, CFML, or
JavaScript; changing text or image properties; or sorting tables
• Interacting with the application to automatically open or close windows, open or close
documents, change keyboard shortcuts, and more
• Connecting to data sources, which lets Dreamweaver users create dynamic, data-driven pages
• Inserting and managing blocks of server code in the current document
You might want to write an extension to handle a commonly used, and therefore repetitive, task.
Such an extension could be useful to many web developers. On the other hand, you might have a
unique requirement that you can satisfy only by writing an extension for that specific situation. In
both cases, Dreamweaver provides an extensive set of tools that you can use to add to or customize
its functionality.
This book describes the API functions that Dreamweaver calls to implement the various objects,
menus, floating panels, server behaviors, and so on, that comprise the features of Dreamweaver.
To add an object, menu, floating panel, or other feature to Dreamweaver, you must code the
functions that the particular type of extension requires. This book describes the arguments that
Dreamweaver passes to these functions and also the values that Dreamweaver expects these
functions to return.
This book also explains how to customize Dreamweaver by editing and adding tags to various
HTML and XML files to add menu items or document types, and so on.
For information on the utility and general purpose JavaScript APIs that you can use to perform
various support operations in your Dreamweaver extensions, see the Dreamweaver API Reference.
If you plan to create extensions that work with databases, you might also want to review the
sections in Getting Started with Dreamweaver about making connections to databases.
13
Background
Most Dreamweaver extensions are written in HTML and JavaScript. This book assumes that you
are familiar with Dreamweaver, HTML, XML, and JavaScript programming. If you are
implementing C extensions, the book assumes that you know how to create and use C dynamic
linked libraries (DLLs). If you are writing extensions for building web applications, you should
also be familiar with server-side scripting on at least one platform, such as Active Server Pages
(ASP), ASP.net, PHP: Hypertext Preprocessor (PHP), ColdFusion, or Java Server Pages (JSP).
Installing an extension
As you become familiar with the process of writing extensions, you might want to explore the
extensions and resources that are available through the Macromedia Exchange website
(www.macromedia.com/exchange). Installing an existing extension introduces you to some of the
tools that you need to work with in your own extensions.
To install an extension, use the following procedure:
1 Download and install the Extension Manager, which is available on the Macromedia
Downloads website (www.macromedia.com/software/downloads).
2 Log on to the Macromedia Exchange website (www.macromedia.com/exchange).
3 From the available extensions, select one that you want to use. Click the Download link to
download the extension package.
4 Save the extension package in the Dreamweaver MX 2004/Downloaded Extensions folder of
your installed Dreamweaver folder.
5 In the Extension Manager, select File > Install Extension. In Dreamweaver, select
Commands > Manage Extensions to start the Extension Manager.
The Extension Manager automatically installs the extension from the Downloaded Extension
folder into Dreamweaver.
Some extensions need Dreamweaver to restart before you can use them. If you are running
Dreamweaver when you install the extension, you might be prompted to quit and restart
the application.
To view basic information on the extension after its installation, go to the Extension Manager
(Commands > Manage Extensions) in Dreamweaver.
14 Chapter 1: Introduction
What’s new in Extending Dreamweaver
Dreamweaver MX 2004 includes the following new features and interfaces that are extensible.
• New Insert Bar
The Insert Bar is now divided into separate categories (instead of tabs) for grouping various
objects, and also supports pop-up menus. This new grouping and functionality presents a less
cluttered user interface. Users can now group their favorite objects into a Favorites category for
their own quick reference. Extensions can be added to their own category or pop-up menu and
grouped with other existing objects. See Chapter 6, “Insert Bar Objects,” on page 113.
• Extensible code coloring
Lets you add new keywords to an existing code coloring scheme or create a new one. If you
develop new JavaScript functions to use in your client-side script, for example, you can add the
names of these functions to the keywords section so that they display in the color that is
specified in Preferences. You can also add new code coloring schemes for a new document type.
For more information, see Chapter 5, “Customizing Code View,” on page 77.
• The cssimport and cssmedia tags support code coloring rules for the @import and @media
functions of the style element in a cascading style sheet. For more information, see
Chapter 5, “Customizing Code View,” on page 77.
• API support for Flash Elements (SWC files).
Extension developers can add their own Flash Elements to the Insert Bar, Insert menu, or other
Toolbars so users can insert them into documents by simply clicking a button or menu option.
See “Flash Integration” in the Dreamweaver API Reference.
• Enhanced support for “code behind” pages can be found in the CodeBehindMgr.js file in the
Dreamweaver Configuration/Shared/Common folder. See Appendix A, “The Shared folder
contents,” on page 375.
• Integration of Customizing Dreamweaver content.
Material formerly available only as a separate document download from the Macromedia
website is now integrated into this book.
Documentation Changes
Extending Dreamweaver MX has been divided into two books: Extending Dreamweaver and the
Dreamweaver API Reference. Extending Dreamweaver describes how to build various types of
Dreamweaver extensions, including the functions that you must write to create each type. It also
describes how to customize Dreamweaver by modifying some of its configurable HTML and
XML files. The Dreamweaver API Reference describes the two APIs that let you perform various
supporting tasks in your Dreamweaver extensions.
The Extending Dreamweaver book is designed to serve the user who wants to learn how to build a
Dreamweaver extension. The Dreamweaver API Reference is designed to serve the experienced
Dreamweaver programmer who wants to quickly locate the right function to accomplish a
particular task. Dividing the material into two books also clarifies the distinction between the
extension API functions that an extension author must code, and which Dreamweaver calls, and
the JavaScript and Utility API functions that a programmer can call to accomplish various tasks
from within an extension.
Extending Dreamweaver includes the following improvements to help new extension authors to
get started.
Macromedia Press
Improve your Dreamweaver skills with books from Macromedia Press. Check out the latest
content written by the experts. See www.macromedia.com/go/dw2004_help_mmp.
Removed Features
In Dreamweaver MX 2004, several features have been removed. As a result, the following material
has been removed from Extending Dreamweaver:
• References to the Dreamweaver 4 style workspace
• The JavaScript Debugger chapter
For information on all the features that have been removed from Dreamweaver, see Using
Dreamweaver. For information on the functions that have been removed from the Utility and
JavaScript APIs, see the Dreamweaver API Reference.
Errata
A current list of known issues can be found in the Extensibility section of the Dreamweaver
Support Center (www.macromedia.com/go/extending_errata).
16 Chapter 1: Introduction
Conventions used in this guide
The following typographical conventions are used in this guide:
• Code font indicates code fragments and API literals, including class names, method names,
function names, type names, scripts, SQL statements, and both HTML and XML tag and
attribute names.
• Italic code font indicates replaceable items in code.
• The continuation symbol (¬) indicates that a long line of code has been broken across two or
more lines. Due to margin limits in this book’s format, what is otherwise a continuous line of
code must be split. When copying the lines of code, eliminate the continuation symbol, and
type the lines as one line.
• Curly braces ({ }) that surround a function argument indicate that the argument is optional.
• Function names that have the prefix dreamweaver. as in dreamweaver.funcname, can be
abbreviated to dw.funcname when you are writing code. This manual uses the full
dreamweaver. prefix when defining the function and in the index. Many examples use the
shorter dw. prefix, however.
The following naming conventions are used in this guide:
• You—the developer who is responsible for writing extensions
• The user—the person using Dreamweaver
• The visitor—the person who views the web page that the user created
PART I
Overview
Learn the fundamental concepts of the Macromedia Dreamweaver MX 2004 interface and how
to customize and extend Dreamweaver to suit your web development needs. These fundamental
concepts include the Dreamweaver folders, extension APIs, Dreamweaver interface components,
the Dreamweaver Document Object Model (DOM), and Dreamweaver document types.
Chapter 2: Extending Dreamweaver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Chapter 3: User Interfaces for Extensions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Chapter 4: The Dreamweaver Document Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Chapter 5: Customizing Code View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
CHAPTER 2
Extending Dreamweaver
The following features of Macromedia Dreamweaver MX 2004 let you create extensions:
• An HTML parser (also called a renderer), which makes it possible to design user interfaces
(UIs) for extensions using form fields, layers, images, and other HTML elements.
Dreamweaver has its own HTML parser.
• A tree of folders that organize and store the files that implement and configure Dreamweaver
elements and extensions.
• A series of application programming interfaces (APIs) that provide access to Dreamweaver
functionality through JavaScript.
• A JavaScript interpreter, which executes the JavaScript code in extension files. Dreamweaver
uses the Netscape JavaScript version 1.5 interpreter. For more information about changes
between this version of the interpreter and previous versions, see “How Dreamweaver processes
JavaScript in extensions” on page 26.
21
Tag Library and Editor extensions work with the associated tag library files. Tag Library and
Editor extensions can modify attributes of existing Tag Dialogs, create new Tag Dialogs, and add
tags to the tag library. Tag Library and Editor extension files are stored in the Configuration/
TagLibraries folder.
Property Inspector extensions appear in the Property inspector panel. Most of the inspectors in
Dreamweaver are part of the core product code and cannot be modified, but custom Property
inspector files can override the built-in Dreamweaver Property inspector interfaces or create new
ones to inspect custom tags. Inspectors are stored in the Configuration/Inspectors folder.
Floating Panel extensions add floating panels to the Dreamweaver UI. Floating panels can
interact with the selection, the document, or the task. They can also display useful information.
Floating panel files are stored in the Configuration/Floaters folder.
Behavior extensions let users add JavaScript code to their documents. The JavaScript code
performs a specific task in response to an event when the document is viewed in a browser.
Behavior extensions appear on the Plus (+) menu of the Dreamweaver Behaviors panel. Behavior
files are stored in the Configuration/Behaviors/Actions folder.
Server Behavior extensions add blocks of server-side code (ASP, JSP, or ColdFusion) to the
document. The server-side code performs tasks on the server when the document is viewed in a
browser. Server behaviors appear on the Plus (+) menu of the Dreamweaver Server Behaviors
panel. Server behavior files are stored in the Configuration/Server Behaviors folder.
Data source extensions let you build a connection to dynamic data stored in a database. Data
source extensions appear on the Plus (+) menu of the Bindings panel. Data source extension files
are stored in the Configuration/Data Sources folder.
Server Format extensions let you define formatting for dynamic data.
Component extensions let you add new types of components to the Components panel.
Components is the term that Dreamweaver uses to refer to some of the more popular and modern
encapsulation strategies, including web services, JavaBeans, and ColdFusion components (CFCs).
Server model extensions let you add support for new server models. Dreamweaver supports the
most common server models (ASP, JSP, ColdFusion, PHP, and ASP.NET). Server model
extensions are needed only for custom server solutions, different languages, or a customized
server. Server model files are stored in the Configuration/ServerModels folder.
Data translator extensions convert non-HTML code into HTML that appears in the Design
view of the document window. These extensions also lock the non-HTML code to prevent
Dreamweaver from parsing it. Translator files are stored in the Configuration/Translators folder.
For more information about the Shared folder, see Appendix A, “The Shared Folder,”
on page 375.
Extension APIs
The extension APIs provide you with the functions that Dreamweaver calls to implement each
type of extension. You must write the bodies of these functions as described for each extension
type and specify the return values that Dreamweaver expects.
If you are a developer who wants to work directly in the C programming language, there is a
C extensibility API that lets you create dynamic link libraries (DLLs). The functionality that is
provided in these APIs wraps your C DLLs in JavaScript so that your extension can work
seamlessly in Dreamweaver.
The documentation of extension APIs outlines what each function does, when Dreamweaver calls
it, and what value Dreamweaver expects it to return.
See the Dreamweaver API Reference for information about the Utility API and the JavaScript API,
which provide functions that you can use to perform specific tasks in your extensions.
Extension APIs 25
How Dreamweaver processes JavaScript in extensions
Dreamweaver checks the Configuration/extension_name folder during startup. If it encounters an
extension file within the folder, Dreamweaver processes the JavaScript by completing the
following steps:
• Compiling everything between the beginning and ending SCRIPT tags
• Executing any code within SCRIPT tags that is not part of a function declaration
Note: This procedure is necessary during startup because some extensions might require global
variables to initialize.
Dreamweaver performs the following actions for any external JavaScript files that are specified in
the SRC attributes of SCRIPT tags:
• Reads in the file
• Compiles the code
• Executes the procedures
Note: If any JavaScript code in your extension file contains the string “</SCRIPT>”, the
JavaScript interpreter reads the string as an ending SCRIPT tag and reports an unterminated
string literal error. To avoid this problem, break the string into pieces and concatenate them like
this: "<' + '/SCRIPT>".
Dreamweaver executes code in the onLoad event handler (if one appears in the BODY tag) when
the user selects the command or action from a menu for the Command and Behavior action
extension types.
Dreamweaver executes code in the onLoad event handler on the BODY tag if the body of the
document contains a form for object extensions.
Dreamweaver ignores the onLoad handler on the BODY tag in the following extensions:
• Data translator
• Property inspector
• Floating panel
For all extensions, Dreamweaver executes code in other event handlers (for example,
onBlur="alert('This is a required field.')") when the user interacts with the form
fields to which they are attached.
Dreamweaver supports the use of event handlers within links. Event handlers in links must use
syntax, as shown in the following example:
<a href=”#” onMouseDown=alert(‘hi’)>link text</a>
Plug-ins (set to play at all times) are supported in the BODY of extensions. The
document.write() statement, Java applets, and ActiveX controls are not supported
in extensions.
Localizing an extension
Use the following techniques to make it easier to translate your extensions into local languages.
• Separate extensions into HTML and JavaScript files. The HTML files can be replicated and
localized; the JavaScript files will not be localized.
• Do not define display strings in the JavaScript files (check for alerts and UI code). Extract all
localizable strings into separate XML files in the Dreamweaver Configuration/Strings folder.
• Do not write JavaScript code in the HTML files except for required event handlers. This
eliminates the need to fix a bug multiple times for multiple translations after the HTML files
are replicated and translated into other languages.
</strings>
Localizing an extension 27
Now your JavaScript files can refer to these translatable strings by calling the dw.loadString()
function, as shown in the following example:
function initializeUI()
{
...
if (problemYhasOccured)
{
alert(dw.loadString("featureX/subProblemY");
}
}
You can use slash (/) characters in your string identifiers, but do not use spaces. Using slashes, you
can create a hierarchy to suit your needs, and include all the strings in a single XML file.
Note: Files that begin with cc in the Configuration/Strings folder are Contribute files. For example,
the file ccSiteStrings.xml is a Contribute file.
The location of the user’s Configuration folder depends on the user’s platform.
For Windows 2000 and Windows XP platforms:
<drive>:\Documents and Settings\<username>\ ¬
Application Data\Macromedia\Dreamweaver MX 2004\Configuration
Note: In Windows XP, this folder may be inside a hidden folder.
Customizing Dreamweaver 29
For Mac OS X platforms:
<drive>:Users:<username>:Library:Application Support: ¬
Macromedia:Dreamweaver MX 2004:Configuration
Note: To install extensions that all users can use in a multiuser operating system, you must be logged
in as Administrator (Windows) or root (Mac OS X).
Dreamweaver copies only some of the configuration files into your user Configuration folder the
first time you run the application. (The files that it copies are specified in the version.xml file in
the Configuration folder.) When you customize Dreamweaver from within the application (for
example, when you modify one of the predesigned code snippets in the Snippets panel),
Dreamweaver copies the relevant files into your user Configuration folder. The version of a file in
your user Configuration folder always takes precedence over the version in the Dreamweaver
Configuration folder. To customize a configuration file that Dreamweaver has not copied into
your user Configuration folder, first copy the file from the Dreamweaver Configuration folder to
the corresponding location inside your user Configuration folder. Then edit the copy in your user
Configuration folder.
Deleting configuration files in a multiuser environment
When you do something within Dreamweaver in a multiuser operating system that would delete
a configuration file (such as when you delete a predesigned snippet from the Snippets panel),
Dreamweaver creates a file in your user Configuration folder called mm_deleted_files.xml. When
a file is listed in mm_deleted_files.xml, Dreamweaver behaves as if that file doesn’t exist.
Note: The mm_deleted_files.xml file isn’t created until you take an action that would cause a
configuration file to be deleted.
<deleteditems>
Description
Container tag holding a list of items that Dreamweaver should treat as deleted.
Attributes
None.
Contents
None.
Example
<deleteditems>
<!-- item tags here -->
</deleteditems>
<item>
Description
Customizing Dreamweaver 31
Reinstalling and uninstalling Dreamweaver in a multiuser environment
After you install Dreamweaver, if you later reinstall it or upgrade to a later version, Dreamweaver
automatically makes backup copies of existing user configuration files, so that if you’ve
customized those files, you can still access the changes you made. When you uninstall
Dreamweaver from a multiuser system (which you can do only if you have administrative
privileges), Dreamweaver can remove each user Configuration folder for you.
You can also create custom page designs by adding files to the subfolders of the BuiltIn folder. To
make a description of the file appear in the New Document dialog box, create a Design Notes file
(in the appropriate _notes folder) that corresponds to the page design file.
Customizing Dreamweaver 33
To add new file types to the menu in the File > Open dialog box:
1 Make a backup copy of the Extensions.txt file in the Configuration folder.
2 Open Extensions.txt in Dreamweaver or a text editor.
3 Add a new line for each new file type. In capital letters, enter the filename extensions that the
new file type can have, separated by commas; then add a colon and a brief descriptive phrase to
show in the pop-up menu for file types that appears in the File > Open dialog box. For example,
for JPEG files, enter the following:
JPG,JPEG,JFIF:JPEG Image Files
4 Save the file.
5 Restart Dreamweaver.
To see the changes, select File > Open, and click the pop-up menu of file types.
Each tag database file defines the name, type, content model, rendering scheme, and icon for one
or more custom tags. You can create any number of tag database files, but all of them must reside
in the Configuration/ThirdPartyTags folder to be read and processed by Dreamweaver. Tag
database files have the .xml file extension.
Tip: If you are working on several unrelated sites at once (for example, as a freelance developer), you
can put all the tag specifications for a particular site in one file. Then simply include that tag database
file with the custom icons and Property inspectors that you hand over to the people who will maintain
the site.
You define a tag specification with an XML tag called tagspec. For example, the following code
describes the specification for a tag named happy:
<tagspec tag_name="happy" tag_type="nonempty" render_contents="false"
content_model="marker_model" icon="happy.gif" icon_width="18"
icon_height="18"></tagspec>
<tagspec>
Description
Customizing Dreamweaver 35
• content_model describes what kinds of content the tag can contain and where in an HTML
file the tag can appear. Valid values are "block_model", "head_model", "marker_model",
and "script_model":
■ block_model specifies that the tag can contain block-level elements such as div and p, and
that the tag can appear only in the body section or inside other body-content tags such as
div, layer, or td.
■ head_model specifies that the tag can contain text content and that it can appear only in the
HEAD section.
■ marker_model specifies that the tag can contain any valid HTML code, and that it can
appear anywhere in an HTML file. The HTML validator in Dreamweaver ignores tags that
are specified as marker_model. However, the validator doesn’t ignore the contents of such a
tag; so even though the tag itself can appear anywhere, the contents of the tag may result in
invalid HTML in certain places. For example, plain text can’t appear (outside of a valid head
element) in the head section of a document, so you can’t place a marker_model tag that
contains plain text in the head section. (To place a custom tag containing plain text in the
head section, specify the tag’s content model as head_model instead of marker_model.) Use
marker_model for tags that should be displayed inline (inside a block-level element such as
p or div—for example, inside a paragraph). If the tag should be displayed as a paragraph of
its own, with line breaks before and after it, don’t use this model.
■ script_model lets the tag exist anywhere between the opening and closing HTML tags of a
document. When Dreamweaver encounters a tag with this model, it ignores all of the tag’s
content. Used for markup (such as certain ColdFusion tags) that Dreamweaver
shouldn’t parse.
• start_string specifies a delimiter that marks the beginning of a string-delimited tag. String
delimited tags can appear anywhere in the document where a comment can appear.
Dreamweaver does not parse tags or decode entities or URLs between start_string and
end_string. This attribute is required if end_string is specified.
• end_string specifies a delimiter that marks the end of a string-delimited tag. This attribute is
required if start_string is specified.
• detect_in_attribute indicates whether to ignore everything between start_string and
end_string (or between opening and closing tags if those strings are not defined) even when
those strings appear inside attribute names or values. You should generally set this to "true"
for string-delimited tags; the default is "false". For example, ASP tags sometimes appear
inside attribute values, and sometimes contain quotation marks ("); because the ASP tag
specification specifies detect_in_attribute="true", Dreamweaver ignores the ASP tags,
including the internal quotation marks, when they appear inside attribute values.
• parse_attributes indicates whether to parse the attributes of the tag. If this is set to "true"
(the default), Dreamweaver parses the attributes; if it’s set to "false", Dreamweaver ignores
everything until the next closing angle bracket that appears outside quotation marks. For
example, this attribute should be set to "false" for a tag such as cfif (as in <cfif a is 1>,
which Dreamweaver cannot parse as a set of attribute name/value pairs).
• icon specifies the path and filename of the icon associated with the tag. This attribute is
required for empty tags, and for nonempty tags whose contents do not appear in the
Document window’s Design view.
• icon_width specifies the width of the icon in pixels.
• icon_height specifies the height of the icon in pixels.
None.
Example
<tagspec tag_name="happy" tag_type="nonempty" render_contents="false"
content_model="marker_model" icon="happy.gif" icon_width="18"
icon_height="18"></tagspec>
Customizing Dreamweaver 37
To change the highlighting color of third-party tags:
1 Select Edit > Preferences, and select the Highlighting category.
2 Click the Third-Party Tags color box to display the color picker.
3 Select a color, and click OK to close the Preferences dialog box. For information about selecting
a color, see Dreamweaver Help (Help > Using Dreamweaver).
• You must include an exclamation point (!) without a space before each of the following words:
ELEMENT, ATTLIST, Error, and msg (ELEMENT, !ATTLIST, !Error, !msg ).
• You can include !Error, !Warning, and !Info within the !ELEMENT or the !ATTLIST area.
• !msg messages can contain only plain text.
• HTML comments (!---->) cannot be listed as tags in browser profiles because they interfere
with parsing. Dreamweaver does not report an error for comments because all browsers
support them.
The following example shows a line (from the Macintosh file) that indicates that files with an
.html extension should be transferred in ASCII mode:
HTML DmWr TEXT ASCII
In both the FTPExtensionMap.txt file and FTPExtensionMapMac.txt file (Macintosh), all
elements on a given line are separated by tabs. The extension and the transfer mode are in
uppercase letters.
To change a default setting, edit the file in a text editor.
To add information about a new filename extension:
1 Edit the extension-map file in a text editor.
2 On a blank line, enter the filename extension (in uppercase letters) and press Tab.
3 On the Macintosh, add the creator code, a tab, the file type, and another tab.
4 Enter ASCII or BINARY to set an FTP transfer mode.
5 Save the file.
Dreamweaver provides an initial document type definition file. This file, named
MMDocumentTypes.xml, contains the document type definitions provided by Macromedia:
Document type Server model Internal type File extensions Previous server
model
ActionScript Text as
CSharp Text cs
JavaScript Text js
VB Text vb
If you need to create a new document type, you can either add your entry to the document
definition file that Macromedia provides (MMDocumentTypes.xml) or add a custom definition
file to the Configuration/DocumentTypes folder.
Note: The NewDocuments subfolder resides in the Configuration/DocumentTypes folder. This
subfolder contains default pages (templates) for each document type.
Element Type
Note: When the user saves a new document, Dreamweaver examines the list of extensions for the
current platform that are associated with the document type (winfileextension and
macfileextension). Dreamweaver selects the first string in the list and uses it as the default file
extension. To change this default file extension, you must reorder the extensions in the comma-
separated list so the new default is listed first.
Dynamic templates
You can create templates that are based on dynamic document types. These templates are called
dynamic templates. The following two elements are essential to defining a dynamic template:
• The value of the internaltype attribute for the new document type must be DWTemplate.
• The dynamicid attribute must be set, and the value must be a reference to the identifier of an
existing dynamic document type.
The following example defines a dynamic document type:
<documenttype
id="PHP_MySQL"
servermodel="PHP MySQL"
internaltype="Dynamic"
winfileextension="php,php3"
macfileextension="php,php3"
file="Default.php">
<title>PHP</title>
<description><![CDATA[PHP document]]></description>
</documenttype>
Now, you can define the following dynamic template, which is based on this PHP_MySQL dynamic
document type:
<documenttype
id="DWTemplate_PHP"
internaltype="DWTemplate"
dynamicid="PHP_MySQL"
winfileextension="php.dwt"
macfileextension="php.dwt"
file="Default.php.dwt">
<title>PHP Template</title>
<description><![CDATA[Dreamweaver PHP Template document]]></description>
</documenttype>
When a Dreamweaver user creates a new blank template of type DWTemplate_PHP,
Dreamweaver lets the user create PHP server behaviors in the file. Furthermore, when the user
creates instances of the new template, the user can create PHP server behaviors in the instance.
In the previous example, when the user saves the template, Dreamweaver automatically adds a
.php.dwt extension to the file. When the user saves an instance of the template, Dreamweaver
adds the .php extension to the file.
Suppose you want to create a new document extension. To create a new document extension, you
can either add the new extension to an existing document type or create a new document type.
To add a new extension to an existing document type:
1 Edit MMDocumentTypes.xml.
2 Add the new extension to the winfileextension and macfileextension attributes of the
existing document type.
To add a new document type:
1 Make a backup copy of the Extensions.txt file in the Configuration folder.
2 Open Extensions.txt in Dreamweaver or a text editor.
3 Add a new line for each new file type. In capital letters, enter the filename extensions that the
new file type can have, separated by commas; then add a colon and a brief descriptive phrase to
show in the pop-up menu for file types that appears in the File > Open dialog box.
For example, for JPEG files, enter JPG,JPEG,JFIF:JPEG Image Files
4 Save the Extensions.txt file.
5 Restart Dreamweaver.
To see the changes, select File > Open and click the pop-up menu of file types.
Localized strings
Within a document type definition file, the <title> and <description> subtags specify the
display title and description for the document type. You can use the MMString:loadstring
directive in the subtags as a placeholder for providing localized strings for the two subtags. This
process is similar to server-side scripting where you specify a particular string to use in your page
by using a string identifier as a placeholder. For the placeholder, you can use a special tag or you
can specify a tag attribute whose value is replaced.
To provide localized strings, perform the following steps:
1 Place the following statement at the beginning of the document type definition file:
<?xml version="1.0" encoding="utf-8"?>
2 Declare the MMString name space in the <documenttypes> tag:
<documenttypes
xmlns:MMString="http://www.macromedia.com/schemes/data/string/">
3 At the location in the document type definition file where you want to provide a localized string,
use the MMString:loadstring directive to define a placeholder for the localized string. You can
specify this placeholder in one of the following ways:
<description>
<loadstring>myJSPDocType/Description</loadstring>
</description>
or
<description>
<loadstring id="myJSPDocType/Description" />
</description>
In these examples, myJSPDocType/Description is a unique string identifier that acts as a
placeholder for the localized string. The localized string is defined in the next step.
4 In the Configuration/Strings folder, create a new XML file (or edit an existing file) that defines
the localized string. For example, the following code, when placed in the Configuration/Strings/
strings.xml file, defines the myJSPDocType/Description string:
<strings>
...
<string id="myJSPDocType/Description"
value=
"<![CDATA[JavaServer Page with <em>special</em> features]]>"
/>
...
</strings>
Most extensions are built to receive information from the user through a user interface (UI).
If you plan to submit your extension for Macromedia certification, you need to follow the
guidelines that are available within the Extension Manager files on the Macromedia Exchange
website (www.macromedia.com/exchange). These guidelines are not intended to limit your
creativity; their purpose is to ensure that certified extensions work effectively within the
Macromedia Dreamweaver MX 2004 UI and that the extension UI design does not detract from
its functionality.
53
Consider the following basic guidelines when you design an extension UI:
• If you want a name for your extension, place the name in the title tag of your HTML file.
Dreamweaver displays the name in the extension title bar.
• Keep text labels on the left side of your UI, aligned right, with text boxes on the right side,
aligned left. This arrangement lets the user’s eyes easily locate the beginning of any text box.
Minimal text can follow the text box as explanation or units of measure.
• Keep checkbox and radio button labels on the right side of your UI, aligned left.
• For readable code, assign logical names to your text boxes. If you use Dreamweaver to create
your extension UI, you can use the Property inspector or the Quick Tag Editor to assign names
to the fields.
In a typical scenario, after you create the UI, test the extension code to see that it properly
performs the following UI-related tasks:
• Getting the values from the text boxes
• Setting default values for the text boxes or gathering values from the selection
• Applying changes to the user document
The Base Property inspector as it appears in Design view without the DOCTYPE statement.
The Base Property inspector as it appears in Design view with the DOCTYPE statement (and after a few
adjustments to accommodate the new rendering).
The following example creates a command that contains an editable select list using common
JavaScript functions:
<html>
<head>
<title>Editable Dropdown Test</title>
<script language="javascript">
function getAlert()
{
var i=document.myForm.mySelect.selectedIndex;
if (i>=0){
alert ("selectedIndex: " + i);
alert("selected text " + document.myForm.mySelect.options[i].text);
}
else{
var i=document.myForm.mySelect_no.selectedIndex;
if (i>=0){
alert ("selectedIndex: " + i);
alert("selected text " +
document.myForm.mySelect_no.options[i].text);
}
else
alert("nothing is selected");
}
}
function commandButtons()
{
return new Array("OK", "getAlert()", "Cancel", "window.close()");
}
</script>
</head>
<body>
<div name="test">
<form name="myForm">
<table>
<tr>
<td>Editable DropDown with default text:</td>
</form>
</div>
</body>
</html>
To use this sample, save it to the Dreamweaver Configuration/Commands folder as
EditableSelectTest.htm. Restart Dreamweaver, and select EditableSelectTest from the Commands
menu.
Database controls
Using Dreamweaver, you can extend the HTML select tag to create a database tree control. You
can also add a variable grid control. The database tree control displays database schema, and the
variable grid control displays tabular information.
Any option tags that are placed inside the select tag are ignored.
The following example adds a simple variable grid control to a dialog box:
<select name="ParamList" style="width:515px;" ¬
type="mmparameterlist columns"="Name,SQL Data ¬
Type,Direction,Default Value,Run-time Value" size=6></select>
The following example creates a variable grid control that is 500 pixels wide, with five columns of
various widths:
<select name="ParamList" style="width:500px;" ¬
type=mmparameterlist columns="Name,SQL Data Type,Direction, ¬
Default Value,Run-time Value" columnWidth="100,25,11," size=6>¬
</select>
This example creates two blank columns that are 182 pixels wide. (The specified columns total
136. The total width of the variable grid control is 500. The remaining space after the first three
columns are placed is 364. Two columns remain; 364 divided by 2 is 182.)
This variable grid control also has a JavaScript wrapper object that should be used to access and
manipulate the variable grid control’s data. You can find the implementation in the
GridControlClass.js file in the Configuration/Shared/MM/Scripts/Class folder.
For readability, TREECOLUMN tags should follow immediately after the MM:TreeControl tag, as
shown in the following example:
<MM:TREECONTROL name="tree1">
<MM:TREECOLUMN name="Column1" width="100" state="visible">
<MM:TREECOLUMN name="Column2" width="80" state="visible">
...
</MM:TREECONTROL>
selected You can select multiple nodes by setting this attribute on more than one tree
node, if the tree has a MULTIPLE attribute.
icon Optional. The index of built-in icon to use, starting with 0:
0 = no icon; 1 = DW document icon; 2 = Multidocument icon
For example, the following tree control has all its nodes expanded:
<mm:treecontrol name="test" style="height:300px;width:300px">
</mm:treecontrol>
In Dreamweaver, open a new basic HTML file (this will be your Command definition file).
Between the opening and closing title tags, enter My Flash Movie so the head of your page
reads as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My Flash Movie</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
Now, save the file as My Flash Movie.htm in the application Configuration/Commands folder
(but do not close the file yet). You save the file at this point so you can embed your Flash content
with a relative path, otherwise Dreamweaver will try to use an absolute path.
Back in the HTML document, between the opening and closing body tags, add an opening and
closing form tag. Then, within the form tags, use the Insert > Media > Flash menu option to add
your Flash content to the Command definition file. When prompted, select the SWF file in the
Commands folder, and click OK. Your Command definition file should now look like the
following example (of course, the width and height attributes might differ, depending on your
SWF file properties):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My Flash Movie</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<body>
<form>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://
download.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=6,0,29,0" width="200" height="100">
<param name="movie" value="myFlash.swf">
<param name="quality" value="high">
<embed src="myFlash.swf" quality="high" pluginspage="http://
www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"
width="200" height="100"></embed>
</object>
</form>
</body>
</html>
This example shows a simple implementation of Dreamweaver’s Flash content support. After you
are familiar with building objects and commands as well as more sophisticated forms, you can
integrate Flash content into your Dreamweaver extensions for a more dynamic user experience.
For more infomation, see Chapter 7, “Commands,” on page 135 about writing a
commandButtons() function to add buttons to the dialog box that displays your Flash content.
67
Which document DOM?
It is important to distinguish between the DOM of the user’s document and the DOM of the
extension. The information in this chapter applies to both types of Dreamweaver documents, but
the way that you reference each DOM is different.
If you are familiar with JavaScript in browsers, you can reference objects in the active document
by writing document. (for example, document.forms[0]), the same way that you reference
objects in extension files. To reference objects in the user’s document, however, you must call
dw.getDocumentDOM(), dw.createDocument(), or another function that returns a user
document object.
For example, to refer to the first image in the active document, you can write
dw.getDocumentDOM().images[0]. You can also store the document object in a variable and use
that variable in future references, as shown in the following example:
var dom = dw.getDocumentDOM(); //get the dom of the current document
var firstImg = dom.images[0];
firstImg.src = “myImages.gif”;
This kind of notation is common in files throughout the Configuration folder, especially in
command files. For more information about the dw.getDocumentDOM() method, see the
dreamweaver.getDocumentDOM() function in the Dreamweaver API Reference.
layer In addition to the properties that Only those methods that None
are available for all tags: are available to all tags
visibility
left
top
width
height
zIndex
image In addition to the properties that Only those methods that onMouseOver
are available for all tags: are available to all tags onMouseOut
src onMouseDown
onMouseUp
option In addition to the properties that Only those methods that None
are available for all tags: are available to all tags
text
parentNode • null
parentNode • The parent tag. If this is the HTML tag, the document
object returns.
childNodes • A NodeList that contains all the immediate children of the tag.
tagName • The HTML name for the tag, such as IMG, A, or BLINK. This
value always returns in uppercase letters.
attrName A string that contains the value of the specified tag attribute.
tag.attrName cannot be used if the attrName attribute is a
reserved word in the JavaScript language (for example,
class). In this case, use getAttribute() and setAttribute().
innerHTML The source code that is contained between the opening tag
and the closing tag.For example, in the code <p><b>Hello</
b>, World!</p>, p.innerHTML returns <b>Hello</b>, World!.
If you write to this property, the DOM tree immediately
updates to reflect the new structure of the document. (This
property is not included in DOM Level 1, but Internet Explorer
4.0 supports it.)
outerHTML The source code for this tag, including the tag. For the
previous example code, p.outerHTML returns <p><b>Hello</
b>, World!</p>. If you write to this property, the DOM tree
immediately updates to reflect the new structure of the
document. (This property is not included in DOM Level 1, but
Internet Explorer 4.0 supports it.)
getAttribute(attrName) The value of the specified attribute if it is explicitly specified;
null otherwise.
removeAttribute(attrName) Does not return a value. Removes the specified attribute and
its value from the HTML for this tag.
As an example, the value of the appVersion property for the Swedish Windows version of
Dreamweaver MX 2004 is "7.0.XXXX [se] (Win32)"; the value for the English Macintosh
version is "7.0.XXXX [en] (MacPPC)".
Note: You can find the version and build number by selecting the Help > About menu item.
The appName and appVersion properties were implemented in Dreamweaver 3 and are not
available in earlier versions of Dreamweaver. You might want to check that the user of your
extension has Dreamweaver version 3 or later by checking for the existence of the appVersion or
appName property.
To find the specific version of Dreamweaver, check first for the existence of appVersion and then
for the version number, as shown in the following example:
if (dreamweaver.appVersion && ¬
dreamweaver.appVersion.indexOf('3.01') != -1){
// execute code
}
Language Value
Japanese ja
Korean ko
TChinese zh_tw
SChinese zh_cn
Macromedia Dreamweaver MX 2004 uses two devices in Code view that help you enter code
quickly and make your code readable and accurate. These two devices are Code Hints and Code
Coloring. In addition, Dreamweaver validates your code for the target browsers that you specify
and allows you to change default HTML formatting.
You can customize Code Hints and Code Coloring by modifying the XML files that implement
them. You can add items to the Code Hints menus by adding entries to the CodeHints.xml file.
You can modify color schemes by modifying the code coloring style file, Colors.xml, or you can
change code coloring schemes or add new ones by modifying one of the code coloring syntax files,
such as CodeColoring.xml. You can also modify the cascading style sheet (CSS) profile file for
your target browser to affect how Dreamweaver validates CSS properties and values. You can also
change Dreamweaver’s default HTML formatting through the Preferences dialog box. The
following sections describe how to customize these features.
Code Hints
Code Hints are menus that Dreamweaver opens when you type certain character patterns in the
Code View. Code Hints offer a typing shortcut by providing a list of strings that potentially
complete the string you are typing. If the string you are typing appears in the menu, you can scroll
to it and press Enter or Return to complete your entry. For example, when you type <, a pop-up
menu shows a list of tag names. Instead of typing the rest of the tag name, you can select the tag
from the menu to include it in your text.
Dreamweaver loads Code Hints menus from the CodeHints.xml file in the Configuration/
CodeHints folder. You can add Code Hints menus to Dreamweaver by defining them in the
CodeHints.xml file. After Dreamweaver loads the contents of CodeHints.xml, you can also add
new Code Hints menus dynamically through JavaScript. For example, JavaScript code populates
the list of session variables in the Bindings panel. You can use the same code to add a Code Hints
menu, so when a user types "Session." in Code view, Dreamweaver displays a menu of session
variables. For information on using JavaScript to add or modify a Code Hints menu, see Code
Functions in the Dreamweaver API Reference.
Dreamweaver cannot express some types of Code Hints menus through the XML file or the
JavaScript API. Both the CodeHints.xml file and the JavaScript API expose a useful subset of the
Code Hints engine, but some Dreamweaver functionality is not accessible. For example, there is
no JavaScript hook to open a color picker, so Dreamweaver cannot express the Attribute Values
menu using JavaScript. You can only open a menu of text items from which you can insert text.
Note: When you insert text, the insertion pointer is placed after the inserted string.
77
The CodeHints.xml file
The CodeHints.xml file contains the following entities:
• A list of all the menu groups
Dreamweaver displays the list of menu groups when you select the Code Hints category
from the Preferences dialog box. You can open the Preferences dialog box by selecting
Edit > Preferences. Dreamweaver MX provides the following menu groups or types of Code
Hints menus: Tag Names, Attribute Names, Attribute Values, Function Arguments, Object
Methods and Variables, and HTML Entities.
• The description for each menu group
The description appears in the Preferences dialog box for the Code Hints category when you
select the menu group in the list. The description for the selected entry appears below the
menu group list.
• Code Hints menus
A menu consists of a pattern that triggers the Code Hints menu and a list of menu items. For
example, a pattern such as "&" could trigger a menu such as "&", ">", "<".
The following example shows the format of the CodeHints.xml file:
<codehints>
<menugroup name="HTML Entities" enabled="true" id="CodeHints_HTML_Entities">
<description>
<![CDATA[ When you type a '&', a drop-down menu shows
a list of HTML entities. The list of HTML entities
is stored in Configuration/CodeHints.xml. ]]>
</description>
<menu pattern="&">
<menuitem value="&amp;" texticon="&"/>
<menuitem value="&lt;" icon="lessThan.gif"/>
</menu>
</menugroup>
<codehints>
Description
None.
Contents
None.
Example
<codehints>
<menugroup>
Description
Each menugroup tag corresponds to a type of menu. You can see the menu types that
Dreamweaver defines by selecting the Code Hints category from the Preferences dialog box.
Select Preferences from the Edit menu to display the Preferences dialog box.
You can create a new menu group or add to an existing group. Menu groups are logical collections
of menus that the user might want to enable or disable using the Preferences dialog box.
Attributes
name, enabled, id
• The name attribute is the localized name that appears in the list of menu groups in the Code
Hints category of the Preferences dialog box.
• The enabled attribute indicates whether the menu group is currently checked or enabled. A
menu group that is enabled appears with a check mark next to it in the Code Hints category of
the Preferences dialog box. Assign a true value to enable the menu group or a false value to
disable a menu group.
• The id attribute is a nonlocalized identifier that refers to the menu group.
Contents
Code Hints 79
<description>
Description
The description tag contains text that Dreamweaver displays when you select the menu group
from the Preferences dialog box. The description text displays below the list of menu groups. The
description text might optionally contain a single a tag where the href attribute must be a
JavaScript URL that Dreamweaver executes if the user clicks the link. Use the XML CDATA
construct to enclose any special or illegal characters in the string so that Dreamweaver treats them
as text.
Attributes
None.
Contents
Description text.
Container
<menu>
Description
This tag describes a single pop-up menu. Dreamweaver opens the menu whenever the user types
the last character of the string in the pattern attribute. For example, the menu that shows the
contents of a Session variable might have a pattern attribute that is equal to "Session.".
Attributes
pattern, doctypes, casesensitive
• The pattern attribute specifies the pattern of typed characters that cause Dreamweaver to
open the Code Hints menu. If the first character of the pattern is a letter, number, or
underscore, Dreamweaver displays the menu only if the character that precedes the pattern in
the document is not a letter, number, or underscore. For example, if the pattern is "Session.",
Dreamweaver does not display the menu if the user types "my_Session.".
• The doctypes attribute specifies that the menu is active only for the specified document types.
This attribute lets you specify different lists of function names for ASP-JavaScript (ASP-JS),
Java Server Pages (JSP), Macromedia ColdFusion, and so on. You can specify the doctypes
attribute as a comma-separated list of document type IDs. See the Dreamweaver
Configuration/Documenttypes/MMDocumentTypes.xml file for a list of Dreamweaver
document types.
<menuitem>
Description
This tag specifies the text for an item in a Code Hints pop-up menu. The menuitem tag also
specifies the value to insert into the text when you select the item.
Attributes
• The label attribute is the string that Dreamweaver displays in the pop-up menu.
• The value attribute is the string that Dreamweaver inserts in the document when you select
the menu item. When the user selects the item from the menu and presses Enter or Return,
Dreamweaver replaces all the text that the user typed since the menu opened. The user typed
the pattern-matching characters before the menu opened, so Dreamweaver does not insert
them again. For example, if you want to insert &, which is the HTML entity for ampersand
(&), you can define the following menu and menuitem tags:
<menu pattern="&">
<menuitem label="&amp;" value="amp;" texticon="&"/>
The value attribute does not include the ampersand (&) character because the user typed it
before the menu opened.
• The icon attribute, which is optional, specifies the path to an image file that Dreamweaver
displays as an icon to the left of the menu text. The location is expressed as a URL, relative to
the Configuration folder.
• The texticon attribute, which is optional, specifies a text string to appear in the icon area
instead of an image file. This attribute is used for the HTML Entities menu.
Contents
None.
Code Hints 81
Container
<function>
Description
This tag replaces the menu tag for specifying function arguments and object methods for a Code
Hints pop-up menu. When you type a function or method name in Code View, Dreamweaver
opens a menu of function prototypes, displaying the current argument in bold. Each time you
type a comma, Dreamweaver updates the menu to display the next argument in bold. For
example, if you typed the function name ArrayAppend in a Coldfusion document, the Code
Hints menu would display ArrayAppend(array, value). After you type the comma following
array, the menu updates to show ArrayAppend(array, value).
For object methods, when you type the object name, Dreamweaver opens a menu of the methods
that are defined for that object.
The set of recognized functions is stored in the Dreamweaver Configuration/CodeHints.xml file.
Attributes
pattern, doctypes, casesensitive
• The pattern attribute specifies the name of the function and its argument list. For methods,
the pattern attribute describes the name of the object, the name of the method, and the
method’s arguments. For a function name, the Code Hints menu appears when the user types
functionname(. The menu shows the list of arguments for the function. For an object
method, the Code Hints menu appears when the user types objectname. (including the
period). This menu shows the methods that have been specified for the object. After that, the
Code Hints menu opens a list of the arguments for the method in the same way it does for
a function.
• The doctypes attribute specifies that the menu is active only for the specified document types.
This attribute lets you specify different lists of function names for ASP-JavaScript (ASP-JS),
Java Server Pages (JSP), Macromedia ColdFusion, and so on. You can specify the doctypes
attribute as a comma-separated list of document type IDs. For a list of Dreamweaver document
types, see the Dreamweaver Configuration/Documenttypes/MMDocumentTypes.xml file.
• The casesensitive attribute specifies whether the pattern is case-sensitive. The possible
values for the casesensitive attribute are true, false, or a subset of the comma-separated
list that you specify for the doctypes attribute. The list of document types lets you specify that
the pattern is case-sensitive for some document types but not for others. The value defaults to
false if you omit this attribute. If the casesensitive attribute is a value of true, the Code
Hints menu appears only if the text that the user types exactly matches the pattern that the
pattern attribute specifies. If the casesensitive attribute is a value of false, the menu
appears even if the pattern is lowercase and the text is uppercase.
Contents
None.
Code coloring
Dreamweaver lets you customize or extend the code coloring schemes that you see in Code view
so that you can add new keywords to a scheme or add code coloring schemes for new document
types. If you develop JavaScript functions to use in your client-side script, for example, you can
add the names of these functions to the keywords section so that they display in the color that is
specified in Preferences. Likewise, if you develop a new programming language for an application
server and you want to distribute a new document type to help Dreamweaver users build pages
with it, you could add a code coloring scheme for the document type.
Dreamweaver provides the JavaScript function dreamweaver.reloadCodeColoring(), which
enables you to reload code coloring XML files that might have been edited manually. For more
information on this function, see the Dreamweaver API Reference.
To update a code coloring scheme or add a new scheme, you must modify the code coloring
definition files.
Code coloring 83
The following excerpt from the Colors.xml file illustrates the hierarchy of tags in a code coloring
style file:
<codeColors>
<colorGroup>
<syntaxColor id="CodeColor_HTMLEntity" bold="true" italic="true" />
<syntaxColor id="CodeColor_JavascriptNative" text="#009999" />
<syntaxColor id="CodeColor_JavascriptNumber" text="#FF0000" />
…
<tagColor id="CodeColor_HTMLStyle" text="#990099" />
<tagColor id="CodeColor_HTMLTable" text="#009999" />
<syntaxColor id="CodeColor_HTMLComment" text="#999999" italic="true" />
…
</colorGroup>
</codeColors>
Colors are specified in red-green-blue (RGB) hexadecimal values. For example, the statement
text="009999" in the preceding XML code assigns a blue-green (teal) color to the ID
"CodeColor_JavascriptNative".
The following excerpt from the codeColoring.xml file illustrates the hierarchy of tags in a code
coloring scheme file, and it also illustrates the relationship between the styles file and the scheme
file:
<codeColoring>
<scheme name="Text" id="Text" doctypes="Text" priority="1">
<ignoreTags>Yes</ignoreTags>
<defaultText name="Text" id="CodeColor_TextText" />
<sampleText doctypes="Text">
<![CDATA[Default file syntax highlighting.
The quick brown fox
jumped over the lazy dog.
]]>
</sampleText>
</scheme>
<scheme>
Description
The scheme tag specifies code coloring for a block of code text. You can have multiple schemes
within a file to specify different coloring for different scripting or tag languages. Each scheme has
a priority that lets you nest a block of text with one scheme inside a block of text with a
different scheme.
Attributes
• name="scheme_name" A string that assigns a name to the scheme. Dreamweaver shows the
scheme name in the Edit Coloring Scheme dialog box. Dreamweaver shows a combination of
scheme name and field name, such as HTML Comment. If you do not specify a name, the fields
for the scheme do not appear in the Edit Coloring Scheme dialog box. For more information
about the Edit Coloring Scheme dialog box, see “Editing schemes” on page 103.
• id="id_string" Required. An identifier string that maps color and style to this syntax item.
• priority="string" The value ranges from "1" to "99". Highest priority is "1". Specifies
the precedence of the scheme. Blocks that are inside blocks with higher priority are ignored;
blocks that are inside blocks with the same or lower priority take precedence. The priority
defaults to "50" if you do not specify one.
• doctypes="doc_list" Optional. Specifies a comma-separated list of the document types to
which this code coloring scheme applies. This value is necessary to resolve conflicts in which
different start and end blocks use the same extensions.
Contents
Container
Code coloring 85
<blockEnd>
Description
Optional. Text values that delimit the end of the text block for this scheme. The blockEnd and
blockStart tags must be paired and the combination must be unique. Values are not evaluated
as case-sensitive. The blockEnd value can be one character. Multiple instances of this tag are
allowed. For more information on blockEnd strings, see “Wildcard characters” on page 100.
Attributes
None.
Example
<blockEnd><![CDATA[--->]]></blockEnd>
<blockStart>
Description
Optional. Specified only if the coloring scheme can be embedded inside a different coloring
scheme. The blockStart and blockEnd tags must be paired, and the combination must be
unique. Values are not evaluated as case-sensitive. The blockStart value must be two or more
characters in length. Multiple instances of this tag are allowed. For more information on
blockStart strings, see “Wildcard characters” on page 100. For information on the blockStart
scheme attribute, see “Scheme block delimiter coloring” on page 97.
Attributes
• canNest Specifies whether the scheme can nest inside itself. Values are "Yes" or "No". The
default is "No".
• doctypes="doc_type1, doc_type2,…" Required. Specifies a comma-separated list of
document types into which you can nest this code coloring scheme. Document types are
defined in the Dreamweaver Configuration/Document Types/MMDocumentTypes.xml file.
• id="id_string" Required when scheme="customText". An identifier string that maps
color and style to this syntax item.
• name="display_name" A string that appears in the Edit Coloring Scheme dialog box when
scheme="customText".
• scheme Required. This defines how the blockStart and blockEnd strings are colored. For
information on the possible values for the scheme attribute, see “Scheme block delimiter
coloring” on page 97.
Example
<blockStart doctypes="ColdFusion,CFC" scheme="innerText"
canNest="Yes"><![CDATA[<!---]]></blockStart>
name, id
<charStart>
Description
Contains a text string that represents the delimiter of the start of a character. You must specify the
charStart and charEnd tags in pairs. Multiple charStart … charEnd pairs are allowed.
Attributes
None.
Example
<charStart><![CDATA[']]></charStart>
<charEnd>
Description
Contains a text string that represents the delimiter of the end of a character. You must specify the
charStart and charEnd tags in pairs. Multiple charStart … charEnd pairs are allowed.
Attributes
None.
Example
<charEnd><![CDATA[']]></charEnd>
<charEsc>
Description
Contains a text string that represents an escape character. Multiple charEsc tags are allowed.
Attributes
None.
Example
<charEsc><![CDATA[\]]></charEsc>
Code coloring 87
<commentStart>
Description
A text string that delimits the start of a comment block. You must specify the commentStart and
commentEnd tags in pairs. Multiple commentStart…/commentEnd pairs are allowed.
Attributes
None.
Example
<commentStart><![CDATA[<%--]]></commentStart>
<commentEnd>
Description
A text string that delimits the end of a comment block. You must specify the commentStart and
commentEnd tags in pairs. Multiple commentStart…/commentEnd pairs are allowed.
Attributes
None.
Example
<commentEnd><![CDATA[--%>]]></commentEnd>
<cssImport/>
Description
An empty tag that indicates the code coloring rule for the @import function of the style element
in a CSS.
Attributes
name, id
<cssMedia/>
Description
An empty tag that indicates the code coloring rule for the @media function of the style element
in a CSS.
Attributes
name, id
<cssProperty/>
Description
An empty tag that indicates CSS rules and holds code coloring attributes.
Attributes
name, id
CSS Property
Example
<cssProperty name="Property" id="CodeColor_CSSProperty" />
<cssSelector/>
Description
An empty tag that indicates CSS rules and holds code coloring attributes.
Attributes
name, id
<cssValue/>
Description
An empty tag that indicates CSS rules and holds code coloring attributes.
Attributes
name, id
Code coloring 89
<defaultAttribute>
Description
Optional. This tag applies only to tag-based syntax (that is, where ignoreTags="No"). If this tag
is present, then all tag attributes are colored according to the style assigned to this tag. If this tag is
omitted, then attributes are colored the same as the tag.
Attributes
name
<defaultTag>
Description
This tag is used to specify the default color and style for tags in a scheme.
Attributes
name, id
Example
<defaultTag name="Other Tags" id="CodeColor_HTMLTag" />
<defaultText/>
Description
Optional. If this tag is present, all text that is not defined by any other tag is colored according to
the style assigned to this tag. If this tag is omitted, black text is used.
Attributes
name, id
A text string that delimits the start of a comment that continues until the end of the current line.
Multiple endOfLineComment…/endOfLineComment tags are allowed.
Attributes
None.
Example
<endOfLineComment><![CDATA[//]]></endOfLineComment>
<entity/>
Description
An empty tag that indicates that HTML special characters should be recognized and hold
coloring attributes.
Attributes
name, id
<functionKeyword>
Description
Identifies keywords that define a function. Dreamweaver uses these keywords to perform code
navigation. Multiple functionKeyword tags are allowed.
Attributes
name, id
Code coloring 91
<idChar1>
Description
A list of characters, each of which Dreamweaver can recognize as the first character in
an identifier.
Attributes
name, id
<idCharRest>
Description
Attributes
name, id
<ignoreCase>
Description
Specifies whether case should be ignored when comparing tokens to keywords. Values are Yes or
No. The default is Yes.
Attributes
None.
Example
<ignoreCase>Yes</ignoreCase>
<ignoreMMTParams>
Description
None.
Example
<ignoreMMTParams>No</ignoreMMTParams>
<ignoreTags>
Description
Specifies whether markup tags should be ignored. Values are Yes and No; the default is Yes. Set to
No when syntax is for tag markup language that is delimited by < and >. Set to Yes when syntax is
for a programming language.
Attributes
None.
Example
<ignoreTags>No</ignoreTags>
<isLocked>
Description
Specifies whether the text that is matched by this scheme is locked from being edited in the Code
view. Values are Yes and No. Default is No.
Attributes
None.
Example
<isLocked>Yes</isLocked>
<keyword>
Description
A string of text that defines a keyword. Multiple keyword tags are allowed. A keyword may start
with any character, but subsequent characters may only be a-z, A-Z, 0-9, _, $, or @.
The code color is specified by the containing keyword tags.
Attributes
None.
Example
<keyword>.getdate</keyword>
Code coloring 93
<keywords>
Description
List of keywords for type specified in category attribute. Multiple keywords tags are allowed.
Attributes
name, id
Example
<keywords name="Reserved Keywords" id="CodeColor_JavascriptReserved">
<keyword>break</keyword>
<keyword>case</keyword>
</keywords>
<numbers/>
Description
An empty tag that specifies numbers that should be recognized and also holds color attributes.
Attributes
name, id
<operators>
Description
name, id
• name="stringStart_name" A string that assigns a name to the list of search pattern strings.
• id="id_string" Required. An identifier string that maps color and style to this syntax item.
• delimiter The character or string that starts and ends a regular expression.
• escape The character or string that signals special character processing, known as the
“escape” character or string.
Contents
<searchPattern></searchPattern>
Example
<regexp name="RegExp" id="CodeColor_JavascriptRegexp" delimiter="/"
escape="\\">
<searchPattern><![CDATA[(\s*/\e*\\/]]></searchPattern>
<searchPattern><![CDATA[=\s*/\e*\\/]]></searchPattern>
</regexp>
<sampleText>
Description
Representative text that appears in the Preview window of the Edit Coloring Scheme dialog box.
For more information on the Edit Coloring Scheme dialog box, see “Editing schemes”
on page 103.
Attributes
doctypes
• doctypes="doc_type1, doc_type2,...” The document types for which this sample
text appears.
Example
<sampleText doctypes="JavaScript"><![CDATA[/* JavaScript */
function displayWords(arrayWords) {
for (i=0; i < arrayWords.length(); i++) {
// inline comment
alert("Word " + i + " is " + arrayWords[i]);
}
}
Code coloring 95
<searchPattern>
Description
A string of characters that define a regular search pattern using supported wildcard characters.
Multiple searchPattern tags are allowed.
Attributes
None.
Container
<stringStart>
Description
These tags contain a text string that represents the delimiter of the start of a string. You must
specify the stringStart and stringEnd tags in pairs. Multiple stringStart … stringEnd
pairs are allowed.
Attributes
<stringEnd>
Description
Contains a text string that represents the delimiter of the end of a code string. You must specify
the stringStart and stringEnd tags in pairs. Multiple stringStart … stringEnd pairs are
allowed.
Attributes
None.
Example
<stringEnd><![CDATA["]]></stringEnd>
Contains a text string that represents the delimiter of a string escape character. Multiple
stringEsc tags are allowed.
Attributes
None.
Example
<stringEsc><![CDATA[\]]></stringEsc>
<tagGroup>
Description
This tag groups one or more tags to which you can assign a unique color and style.
Attributes
• id="id_string" Required. An identifier string that maps color and style to this syntax item.
• name="display_name" A string that Dreamweaver displays in the code color editor.
• taglibrary="tag_library_id" The identifier of the tag library to which this group of
tags belongs.
• tags="tag_list" A tag or comma-separated list of tags that comprise the tag group.
Example
<tagGroup name="HTML Table Tags" id="CodeColor_HTMLTable"
taglibrary="DWTagLibrary_html"
tags="table,tbody,td,tfoot,th,thead,tr,vspec,colw,hspec" />
innerText
This value tells Dreamweaver to color the block delimiters the same as the default text of the
scheme inside them.
The Template scheme provides an example of the effect of this scheme. The Template scheme
matches blocks of read-only code that are colored gray because you cannot edit them. The block
delimiters, which are the <!-- #EndEditable --> and <!-- #BeginEditable "..." -->
strings, are also colored gray because they also are not editable.
Code coloring 97
Sample code
<!-- #EndEditable -->
<p><b><font size="+2">header</font></b></p>
<!-- #BeginEditable "test" -->
<p>Here's some editable text </p>
<p> </p>
<!-- #EndEditable -->
Example
<blockStart doctypes="ASP-JS,ASP-VB, ASP.NET_CSharp, ASP.NET_VB,
ColdFusion,CFC, HTML, JSP,LibraryItem,PHP_MySQL"
scheme="innerText"><![CDATA[<!--\s*#BeginTemplate]]></blockStart>
customText
This value tells Dreamweaver to use custom colors to color the block delimiters.
Sample code
The delimiters for blocks of PHP script, which appear in red, provide an example of the effect of
the customText value:
<?php
if ($loginMsg <> "")
echo $loginMsg;
?>
Example
<blockStart name="Block Delimiter" id="CodeColor_JavaBlock" doctypes="JSP"
scheme="customText"><![CDATA[<%]]></blockStart>
outerTag
The outerTag value specifies that both the blockStart and blockEnd tags are complete tags and
that Dreamweaver should color them as tags would be colored in the scheme that
surrounds them.
The JavaScript scheme, in which <script> and </script> strings are the blockStart and
blockEnd tags, provides an example of this value. This scheme matches blocks of JavaScript code,
which does not recognize tags, so the delimiters need to be colored by the scheme that
surrounds them.
Sample code
<script language="JavaScript">
// comment
if (true)
window.alert("Hello, World");
</script>
Example
<blockStart doctypes="PHP_MySQL"
scheme="outerTag"><![CDATA[<script\s+language="php">]]></blockStart>
nameTag
This value specifies that the blockStart string is the opening of a tag and blockEnd string is the
closing of a tag, and these delimiters are to be colored based on the tag settings of the scheme.
This type of scheme displays tags that can be embedded inside other tags, such as the cfoutput
tag.
Sample code
<input type="text" name="zip"
<cfif newRecord IS "no">
<cfoutput query="employee"> Value="#zip#" </cfoutput>
</cfif>
>
Example
<blockStart doctypes="ColdFusion,CFC"
scheme="nameTag"><![CDATA[<cfoutput\n]]></blockStart>
nameTagScript
This value is identical to the nameTag scheme; however, the content is script, such as assignment
statements or expressions, as opposed to attribute name=value pairs.
This type of scheme displays a unique type of tag that contains script inside the tag itself, such as
the ColdFusion cfset, cfif, and cfifelse tags, and can be embedded inside other tags.
Sample Code
Scheme processing
Dreamweaver has three basic code coloring modes: CSS mode, Script mode, and Tags mode.
In each mode, Dreamweaver applies code coloring only to particular fields. The following chart
indicates which fields are subject to code coloring in each mode.
defaultText X X
defaultTag X
defaultAttribute X
comment X X X
string X X X
Code coloring 99
Field CSS Tags Script
cssProperty X
cssSelector X
cssValue X
character X X
function keyword X
identifier X
number X X
operator X
brackets X X
keywords X X
To make the process of defining schemes more flexible, Dreamweaver lets you specify wildcard
and escape characters.
Wildcard characters
The following is a list of wildcard characters that Dreamweaver supports, along with the strings to
specify them and descriptions of their usage.
Wildcard \* Skip all characters in the rule until the character that follows the
wildcard is found. For example, use <MMTInstance:Editable
name=”\*”> to match all tags of this type that have the name attribute
specified.
Optional whitespace \s* This matches zero or more white space or newline characters.
For example, <!--\s*#include is used to match ASP include
directives whether they have any white space preceding the
#include token or not because either case is valid.
The white space wildcards match any combination of white space
and newline characters.
Required whitespace \s+ This matches one or more white space or newline characters.
For example, <!--#include\s+virtual is used to match ASP
include directives with any combination of white space between
#include and virtual. White space must be specified between
these tokens, but it can be any combination of valid white space
characters.
The white space wildcards match any combination of white space
and newline characters.
Escape characters
The following is a list of escape characters that Dreamweaver supports, along with the strings to
specify them and descriptions of their usage.
Backslash \\ The backslash character (\) is the code coloring escape character,
so it must be escaped to be specified in a code coloring rule.
White space \s This escape character matches any non-visible characters, except
those listed that match the Newline escape character, such as space
and tab characters.
The optional white space and required white space wildcards match
both the white space and newline characters.
Newline \n This escape character matches the newline (also known as linefeed)
and carriage-return characters.
Schemes can nest within another scheme only if the scheme.priority is equal to or greater
than the outer scheme. If the priority is equal, the scheme can nest only in the body state of the
outer scheme. For example, the <script>...</script> block can nest only inside the
<html>...</html> block where tags are legal—not inside a tag, attribute, string, comment, and
so on.
Schemes with a higher priority than the outer scheme can nest almost anywhere within the
outer scheme. For example, in addition to nesting in the body state of the <html>...</html>
block, the <%...%> block can also nest inside a tag, attribute, string, comment, and so on.
The maximum nesting level is 4.
3 When matching blockStart strings, Dreamweaver always uses the longest match.
4 After reaching the blockEnd string for the current scheme, syntax coloring returns to the state
where the blockStart string is detected. For example, if a <%...%> block is found within an
HTML string, then coloring resumes with the HTML string color.
For fields that you can specify more than once, such as stringStart, specify color and style settings
only on the first tag. Data will be lost when you split color and style settings across tags and you
later edit the colors or styles by using the Preferences dialog box.
Note: Macromedia recommends that you create backup copies of all XML files before you make
changes. You should verify all manual changes before you edit color and style settings using the
Preferences dialog box. Data will be lost if you edit an invalid XML file using the Preferences
dialog box.
To edit the style for a particular element, select it in the Styles For list. The items listed in the
Styles For pane include the fields for the scheme being edited and also the schemes that might
appear as blocks within this scheme. For example, if you edit the HTML scheme, the fields for
CSS and JavaScript blocks are also listed.
The fields listed for a scheme correspond to the fields defined in the XML file. The value of the
scheme.name attribute precedes each field listed in the Styles For pane. Fields that do not have a
name are not listed.
The style for a particular element includes bold, italic, underline, and background color in
addition to code coloring. After you select an element in the Styles For pane, you can change any
of these style characteristics.
The Preview area displays how sample text would appear with the current settings. The sample
text is taken from the sampleText setting for the scheme.
Select an element in the Preview area to change the selection in the Styles For list.
If you change the setting for an element of a scheme, Dreamweaver stores the value in the code
coloring file and overrides the original setting. When you click OK, Dreamweaver reloads all code
coloring changes automatically.
The following sample text for the CSS scheme illustrates the CSS code coloring scheme:
/* Comment */
H2, .head2 {
font-family : 'Sans-Serif';
font-weight : bold;
color : #339999;
}
The following lines from the Colors.xml file provide the color and style values that are seen in the
sample text and were assigned by the code coloring scheme:
<syntaxColor id="CodeColor_CSSSelector" text="#FF00FF" />
<syntaxColor id="CodeColor_CSSProperty" text="#000099" />
<syntaxColor id="CodeColor_CSSValue" text="#0000FF" />
The sample text for the JavaScript scheme illustrates the JavaScript code coloring scheme as
follows:
* JavaScript */
function displayWords(arrayWords) {
for (i=0; i < arrayWords.length(); i++) {
// inline comment
alert("Word " + i + " is " + arrayWords[i]);
}
}
Code validation
When opening a document in Code view, Dreamweaver automatically validates that the
document is not using any tags, attributes, CSS properties, or CSS values that are not available in
the target browsers that the user selected. Dreamweaver underlines errors with a wavy red line.
Dreamweaver stores browser profiles in the Browser Profile folder inside the Dreamweaver
Configuration folder. Each browser profile is defined as a text file that is named for the browser.
For example, the browser profile for Internet Explorer version 6.0 is Internet_Explorer_6.0.txt.
To support target browser checking for CSS, Dreamweaver stores CSS profile information for a
browser in an XML file whose name corresponds to the browser profile but with a suffix of
_CSS.xml. For example, the CSS profile for Internet Explorer 6.0 is
Internet_Explorer_6.0_CSS.xml. You might want to make changes to a CSS profile file if you
find that Dreamweaver is reporting an error that you do not want.
The CSS profile file consists of three XML tags: css-support, property, and value. The
following sections describe these tags.
This tag is the root node for a set of property and value tags that are supported by a
particular browser.
Attributes
None.
Contents
None.
Example
<css-support>
...
</css-support>
<property>
Description
<property name="foo">
<value type="named" name="top"/>
<value type="named" name="bottom"/>
</property>
<property name="bar">
<value type="named" name="top"/>
<value type="named" name="bottom"/>
</property>
• supportlevel="error", "warning", "info", or "supported" Specifies the level of
support for the property. If not specified, "supported" is assumed. If you specify a support
level other than "supported" and omit the message attribute, Dreamweaver uses the default
message, “CSS property name property_name is not supported.”
Container
css-support
Example
<value>
Description
None.
Container
property
Example
<property name="margin">
<value type="units" name="ex" supportLevel="warning"
message="The implementation of ex units is buggy in Safari 1.0."/>
<value type="units" names="%,em,px,in,cm,mm,pt,pc”/>
<value type="named" name="auto"/>
<value type="named" name="inherit"/>
</property>
PART II
Extension APIs
Learn about functions that you need to write when you create new objects, toolbars, tag editors,
floating panels, server behaviors, components, or server models.
Chapter 6: Insert Bar Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Chapter 7: Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Chapter 8: Menus and Menu Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Chapter 9: Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Chapter 10: Reports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Chapter 11: Tag Libraries and Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Chapter 12: Property Inspectors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Chapter 13: Floating Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Chapter 14: Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Chapter 15: Server Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Chapter 16: Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Chapter 17: Server Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Chapter 18: Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Chapter 19: Server Models. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Chapter 20: Data Translators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Chapter 21: C-Level Extensibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
CHAPTER 6
Insert Bar Objects
In Dreamweaver, objects insert specific strings of code into a user’s document. Objects commonly
reside on the Insert bar, on the Insert menu, or both, so users can add content, such as images,
layers, and tables, by clicking icons or menu options. You can add items to the Insert bar
to automate repetitive tasks for your users or even create dialog boxes for users to set
specific attributes.
Objects reside in the Configuration/Objects folder inside the Dreamweaver application folder.
The Objects subfolders are grouped according to their location on the Insert bar, and you can
open these files to see the construction of current objects. For example, you can open the
Configuration/Objects/Common/Hyperlink.htm file to see the code that corresponds to the
hypertext link object button on the Insert bar.
113
When a user selects an object by clicking an icon on the Insert bar or by selecting an item on the
Insert menu, the following events occur:
1 Dreamweaver calls the canInsertObject() function to determine whether to show a
dialog box.
2 The Object file is scanned for a FORM tag. If a form exists and you select the Show Dialog When
Inserting Objects option in the General Preferences dialog box, Dreamweaver calls the
windowDimensions() function, if defined, to determine the size of the dialog box in which to
display the form. If no form exists in the Object file, Dreamweaver does not display a dialog
box, and skips step 2.
3 If Dreamweaver displays a dialog box in step 1, the user enters parameters for the object (such
as the number of rows and columns in a table) in the dialog box text fields and clicks OK.
4 Dreamweaver calls the objectTag() function and inserts its return value into the document
after the current selection (it does not replace the current selection).
5 If Dreamweaver does not find the objectTag() function, it looks for an insertObject()
function and calls that function instead.
<insertbar xmlns:MMString="http://www.macromedia.com/schemes/data/string/">
<insertbar>
Description
This tag signals the content of the Insert bar definition file, and the end of the content is noted
with the </insertbar> closing tag.
Attributes
None.
Example
<insertbar>
<category id="DW_Insertbar_Common" folder="Common">
<button id="DW_Hyperlink" image="Common\Hyperlink.gif"
file="Common\Hyperlink.htm"/>
...
</insertbar>
<category>
Description
This tag defines a category on the Insert bar (such as Common, Forms, or HTML). The end of
the category content is denoted with the </category> closing tag.
Note: By default, the Insert bar is organized into categories of use (such as Common, Forms, or
HTML). In previous versions of Dreamweaver, the Insert bar was organized similarly by tabs. Users
can set their own preferences for how the Insert bar objects are organized (by category or tab). If the
user has selected the tab organization, then the category tag will define each tab.
Attributes
id, {folder}, {showIf}
Example
<category id="DW_Insertbar_Common" folder="Common">
<button id="DW_Hyperlink" image="Common\Hyperlink.gif"
file="Common\Hyperlink.htm"/>
</category>
Example
<menubutton
id="DW_ImageMenu"
name="Images"
image="Common\imagemenu.gif"
folder="Images">
<button id="DW_Image"
image="Common\Image.gif"
enabled=""
showIf=""
file="Common\Image.htm" />
</menubutton>
<button />
Description
This tag defines a button on the Insert bar that the user clicks to execute the code that the
command or file attributes specify.
Attributes
id, image, name, {canDrag}, {showIf}, {enabled}, {command}, {file}, {tag},
{codeOnly}
Example
<button id="DW_Object"
image="Common\Object.gif"
name=”Object”
enabled="true"
showIf=""
file="Common\Obect.htm"
/>
<checkbutton />
Description
A checkbutton is a button that has a checked or unchecked state. When you click it, a
checkbutton appears pressed in and highlighted. When it is unchecked, a checkbutton appears
flat. Dreamweaver has Mouse-over, Pressed, Mouse-over-while-pressed, and Disabled-while-
pressed states. The command must ensure that clicking the checkbutton causes its state to change.
Attributes
id, image, checked, {showIf}, {enabled}, {command}, {file}, {tag}, {name},
{codeOnly}
<separator />
Description
Example
<separator showIf="_VIEW_CODE"/>
id="unique id"
Description
The id attribute is an identifier for the buttons that appear on the Insert bar. The id attribute
must be unique identifier for the element within the file.
Example
id="DW_Anchor"
image="image_path”
Description
This attribute specifies the path, relative to the Dreamweaver Configuration folder, to the icon
file that appears on the Insert bar. The icon can be in any format that Dreamweaver can render,
but typically it is a GIF or JPEG file format, 18 x 18 pixels.
Example
image="Common/table.gif"
canDrag="Boolean”
Description
This attribute specifies whether the user can drag the icon into the code or workspace to insert the
object into a document. If omitted, the default value is true.
Example
canDrag="false"
This attribute specifies that this button should appear on the Insert bar only if the given
Dreamweaver enabler is a true value. If you do not specify showIf, the button always appears.
The possible enablers are _SERVERMODEL_ASP, _SERVERMODEL_ASPNET, _SERVERMODEL_JSP,
_SERVERMODEL_CFML (for all versions of ColdFusion), _SERVERMODEL_CFML_UD4 (only for
UltraDev version 4 of ColdFusion), _SERVERMODEL_PHP, _FILE_TEMPLATE, _VIEW_CODE,
_VIEW_DESIGN, _VIEW_LAYOUT, _VIEW_EXPANDED_TABLES, and _VIEW_STANDARD.
You can specify multiple enablers by placing a comma (which means AND) between the enablers.
You can specify NOT with "!".
Example
If you want a button to appear only in Code view for an ASP page, specify the enablers as
showIf="_VIEW_CODE, _SERVERMODEL_ASP".
enabled="enabler"
Description
This attribute specifies that the item is available to the user if the DW_enabler value is true. If
you do not specify the enabled function, the item defaults to always enabled. The possible
enablers are _SERVERMODEL_ASP, _SERVERMODEL_ASPNET, _SERVERMODEL_JSP,
_SERVERMODEL_CFML (for all versions of ColdFusion), _SERVERMODEL_CFML_UD4 (only for
UltraDev version 4 of ColdFusion), _SERVERMODEL_PHP, _FILE_TEMPLATE, _VIEW_CODE,
_VIEW_DESIGN, _VIEW_LAYOUT, _VIEW_EXPANDED_TABLES, and _VIEW_STANDARD.
You can specify multiple enablers by placing a comma (which means AND) between the enablers.
You can specify NOT with "!".
Example
If you want the button to be available only in Code view, specify enabled="_VIEW_CODE", and
the button will be dimmed in other views.
checked="enabler"
Description
You can specify multiple enablers by placing a comma (which means AND) between them. You
can specify NOT with "!".
Example
checked="_View_Layout"
Instead of referring Dreamweaver to an HTML file with the code to insert, you can use this tag to
specify a command that Dreamweaver performs when the button is clicked with this tag.
Example
command="dw.showTagChooser()"
file="file_path"
Description
The file attribute specifies the path, relative to the Dreamweaver Configuration folder, of an
object file. Dreamweaver derives the tooltip for the object icon from the title of the object file,
unless you specify the name attribute.
Example
file="Templates/Editable.htm"
tag="editor"
Description
This attribute tells Dreamweaver to invoke a Tag editor. In Code view, if the tag attribute is
defined and the user clicks the object, Dreamweaver invokes the Tag dialog box. In Code view, if
you specify the tag and command attributes, Dreamweaver invokes the Tag editor. In Design view,
if codeOnly="TRUE" and you do not specify the file attribute, Dreamweaver MX invokes Split
view, places focus in the code, and invokes the Tag editor.
Example
tag = "form"
name="tooltip_text"
Description
The name attribute specifies the tooltip that appears when the mouse pointer rests over the object.
If you specify an object file but do not specify the name attribute, Dreamweaver uses the name of
the object file for the tooltip.
Note: If the name attribute is not provided, the object will not be available for grouping in the Favorites
category on the Insert bar UI.
Some Insert bar objects use a variation of the name attribute with prefix MMString. The
MMString denotes a localized string; these values are explained in “Localized strings” on page 50.
Example
name = "cfoutput"
To move or copy an object from one Insert bar category to another or to a new location
within a category:
1 Save a backup copy of insertbar.xml (with a name such as insertbar.backup.xml).
2 Open the original insertbar.xml file.
3 Find the button tag that represents the object you want to move or copy. For example, to move
the Image object from its location in the Common category, find the button tag that has an id
attribute of "DW_Image".
4 Cut or copy the entire button tag.
5 Find the category tag that represents the category in which you want to move or copy
the object.
6 Find the location within the category where you want the object to appear.
7 Paste the copied button tag.
8 Save the insertbar.xml file.
9 Reload extensions.
To remove an object from the Insert bar:
1 Save a backup copy of insertbar.xml (with a name such as insertbar.backup.xml).
2 Open the original insertbar.xml file.
3 Find the button tag that represents the object you want to remove.
4 Delete the entire button tag.
5 Save the insertbar.xml file.
6 On your disk, move the object’s HTML, GIF, and JavaScript files out of their current folder,
and put them into a folder that isn’t listed in the insertbar.xml file. For example, you can create
a new folder in the Configuration/Objects folder named Unused, and move the object’s files
there. (If you’re certain you want to remove the object, you can delete those files entirely, but
it’s a good idea to keep backups of those files in case you need to restore the object later.)
7 Reload extensions.
canInsertObject()
Availability
Dreamweaver MX.
Description
None.
Returns
The following code tells Dreamweaver to check to see that the document contains a particular
string before allowing the user to insert the selected object:
function canInsertObject(){
var docStr = dw.getDocumentDOM().documentElement.outerHTML;
var patt = /hava/;
var found = ( docStr.search(patt) != -1 );
var insertionIsValid = true;
if (!found){
insertionIsValid = false;
alert("the document must contain a 'hava' string to use this object.");}
return insertionIsValid;}
displayHelp()
Description
If you define this function, it displays a Help button below the OK and Cancel buttons in the
Parameters dialog box. This function is called when the user clicks the Help button.
Arguments
None.
Returns
The following example opens the myObjectHelp.htm file in a browser; this file explains how to
use the extension:
function displayHelp(){
var myHelpFile = dw.getConfigurationPath() +
'/ExtensionsHelp/myObjectHelp.htm';
dw.browseDocument(myHelpFile);
}
isDomRequired()
Description
This function determines whether the object requires a valid DOM to operate. If this function
returns a true value or if the function is not defined, Dreamweaver assumes that the command
requires a valid DOM and synchronizes the Code and Design views for the document before
executing. Synchronization causes all edits in the Code view to be updated in the Design view.
Arguments
None.
Returns
insertObject()
Availability
Dreamweaver MX.
Description
This function is required if the objectTag() function is not defined. It is called when the user
clicks OK; it either inserts code into the user’s document and closes the dialog box or displays an
error message and leaves the dialog box open. This works as an alternate function to use in objects
instead of the objectTag() function. It does not assume that the user is inserting text at the
current insertion point and allows data validation when the user clicks OK. You should use the
insertObject() function if one of the following conditions exists:
None.
Dreamweaver expects a string that contains an error message or an empty string. If it returns an
empty string, the Object dialog box closes when the user clicks OK. If it is not empty,
Dreamweaver displays the error message and the dialog box remains.
Enabler
canInsertObject()
Example
The following example uses the insertObject() function because it needs to validate input
before inserting code:
function insertObject() {
var theForm = document.forms[0];
var nameVal = theForm.firstField.value;
var passwordVal = theForm.secondField.value;
var errMsg = "",
var isValid = true;
if (!errMsg) {
// do some document manipulation here. Exercise left to the reader
}
return errMsg;
}
objectTag()
Description
The objectTag() and insertObject() functions are mutually exclusive: If both are defined in a
document, the objectTag() function is used. For more information, see “insertObject()”
on page 123.
This function inserts a string of code into the user’s document. In Dreamweaver MX, returning
an empty string, or a null value (also known as "return;"), is a signal to Dreamweaver to
do nothing.
Note: The assumption is that edits have been made manually before the return statement, so doing
nothing in this case is not equivalent to clicking Cancel.
In Dreamweaver 4, if the focus is in Code view and the selection is a range (meaning that it is not
an insertion point), the range is replaced by the string that the objectTag() function returns.
This is the value true, even if the objectTag() function returns an empty string or returns
nothing. The reason for returning an empty string, or a null value from the objectTag()
function is because edits to the document have already been made manually. Otherwise, double
quotes ("") often deletes the edit by replacing the selection.
None.
Returns
The following example of the objectTag() function inserts an OBJECT/EMBED combination for a
specific ActiveX control and plug-in:
function objectTag() {
return '\n' +
'<OBJECT CLASSID="clsid:166F1OOB-3A9R-11FB-8075444553540000" \n'¬
+ 'CODEBASE="http://www.mysite.com/product/cabs/¬
myproduct.cab#version=1,0,0,0" \n' + 'NAME="MyProductName"> \n' ¬
+ '<PARAM NAME="SRC" VALUE=""> \n' + '<EMBED SRC="" HEIGHT="" ¬
WIDTH="" NAME="MyProductName"> \n' + '</OBJECT>'
}
windowDimensions()
Description
This function sets specific dimensions for the Options dialog box. If this function is not defined,
the window dimensions are computed automatically.
Note: Do not define this function unless you want an Options dialog box that is larger than
640 x 480 pixels.
Arguments
platform
• The value of the platform argument is either "macintosh" or "windows", depending on the
user’s platform.
Returns
The following example of the windowDimensions() function sets the dimensions of the
Parameters dialog box to 648 x 520 pixels for Windows and 660 x 580 pixels for the Macintosh:
function windowDimensions(platform){
var retval = ""
if (platform = = "windows"){
retval = "648, 520";
}else{
retval = "660, 580";
}
return retval;
}
function isDOMRequired() {
// Return false, indicating that this object is available in code view.
return false;
}
function objectTag() {
// Determine if the user is in Code view.
var dom = dw.getDocumentDOM();
if (dw.getFocus() == 'textView' || dw.getFocus(true) == 'html'){
var upCaseTag = (dw.getPreferenceString("Source Format", "Tags Upper Case",
"") == 'TRUE');
// Manually wrap tags around selection.
if (upCaseTag){
dom.source.wrapSelection('<S>','</S>');
}else{
dom.source.wrapSelection('<s>','</s>');
}
// If the user is not in Code view, apply the formatting in the Design view
}else if (dw.getFocus() == 'document'){
dom.applyCharacterMarkup("s");
}
Name the graphic file Strikethrough.gif, and save it in the Configuration/Objects/Text folder.
Now your HTML file identifies the code to insert into the document, and you have the
accompanying graphic file for the Insert bar. You need to edit the insertbar.xml file so
Dreamweaver can associate these two items with the Insert bar interface.
Note: Before you edit the insertbar.xml file, you might want to copy the original one as
insertbar.xml.bak, so you have a backup.
The code within the insertbar.xml file identifies all the existing objects on the Insert bar. Each
category tag in the XML file creates a category in the interface. Each menubutton tag creates a
pop-up menu on the Insert bar. And, each button tag in the XML file places an icon on the
Insert bar and connects it to the proper HTML file or function.
To add the new object to the Insert bar, find the following line near the beginning of the
inserbar.xml file:
<category id="DW_Insertbar_Common" MMString:name="insertbar/category/common"
folder="Common">
This line identifies the beginning of the Common category on the Insert bar. Start a new line after
the category tag, and insert the button tag and assign it the id, image, and file attributes for the
Strikethrough object. The id must be a unique name for the button (following standard naming
conventions; use DW_Text_Strikethrough for this object). The image and file attributes
simply tell Dreamweaver the location of the supporting files, as shown in the following example:
<button id="DW_Text_Strikethrough"
image="Text\Strikethrough.gif"
file="Text\Strikethrough.htm"/>
Save the insertbar.xml file, reload the extensions (see “To reload extensions” on page 120), and the
new object appears at the beginning of the Common category on the Insert bar, as shown in the
following figure:
function objectTag() {
// Manually wrap tags around selection.
var dom = dw.getDocumentDOM();
if (dw.getFocus() == 'textView' || dw.getFocus(true) == 'html'){
function fontColorRed(){
var dom = dw.getDocumentDOM();
if (dw.getFocus() == 'textView' || dw.getFocus(true) == 'html'){
Then, in the Strikethrough.htm file, add the form. After the body tag, use the form tag to define
your form, and the table tag for layout control (otherwise, the dialog box might wrap words or
size awkwardly). The form for this example is a simple checkbox that calls the fontColorRed()
function when the user clicks on it. The entire Strikethrough.htm file should contain the
following code:
<html>
<head>
<title>Strikethrough</title>
<script language="javascript" src=”Strikethrough.js”>
</script>
</head>
<body>
<form>
<table border="0" height="100" width="100">
<tr valign="baseline">
<td align="left" nowrap>
<input type="checkbox" name="red" onClick=fontColorRed()>Red text</input>
</td>
</tr>
</table>
</form>
</body>
</html>
Clicking the OK button performs the objectTag() function, which adds the strikethrough:
The following example builds a new category on the Insert bar called Editorial and then adds a
pop-up menu to that category. The pop-up menu will contain the Strikethrough object from “A
simple Insert Object example” on page 126 and groups it with a Blue Text object you will create.
The objects in the Editorial category on the Insert bar let users make editorial comments on a file
and either strikethrough the content they want to remove or make new content blue so from the
rest of the text.
To keep the files organized, create a new Configuration/Objects/Editorial folder in your
Dreamweaver installation folder. Copy the files for the Strikethrough object example you created
to the Editorial folder (Strikethrough.htm, Strikethrough.js, and Strikethrough.gif ).
Next, make the new Blue Text object. Create a new HTML file called AddBlue.htm that contains
the following code:
<html>
<head>
<title>Blue Text</title>
<script language="javascript">
function isDOMRequired() {
// Return false, indicating that this object is available in code view.
return false;
}
function objectTag() {
// Manually wrap tags around selection.
var dom = dw.getDocumentDOM();
if (dw.getFocus() == 'textView' || dw.getFocus(true) == 'html'){
</script>
</head>
<body>
</body>
</html>
Save AddBlue.htm in the Editorial folder.
Now you can create an image for the Blue Text Object, an 18 x 18 pixel GIF, which will look like
the following figure:
Now you can end the pop-up menu with the </menubutton> closing tag. The following code
shows your entire category with the pop-up menu and the two objects:
<category id="DW_Insertbar_Editorial" name="Editorial" folder="Editorial">
<menubutton id="DW_Insertbar_Markup" name="markup"
image="Editorial\Strikethrough.gif" folder="Editorial">
<button id="DW_Editorial_Strikethrough"
image="Editorial\Strikethrough.gif" file="Editorial\Strikethrough.htm"/>
<button id="DW_Blue_Text" image="Editorial\AddBlue.gif" name="Blue Text"
file="Editorial\AddBlue.htm"/>
</menubutton>
</category>
To test the new pop-up menu, Reload Extensions. The following pop-up menu appears:
Macromedia Dreamweaver MX 2004 commands can perform almost any kind of edit to a user’s
current document, other open documents, or any HTML document on a local drive. Commands
can insert, remove, or rearrange HTML tags and attributes, comments, and text.
Commands are HTML files. The BODY section of a command file can contain an HTML form
that accepts options for the command (for example, how a table should be sorted and by which
column). The HEAD section of a command file contains JavaScript functions that process form
input from the BODY section and control what edits are made to the user’s document.
135
Adding commands to the Commands menu
Dreamweaver automatically adds any files that are inside the Configuration/Commands folder to
the bottom of the Commands menu. To prevent a command from appearing in the Commands
menu, insert the following comment on the first line of the file:
<!-- MENU-LOCATION=NONE -->
When this line is present, Dreamweaver does not create a menu item for the file, and you must
call dw.runCommand() to execute the command.
canAcceptCommand()
Description
Arguments
None.
Returns
Dreamweaver expects a true value if the command is allowed; false otherwise, dimming the
command in the menu.
Example
The following example of the canAcceptCommand() function makes the command available only
when the selection is a table:
function canAcceptCommand(){
var retval=false;
var selObj=dw.getDocumentDOM.getSelectedNode();
return (selObj.nodeType == Node.ELEMENT_NODE && ¬
selObj.tagName=="TABLE");{
retval=true;
}
return retval;
}
commandButtons()
Description
Defines the buttons that should appear on the right side of the Options dialog box and their
behaviors when they are clicked. If this function is not defined, no buttons appear, and the BODY
section of the Commands file expands to fill the entire dialog box.
Arguments
None.
Dreamweaver expects an array that contains an even number of elements. The first element is a
string that contains the label for the topmost button. The second element is a string of JavaScript
code that defines the behavior of the topmost button when it is clicked. The remaining elements
define additional buttons in the same way.
Example
The following instance of commandButtons() defines three buttons: OK, Cancel, and Help:
function commandButtons(){
return new Array("OK" , "doCommand()" , "Cancel" , ¬
"window.close()" , "Help" , "showHelp()");
}
isDomRequired()
Description
Determines whether the command requires a valid DOM to operate. If this function returns a
value of true or if the function is not defined, Dreamweaver assumes that the command requires
a valid DOM and synchronizes the Design and Code views of the document before executing.
Synchronization causes all edits in the Code view to update in the Design view.
Arguments
None.
Returns
receiveArguments()
Description
Processes any arguments that pass from a menu item or from the dw.runCommand() function.
Arguments
{arg1}, {arg2},...{argN}
• If the arguments attribute is defined for a menuitem tag, the value of that attribute passes to
the receiveArguments() function as one or more arguments. Arguments can also pass to a
command by the dw.runCommand() function.
Returns
Sets specific dimensions for the Parameters dialog box. If this function is not defined, the window
dimensions are computed automatically.
Note: Do not define this function unless you want an Options dialog box that is larger than
640 x 480 pixels.
Arguments
platform
• The value of the platform argument is either "macintosh" or "windows", depending on the
user’s platform.
Returns
The following example of the windowDimensions() function sets the dimensions of the
Parameters dialog box to 648 x 520 pixels:
function windowDimensions(){
return "648,520";
}
<HTML>
<HEAD>
<!-- Copyright 2001-2002 Macromedia, Inc. All rights reserved. -->
<Title>Make Uppercase or Lowercase</Title>
<SCRIPT SRC="Change Selection Case.js"></SCRIPT>
</HEAD>
<BODY>
<form name="uorl">
<table border="0">
<!--DWLayoutTable-->
<tr>
<td valign="top" nowrap> <p>
<label>
<input type="radio" name="RadioGroup1" value="uppercase" checked>
Uppercase</label>
<br>
<label>
<input type="radio" name="RadioGroup1" value="lowercase">
Lowercase</label>
</p></td>
</tr>
</table>
</div>
</form>
</BODY>
</HTML>
The contents of the Title tag, Make Uppercase or Lowercase, appears in the top bar of the
dialog box. Within the form, a table with two cells controls the layout of the elements. Within the
table cells are the two radio buttons, Uppercase and Lowercase. The Uppercase button has the
checked attribute, making it the default selection and ensuring that the user must either select
one of the two buttons or cancel the command.
The form looks like the following figure.
The commandButtons() function supplies the OK and Cancel buttons that let the user submit
the choice or cancel the operation.
Save the HTML code as ChangeCase.html in the Commands folder within the Dreamweaver
Configuration folder.
canAcceptCommand()
When a user clicks the Commands menu, Dreamweaver calls the canAcceptCommand() function
for each menu item to determine whether it should be enabled. If canAcceptCommand() returns
the value true, Dreamweaver displays the menu item text as active or enabled. If
canAcceptCommand() returns the value false, Dreamweaver dims the menu item.
The first task in creating a command is to determine when the item should be active and when it
should be dimmed. In this example, the menu item is active when the user has selected text in
the document.
The first lines of canAcceptCommand() retrieve the selected text by retrieving the DOM for the
user’s document and calling the getSelection() function on the document object. Next, the
function retrieves the node that contains the selected text, followed by any children of the node,
as shown in the following code:
function canAcceptCommand(){
var theDOM = dw.getDocumentDOM(); // Get the DOM of the current document
var theSel = theDOM.getSelection(); // Get start and end of selection
var theSelNode = theDOM.getSelectedNode(); // Get the selected node
var theChildren = theSelNode.childNodes; // Get children of selected node
The last line checks to see if the selection or its first child is text and returns the result as a value of
true or false:
return (theSel[0] != theSel[1] && (theSelNode.nodeType ==
Node.TEXT_NODE || theSelNode.hasChildNodes() && (theChildren[0].nodeType ==
Node.TEXT_NODE)));
The first part of the return statement (theSel[0] != theSel[1]) checks if the user has selected
anything in the document. The variable theSel is a two-slot array that holds the beginning and
ending offsets of the selection within the document. If the two values are not equal, content has
been selected. If the values in the two slots are equal, there is only an insertion point and nothing
has been selected.
Otherwise, canAcceptCommand() returns the value false and Dreamweaver dims the item, as
shown in the following figure:
changeCase()
The changeCase() function is a user-defined function that is called by the commandButtons()
function when the user clicks OK. This function changes the selected text to uppercase or
lowercase. Because the UI uses radio buttons, the code can rely on one choice or the other being
checked; it does not need to test for the possibility that the user makes neither choice.
The changeCase() function first tests the property
document.forms[0].elements[0].checked. The document.forms[0].elements[0]
property refers to the first element in the first form of the current document object, which is the
UI for the extension. The checked property has the value true if the element is checked
(or enabled) and false if it is not. In the interface, elements[0] refers to the first radio button,
which is the Uppercase button. Because one of the radio buttons is always checked when the
user clicks OK, the code assumes that if the choice is not uppercase, it must be lowercase. The
function sets the variable uorl to “u” or “l” to store the user’s response, as shown in the
following code:
function changeCase() {
var uorl;
Next, click the Reload Extensions item on the Context menu, as shown in the following figure:
The Change Case entry should now appear on the Commands menu.
When Dreamweaver starts, it creates a Commands menu entry for each HTML file in the
Commands folder, except those that contain the following line:
<!-- MENU-LOCATION=NONE -->
Because the Change Case.html file does not contain this line, Dreamweaver adds an entry for
Change Case to the Commands menu. The entry will be dim, however, until the user selects text
in the document.
To test the command, type some text in a document, select it, and select Change Case from the
Commands menu.
Macromedia Dreamweaver MX 2004 creates all its menus from the structure defined in the
menus.xml file in the Dreamweaver Configuration/Menus folder. You can rearrange, rename, and
remove menu items by editing the menus.xml file. You can also add, change, and remove
keyboard shortcuts for menu items, although in most cases it is easier to do that using the
Keyboard Shortcut Editor (see Dreamweaver Help). Changes to the Dreamweaver menus take
effect the next time you start Dreamweaver or reload extensions.
In a multiuser operating system, when you make changes within Dreamweaver that result in
changes to menus.xml (such as changing keyboard shortcuts using the Keyboard Shortcut
Editor), Dreamweaver creates a new menus.xml file in your user Configuration folder. To
customize menus.xml in a multiuser operating system, edit the copy of the file in your user
Configuration folder (or copy the master menus.xml file to your user Configuration folder if
Dreamweaver hasn’t yet created a version there). For more information, see “About customizing
Dreamweaver in a multiuser environment” on page 29.
If you open menus.xml in an XML editor, you might see error messages regarding the ampersands
(&) in the menus.xml file. It’s best to edit menus.xml in a text editor; do not edit it in
Dreamweaver. For basic information about XML, see Dreamweaver Help.
Note: Always make a backup copy of the current menus.xml file, or any other Dreamweaver
configuration file, before you modify it. It’s easy to make mistakes while editing the menu
configuration file, and there’s no way to revert to a previous set of menus other than replacing the
menus.xml file. In case you forget to make a backup, the Configuration folder contains a backup of the
default menus.xml file, called menus.bak; to revert to the default menu set, replace menus.xml with a
copy of menus.bak.
145
About the menus.xml file
The menus.xml file contains a structured list of menu bars, menus, menu items, separators,
shortcut lists, and keyboard shortcuts. These items are described by XML tags that you can edit in
a text editor.
Note: Be careful when making changes to menus. Dreamweaver ignores any menu or menu item that
contains an XML syntax error.
A menu bar (tagged with opening and closing menubar tags) is a discrete menu or set of menus—
for example, there’s a main menu bar, a separate Site window menu bar (which appears only on
Windows, not the Macintosh), and a menu bar for each context menu. Each menu bar contains
one or more menus; a menu is contained in a menu tag. Each menu contains one or more menu
items, each described by a menuitem tag and its attributes. A menu can also contain separators
(described by separator tags) and submenus.
In addition to the keyboard shortcuts associated with menu items, Dreamweaver provides a
variety of other keyboard shortcuts, including alternate shortcuts and shortcuts that are available
only in certain contexts. For example, Control+Y (Windows) or Command+Y (Macintosh) is the
shortcut for Redo; but Control+Shift+Z or Command+Shift+Z is an alternate shortcut for Redo.
These alternates—and other shortcuts that can’t be represented in the tags for menu items—are
defined in shortcut lists in the menus.xml file. Each shortcut list (described by a shortcutlist
tag) contains one or more shortcuts, each of which is described by a shortcut tag.
The following sections describe the syntax of the menus.xml tags. Optional attributes are marked
in the attribute lists with curly braces ({}); all attributes not marked with curly braces are required.
<menubar>
Description
None.
The main (Document window) menu bar uses the following menubar tag:
<menubar name="Main Window" id="DWMainWindow">
<!-- menu tags here -->
</menubar>
<menu>
Description
Provides information about a menu or submenu to appear in the Dreamweaver menu structure.
Attributes
name, {app}, id, {platform}, {showIf}
• name The name of the menu as it will appear on the menu bar. To set the menu’s access key
(mnemonic) in Windows, use an underscore (_) before the access letter. The underscore is
automatically removed on the Macintosh.
• app The name of the application in which the menu is available. Not currently used.
• id The menu ID for the menu. Every ID in the file should be unique.
• platform Indicates that the menu should appear only on the given platform. Valid values
are "win" and "mac".
• showIf Specifies that the menu should appear only if the given Dreamweaver enabler is the
value true. The possible enablers are: _SERVERMODEL_ASP, _SERVERMODEL_ASPNET,
_SERVERMODEL_JSP, _SERVERMODEL_CFML (for all versions of ColdFusion),
_SERVERMODEL_CFML_UD4 (for UltraDev version 4 of ColdFusion), _SERVERMODEL_PHP,
_FILE_TEMPLATE, _VIEW_CODE, _VIEW_DESIGN, _VIEW_LAYOUT,
_VIEW_EXPANDED_TABLES, and _VIEW_STANDARD. You can specify multiple enablers by
placing a comma (which means AND) between the enablers. You can specify NOT with "!".
For example, if you want the menu to appear only in Code view for an ASP page, specify the
attribute as showIf="_VIEW_CODE, _SERVERMODEL_ASP".
Contents
This tag can contain one or more menuitem tags, and one or more separator tags. It can also
contain other menu tags (to create submenus) and standard HTML comment tags.
Container
<menuitem>
Description
■ Alt and Opt interchangeably specify the Alt key (Windows) or Option key (Macintosh).
■ A Plus (+) sign separates modifier keys if a given shortcut uses more than one modifier. For
example, Cmd+Opt+5 in the key attribute means the menu item is executed when the user
presses Control+Alt+5 (Windows) or Command+Option+5 (Macintosh).
■ Special keys are specified by name: F1 through F12, PgDn, PgUp, Home, End, Ins, Del, Tab,
Esc, BkSp, and Space. Modifier keys can also be applied to special keys.
• platform Indicates on which platform the item appears. Valid values are "win", meaning
Windows, or "mac", meaning Macintosh. If you don’t specify the platform attribute, the
menu item appears on both platforms. If you want a menu item to behave differently on
different platforms, supply two menu items with the same name (but different IDs): one
with platform="win" and the other with platform="mac".
• enabled Provides JavaScript code (usually a JavaScript function call) that determines
whether the menu item is currently enabled. If the function returns the value false, the
menu item is dimmed. The default value is "true", but it’s best to always specify a value
for clarity even if the value is "true".
• arguments Provides arguments for Dreamweaver to pass to the code in the JavaScript file
that you specify in the file attribute. Enclose arguments in single quotation marks ('),
inside the double quotation marks (") used to delimit an attribute’s value.
• command Specifies a JavaScript expression that’s executed when the user selects this item
from the menu. For complex JavaScript code, use a JavaScript file (specified in the file
attribute) instead. You must specify either file or command for each menu item.
• file The name of an HTML file containing JavaScript that controls the menu item. Specify a
path to the file relative to the Configuration folder. (For example, the Help > Welcome menu
item specifies file="Commands/Welcome.htm".) The file attribute overrides the command,
enabled, and checked attributes. You must specify either file or command for each menu
item. For information on creating a command file using the History panel, see Dreamweaver
Help. For information on writing your own JavaScript commands, see Chapter 7,
“Commands,” on page 135.
• checked A JavaScript expression that indicates whether the menu item has a check mark
next to it in the menu; if the expression evaluates as true, the item appears with a
check mark.
<separator>
Description
Indicates that a separator should appear at the corresponding location in the menu.
Attributes
{app}
• app The name of the application in which the separator is shown. Not currently used.
Contents
This tag can contain one or more shortcut tags. It can also contain one or more comment tags
(which use the same syntax as HTML comment tags).
Container
None.
Example
<shortcutlist id="DWMainWindow">
<!-- shortcut and comment tags here -->
</shortcutlist>
<shortcut>
Description
Contents
9 Write your new shortcut in the appropriate location in the Keyboard Shortcut Matrix.
Modifying pop-up menus and context menus
Dreamweaver provides pop-up menus and context menus in many of its panels and dialog boxes.
Some context menus are defined in the menus.xml file; others are defined in other XML files. You
can add, remove, or modify items in those menus, although in most cases it’s better to write an
extension to make such changes.
The following pop-up menus and context menus in Dreamweaver are specified in XML files,
using the same tags as menus.xml:
• Data sources (listed in the Plus (+) pop-up menu on the Bindings panel) are specified in
DataSources.xml files, in subfolders of the DataSources folder.
• Server behaviors (listed in the Plus (+) pop-up menu on the Server Behaviors panel) are
specified in ServerBehaviors.xml files, in subfolders of the ServerBehaviors folder.
• Server formats (listed in the Plus (+) pop-up menu in the Edit Format List dialog box) are
specified in ServerFormats.xml files, in subfolders of the ServerFormats folder.
• Items in the formats pop-up menu for a binding in the Bindings panel are specified in
Formats.xml files, in subfolders of the ServerFormats folder. You can add entries to this menu
from inside Dreamweaver by using the Add Format dialog box.
• The Tag Library Editor dialog box menu items are specified in the TagLibraries/TagImporters/
TagImporters.xml file.
• Menu items for parameters in the Generate Behavior dialog box, which is part of the Server
Behavior Builder, are specified in Shared/Controls/String Menu/Controls.xml.
• Items for context menus associated with ColdFusion Components are specified in
Components/ColdFusion/CFCs/CFCsMenus.xml.
• Items for context menus associated with ColdFusion data sources are specified in
Components/ColdFusion/DataSources/DataSourcesMenus.xml.
• Items for context menus associated with JavaBeans are specified in Components/Jsp/
JavaBeans/JavaBeanMenus.xml.
• Items for context menus associated with various server components are specified in XML
files, in subfolders of the Components folder.
To create new commands that are automatically placed in the Commands menu, use the History
panel. Alternatively, you can use the Extension Manager to install new extensions, including
commands. For more information, see Dreamweaver Help.
To reorder the items in the Commands menu, or to move items between menus, you must edit
the menus.xml file.
To rename a command you’ve created:
1 Select Commands > Edit Command List.
A dialog box appears, listing all the commands whose names you can change. (Commands
that are in the default Commands menu don’t appear on this list and can’t be edited using
this approach.)
2 Select a command to rename.
3 Enter a new name for it.
4 Click Close.
The command is renamed in the Commands menu.
canAcceptCommand()
Description
Returns
Dreamweaver expects a Boolean value: true if the item should be enabled; false otherwise.
commandButtons()
Description
Defines the buttons that appear on the right side of the Options dialog box and their behavior
when they are clicked. If this function is not defined, no buttons appear, and the BODY section of
the Menu Commands file expands to fill the entire dialog box.
Arguments
None.
Returns
Dreamweaver expects an array that contains an even number of elements. The first element is a
string that contains the label for the topmost button. The second element is a string of JavaScript
code that defines the behavior of the topmost button when it is clicked. The remaining elements
define additional buttons in the same manner.
The following example of the commandButtons() function defines the OK, Cancel, and Help
buttons:
function commandButtons(){
return new Array("OK" , "doCommand()" , "Cancel" , ¬
"window.close()" , "Help" , "showHelp()");
}
getDynamicContent()
Description
Dreamweaver expects an array of strings where each string contains the name of a menu item
and its unique ID, separated by a semicolon. If the function returns a null value, the menu does
not change.
Example
The following example of the getDynamicContent() function returns an array of four menu
items (My Menu Item 1, My Menu Item 2, My Menu Item 3, and My Menu Item 4):
function getDynamicContent(){
var stringArray= new Array();
var i=0;
var numItems = 4;
return stringArray;
}
Returns
Dreamweaver expects a Boolean value: true if a check mark should appear next to the menu
item; false otherwise.
Example
function isCommandChecked()
{
var bChecked = false;
var cssStyle = arguments[0];
if (dw.getDocumentDOM() == null)
return false;
if (cssStyle == "(None)")
{
return dw.cssStylePalette.getSelectedStyle() == '';
}
else
{
return dw.cssStylePalette.getSelectedStyle() == cssStyle;
}
return bChecked;
}
Processes any arguments passed from a menu item or from the dw.runCommand() function. If it
is a dynamic menu item, it processes the dynamic menu item ID.
Arguments
{arg1}, {arg2},...{argN}
• If it is a dynamic menu item, the unique ID that the getDynamicContents() function
specifies is the only argument. Otherwise, if the arguments attribute is defined for a menuitem
tag, the value of that attribute passes to the receiveArguments() function (and to the
canAcceptCommand(), isCommandChecked(), and setMenuText() functions) as one or more
arguments. The arguments attribute is useful for distinguishing between two menu items that
call the same menu command.
Note: The arguments attribute is ignored for dynamic menu items.
Returns
setMenuText()
Description
Arguments
{arg1}, {arg2},...{argN}
• If the arguments attribute is defined for a menuitem tag, the value of that attribute passes to
the setMenuText() function (and to the canAcceptCommand(), isCommandChecked(), and
receiveArguments() functions) as one or more arguments. The arguments attribute is useful
for distinguishing between two menu items that call the same menu command.
Returns
windowDimensions()
Description
Sets specific dimensions for the Parameters dialog box. If this function is not defined, the window
dimensions are computed automatically.
Note: Do not define this function unless you want a dialog box that is larger than 640 x 480 pixels.
Arguments
platform
• The value of the platform argument is either "macintosh" or "windows", depending on the
user’s platform.
Returns
The following example of windowDimensions() sets the dimensions of the Parameters dialog box
to 648 x 520 pixels:
function windowDimensions(){
return "648,520";
}
receiveArguments()
Dreamweaver calls the receiveArguments() function to process any arguments that you defined
for the menuitem tag. For the Undo and Redo menu items, the receiveArguments() function
calls either the dw.undo() function or the dw.redo() function, depending on whether the value
of the argument, arguments[0], is "undo" or "redo". The dw.undo() function undoes the
previous step that the user performed in the document window, dialog box, or panel that has
focus. The dw.redo() function redoes the last operation that was undone.
The receiveArguments() function looks like the following example code:
function receiveArguments()
{
if (arguments.length != 1) return;
if (whatToDo == "foo"){
doOperationX(arguments[1]);
}else if (whatToDo == "bar"){
doOperationX(arguments[1]);
}
}
setMenuText()
Dreamweaver calls the setMenuText() function to determine what text appears for the menu
item. If you do not define the setMenuText() function, Dreamweaver uses the text that you
specified on the name attribute of the menuitem tag.
The setMenuText() function checks the value of the argument that Dreamweaver passes,
arguments[0]. If the value of the argument is "undo", Dreamweaver calls the
dw.getUndoText() function; if it is "redo", Dreamweaver calls dw.getRedoText(). The
dw.getUndoText() function returns text that specifies the operation that Dreamweaver will
undo. For example, if the user executes multiple Redo operations, dw.getUndoText() could
return the menu text, Undo Edit Source. Likewise, the dw.getRedoText() function returns text
that specifies the operation that Dreamweaver will redo. If the user executes multiple Undo
operations, the dw.RedoText() function could return the menu text, Redo Edit Source.
The setMenuText() function looks like the following example code:
function setMenuText()
{
if (arguments.length != 1) return "";
A dynamic menu
This example implements the Dreamweaver Preview in Browser submenu that displays a list of
available browsers. The example also opens the current file, or the selected files in the Site panel,
in the user-specified browser. Implementing this dynamic menu consists of the following steps:
1 Creating the dynamic menu items
2 Writing the JavaScript code
The name attribute for the first menu item specifies the command file PIB_Dynamic.htm. This
file contains the following line:
<SCRIPT LANGUAGE="javascript" SRC="PIB_Dynamic.js"></SCRIPT>
The script tag includes the JavaScript code in the PIB_Dynamic.js file, which supplies the
JavaScript code that interacts with the Preview in Browser submenu. This code could be saved
directly in the PIB_Dynamic.htm file, but storing it in a separate file allows multiple commands
to include the same code.
if (dw.getPrimaryBrowser() == PIB[i+1])
browsers[j] += "\tF12";
else if (dw.getSecondaryBrowser() == PIB[i+1])
browsers[j] += "\tCmd+F12";
browsers[j] += ";id='"+escQuotes(PIB[i])+"'";
if (itemID == "DWPopup_PIB_Default")
browsers[j] = MENU_strPreviewIn + browsers[j];
j = j+1;
}
return browsers;
}
The getDynamicContent() function calls the dw.getBrowserList() function to obtain an
array of the browser names that have been specified in the Preview in Browser section of
Dreamweaver Preferences. This array contains the name of each browser and the path to the
executable file. Next, for each item in the array (i=0; i<PIB.length; i=i+2), the
getDynamicContents() function moves the name of the browser (PIB[i]) into a second array
called browsers (browsers[j] = new String(PIB[i]);). If the browser has been designated as
the primary or secondary browser, the function appends the names of the keyboard shortcut keys
that invoke them. Next it appends the string ";id=" followed by the name of the browser in
single quotes (for example, ;id=’iexplore’). If the itemID argument is
"DWPopup_PIB_Default", the function prefixes the array item with the string Preview in.
After it constructs an entry for each browser listed in Preferences, the getDynamicContent()
function returns the array browsers to Dreamweaver. If no browsers have been selected in
Preferences, the function returns the value null, and Dreamweaver displays No Browsers Selected
in the menu.
havePreviewTarget()
The havePreviewTarget() function is a user-defined function that returns the value true
if Dreamweaver has a valid target to display in the browser. A valid target is a document or a
selected group of files in the site panel. The havePreviewTarget() function looks like the
following example:
function havePreviewTarget()
{
var bHavePreviewTarget = false;
if (dw.getFocus(true) == 'site')
{
if (site.getFocus() == 'remote')
{
bHavePreviewTarget = site.getRemoteSelection().length > 0 &&
site.canBrowseDocument();
}
else if (site.getFocus() != 'none')
{
var selFiles = site.getSelection();
if (selFiles.length > 0)
{
var i;
bHavePreviewTarget = true;
if (selFile.indexOf("://") == (-1))
{
var urlPrefix = "file:///";
var strTemp = selFile.substr(urlPrefix.length);
if (selFile.indexOf(urlPrefix) == -1)
bHavePreviewTarget = false;
else if (strTemp.indexOf("/") == -1)
bHavePreviewTarget = false;
else if (!DWfile.exists(selFile))
bHavePreviewTarget = false;
else if (DWfile.getAttributes(selFile).indexOf("D") != -1)
bHavePreviewTarget = false;
}
else
{
bHavePreviewTarget = true;
}
}
}
}
}
else if (dw.getFocus() == 'document' ||
dw.getFocus() == 'textView' || dw.getFocus("true") == 'html' )
{
var dom = dw.getDocumentDOM('document');
if (dom != null)
{
var parseMode = dom.getParseMode();
if (parseMode == 'html' || parseMode == 'xml')
bHavePreviewTarget = true;
}
}
return bHavePreviewTarget;
}
The havePreviewTarget() function sets the value bHavePreviewTarget to false as the
default return value. The function performs two basic tests calling the dw.getFocus() function
to determine what part of the application currently has focus. The first test checks whether the
site panel has focus (if (dw.getFocus(true) == 'site')). If the site panel does not have
focus, the second test checks to see if a document (dw.getFocus() == 'document'), Text view
(dw.getFocus() == 'textView'), or the Code inspector (dw.getFocus("true") == 'html')
has focus. If neither test is true, the function returns the value false.
If the site panel has focus, the function checks whether the view setting is Remote view. If it is, the
function sets bHavePreviewTarget to true if there are remote files
(site.getRemoteSelection().length > 0) and the files can be opened in a browser
(site.canBrowseDocument()). If the view setting is not Remote view, and if the view is not
None, the function gets a list of the selected files (var selFiles = site.getSelection();) in
the form of file:/// URLs.
If a document, Text view, or the Code inspector have focus (else if (dw.getFocus() ==
'document' || dw.getFocus() == 'textView' || dw.getFocus("true") == 'html' )),
the function gets the DOM and checks to see if the document is an HTML or an XML
document. If so, the function sets bHavePreviewTarget to true. Finally, the function returns
the value stored in bHavePreviewTarget.
receiveArguments()
Dreamweaver calls the receiveArguments() function to let the command process
any arguments that pass from the menu item. For the Preview in Browsers menu,
the receiveArguments() function invokes the browser that the user selects.
The receiveArguments() function looks like the following example:
function receiveArguments()
{
var whichBrowser = arguments[0];
var theBrowser = null;
var i=0;
var browserList = null;
var result = false;
if (havePreviewTarget())
{
// Code to check if we were called from a shortcut key
if (whichBrowser == 'primary' || whichBrowser == 'secondary')
{
// get the path of the selected browser
if (whichBrowser == 'primary')
{
theBrowser = dw.getPrimaryBrowser();
}
else if (whichBrowser == 'secondary')
{
theBrowser = dw.getSecondaryBrowser();
}
// If they clicked OK, show the prefs dialog with the browser panel
if (result)
dw.showPreferencesDialog('browsers');
}
}
}
The function first sets the variable whichBrowser to the value that Dreamweaver passes,
arguments[0]. Along with setting other default values, the function also sets return to a default
value of false.
After initializing variables, the receiveArguments() function calls the user-defined function
havePreviewTarget() and tests the result. If the result of the test is true, the function checks to
see if the user selected the primary or secondary browser. If so, the function sets the variable
theBrowser to the path of the executable file that starts the browser (dw.getPrimaryBrowser()
or dw.getSecondaryBrowser()). The function then performs a loop that examines the list of
browsers returned by dw.getBrowsersList(). If the path to a browser in the list matches the
path to the primary or secondary browser, the function sets the variable theBrowser to the
matching value in browserList. This value contains the name of the browser and the path to the
executable file that starts the browser. If havePreviewTarget() returns the value false, the
function sets the variable theBrowser to the value of the variable whichBrowser.
Next, the receiveArguments() function tests the variable theBrowser to make sure that it does
not begin with a path, that it is not "undefined", and that it has a length greater than zero. If all
these conditions are true, and if the Site panel has focus, the receiveArguments() function calls
the site.browseDocument() function to invoke the selected browser with the files selected in
the Site panel. If the Site panel does not have focus, the receiveArguments() function calls the
function dw.browseDocument() and passes it the path of the current document and the value
of the variable theBrowser, which specifies the name of the browser with which to open
the document.
You can create a toolbar for Macromedia Dreamweaver MX 2004 simply by creating a file that
defines the toolbar and placing that file in the Configuration/Toolbars folder. Within a toolbar
file, you can define items such as check buttons, radio buttons, text boxes, and pop-up menus
using a few custom XML tags. You can assign attributes and commands to toolbar items to
specify how they look and behave, include other toolbar files, and reference toolbar items that are
defined in other toolbars.
Unlike menus, you can define toolbar items independently from the toolbars that use them. This
flexibility lets you use toolbar items in multiple toolbars by using the itemref tag.
The first time Dreamweaver loads a toolbar, its visibility and position are set by the toolbar
definition. After that, its visibility and position are saved in and restored from the registry
(Windows) or the Dreamweaver Preferences file (Macintosh).
171
How toolbars behave
In Windows, Dreamweaver toolbars generally act the same as standard Windows toolbars.
Dreamweaver toolbars have the following characteristics:
• You can drag and drop toolbars to dock them, undock them, and reposition them relative to
other toolbars.
• You can horizontally dock toolbars to the top or bottom of the frame window.
In the Dreamweaver workspace, which integrates all the Dreamweaver document windows
within a single parent frame, you can specify whether toolbars dock to the workspace frame or
to the document window.
For toolbars that dock to the Dreamweaver workspace frame, there is only one instance of each
toolbar. In this case, the toolbars always operate on the document in front. In the
Dreamweaver workspace, you can dock toolbars above, below, or to the left or right of the
Insert toolbar. Toolbars that are attached to the Dreamweaver workspace frame do not
automatically disable when there is no document window. The toolbar items determine
whether they are enabled when no document is open.
When toolbars stay docked to the document window, there is one instance for each window.
Toolbars that are attached to a document window completely disable themselves when their
window is not the front document and rerun all their update handlers when their window
comes to the front.
You cannot drag and drop toolbars between the document window and the Dreamweaver
workspace frame.
• Toolbars remain a fixed size. A toolbar does not shrink if the container shrinks or if other
toolbars are placed next to it.
• You can show or hide toolbars from the View >Toolbars menu.
• Toolbars cannot overlap.
• Only the outline of the toolbar appears while you drag it.
On the Macintosh, toolbars are always attached to the document window. They can be shown or
hidden from the menu, but you cannot drag and drop, rearrange, or undock them.
Defines a toolbar. Dreamweaver displays the items and separators from left to right in the
specified order, laying out the items automatically. The toolbar file does not specify control over
the spacing between the items, but you can specify the widths of certain kinds of items.
Attributes
id, label, {container}, {initiallyVisible}, {initialPosition}, {relativeTo}
• id="unique_id" Required. An identifier string must be unique within a file and within all
files that the file includes. The JavaScript API functions that manipulate a toolbar refer to it by
its ID. For more information on these functions, see the Dreamweaver API Reference. If two
toolbars that are included in the same file have the same ID, Dreamweaver displays an error.
• label="string" Required. The label attribute specifies the label, which is a character string,
that Dreamweaver displays to the user. The label appears in the View >Toolbars menu and in
the title bar of the toolbar when it’s floating.
• container="mainframe" or "document" Defaults to "mainframe". Specifies where the
toolbar should dock in the Dreamweaver workspace on Windows. If the container is set to
"mainframe", the toolbar appears in the outer workspace frame and operates on the front
document. If the container is set to "document", the toolbar appears in each document
window. On the Macintosh, all toolbars appear in each document window.
• initiallyVisible="true" or "false". This tag specifies whether the toolbar should be
visible the first time that Dreamweaver loads it from the Toolbars folder. After the first time,
the user controls visibility. Dreamweaver saves the current state to the system registry
(Windows) or the Dreamweaver Preferences file (Macintosh) when the user quits
Dreamweaver. Dreamweaver restores the setting from the registry or the Preferences file when
it restarts. You can manipulate toolbar visibility using the dom.getToolbarVisibility() and
dom.setToolbarVisibility() functions, as described in the Dreamweaver API Reference. If
you do not set the initiallyVisible attribute, it defaults to true.
• initialPosition="top", "below", or "floating". Specifies where Dreamweaver initially
positions the toolbar, relative to other toolbars, the first time that Dreamweaver loads it. The
possible values for intialPosition are described in the following list:
■ top This is the default position, so the toolbar appears at the top of the document window.
If multiple toolbars specify top for a given window type, the toolbars appear in the order
that Dreamweaver encounters them during loading, which might not be predictable, if the
toolbars reside in separate files.
■ below The toolbar appears at the beginning of the row immediately below the toolbar that
Dreamweaver automatically places the toolbar so it is offset from other floating toolbars. On
the Macintosh, floating is treated the same as top.
The toolbar tag contains include, itemref, and separator tags as well as individual item
definitions such as button, combobox, dropdown, and so on. For descriptions of the item
definitions that you can specify, see “Toolbar item tags” on page 177.
Container
<include/>
Description
Loads toolbar items from the specified file before continuing to load the current file. Toolbar
items that are defined in the included file can be referenced in the current file. If a file attempts to
recursively include another file, Dreamweaver displays an error message and ignores the recursive
include. Any toolbar tags in the included file are skipped, although toolbar items in those
toolbars are available for reference in the current file.
Attributes
• The file path, relative to the Toolbars folder, of the toolbar XML file to include.
Contents
None.
Container
Defines a single toolbar item. Toolbar items include buttons, radio buttons, check buttons,
combo boxes, pop-up menus, and so on. For a list of the types of toolbar items that you can
define, see “Toolbar item tags” on page 177.
Attributes
The attributes vary, depending on the item that you define. For a complete list of the attributes
that you can specify for toolbar items, see “Item tag attributes” on page 182.
Contents
None.
Container
<itemref/>
Description
Refers to (and includes in the current toolbar) a toolbar item that was defined either inside a
previous toolbar or outside of all toolbars.
Attributes
id, {showIf}
• id="id_reference" Required. Must be the ID of an item that was previously defined or
included in the file. Dreamweaver does not allow forward references. If a toolbar item tag
references an undefined ID, Dreamweaver reports an error and ignores the reference.
• showIf="script" Specifies that this item appears on the toolbar only if the specified script
returns a true value. For example, you can use showIf to show certain buttons only in a given
application or only when a page is written in a server-side language such as ColdFusion, ASP,
or JSP. If you do not specify showIf, the item always appears. Dreamweaver checks this
property whenever the item’s enabler runs; that is, according to the value of the update
attribute. You should use this attribute sparingly. The showIf attribute can be used either in
the item definition or in a reference to the item from a toolbar. If both the definition and the
reference specify the showIf attribute, Dreamweaver shows the item only if both conditions
are true. The showIf attribute is equivalent to the showIf() function in a command file.
Contents
None.
Container
None.
Container
<button>
Description
This push button executes a specific command when you click it. It looks and acts the same as the
Reference button on the Dreamweaver toolbar.
Attributes
id, image, tooltip, command, {showIf}, {disabledImage}, {overImage}, {label},
{file}, {domRequired}, {enabled}, {update}, {arguments}
For a description of each attribute, see “Item tag attributes” on page 182.
Contents
None.
Container
<checkbutton>
Description
A check button is a button that has a checked or unchecked state and that executes a specific
command when clicked. When it is checked, it appears pressed in and highlighted. When it is not
checked, it appears flat. Dreamweaver implements the following states for the check button:
Mouse-over, Pressed, Mouse-over-while-pressed, and Disabled-while-pressed. The handler that is
specified by the checked attribute or the isCommandChecked() function must ensure that
clicking the check button causes the button’s state to toggle.
Attributes
id, {showIf}, image, {disabledImage}, {overImage}, tooltip, {label}, {file},
{domRequired}, {enabled}, checked, {update}, command, {arguments}
For a description of each attribute, see “Item tag attributes” on page 182.
Contents
None.
Container
<radiobutton>
Description
A radio button is exactly the same as a check button, except that when it is off, it appears as a
raised button. Dreamweaver implements the following states for the radio button: Mouse-over,
Pressed, Mouse-over-while-pressed, and Disabled-while-pressed. Dreamweaver does not enforce
mutual exclusion between radio buttons. The handler that the checked attribute or the
isCommandChecked() function specifies must ensure that the checked and unchecked states of
radio buttons are consistent with each other.
None.
Container
<menubutton>
Description
A menu button is a button that invokes the context menu that is specified by the menuid
attribute. Dreamweaver implements Mouse-over and Pressed states for menu buttons.
Dreamweaver does not draw the menu arrow, which is the downward-pointing arrow that
indicates menu items are attached to the button; you must include it in your icon. The File
Management and Code Navigation buttons on the Dreamweaver document toolbar are examples
of menu buttons.
Attributes
id, image, tooltip, menuID, domRequired, enabled, {showIf}, {disabledImage},
{overImage}, {label}, {file}, {update}
For a description of each attribute, see “Item tag attributes” on page 182.
Contents
None.
Container
<dropdown>
Description
A dropdown menu is a noneditable menu that executes a specific command when you select an
entry and the menu updates itself, based on an attached JavaScript function. The dropdown
menu looks and acts the same as the Format control in the Text Property inspector, except it’s a
standard size instead of the small Property inspector size.
Attributes
id, tooltip, file, enabled, checked, value, command, {showIf}, {label},
{width}, {domRequired}, {update}, {arguments}
For a description of each attribute, see “Item tag attributes” on page 182.
Contents
None.
Container
<combobox>
Description
A combo box is an editable pop-up menu that executes its command when you select an entry or
when the user makes an edit in the text box and switches focus. The menu looks and acts the
same as the Font control on the Text Property inspector, except it’s a standard size instead of the
small Property inspector size.
Attributes
id, file, tooltip, enabled, value, command, {showiI}, {label}, {width},
{domRequired}, {update}, {arguments}
For a description of each attribute, see “Item tag attributes” on page 182.
Contents
None.
<editcontrol>
Description
An edit control box is a text-editing box that executes its command when the user changes text in
the box and switches focus.
Attributes
id, tooltip, file, value, command, {showIf}, {label}, {width}, {domRequired},
{enabled}, {update}, {arguments}
For a description of each attribute, see “Item tag attributes” on page 182.
Contents
None.
Container
<colorpicker>
Description
A color picker is a panel of colors that does not have an associated text box that executes its
command when the user selects a new color. This panel looks and acts the same as the color
picker on the Dreamweaver Property inspector. You can specify a different icon to replace the
default icon.
Attributes
id, tooltip, value, command, {showIf}, {image}, {disabledImage}, {overImage},
{label}, {colorRect}, {file}, {domRequired}, {enabled}, {update},
{arguments}
For a description of each attribute, see “Item tag attributes” on page 182.
Contents
None.
id="unique_id"
Required. The id attribute is an identifier for the toolbar item. The id attribute must be unique
within the current file and all files that are included within the current file. The itemref tag uses
the item id to refer to and include an item within a toolbar.
Example
<button id="DW_DocRerefresh" . . . >
showIf="script"
Optional. This attribute specifies that the item appears on the toolbar only if the script returns a
true value. For example, you can use the showIf attribute to show certain buttons only when a
page is written in a certain server-side language such as ColdFusion, ASP, or JSP. If you do not
specify showIf, the item always appears.
The showIf attribute is checked whenever the item’s enabler runs; that is, according to the value
of the update attribute. You should use the showIf attribute sparingly.
You can specify the showIf attribute in the item definition and in a reference to the item on an
itemref tag. If the definition and the reference specify the showIf attribute, the item shows only
if both conditions are true. The showIf attribute is the same as the showIf() function in a
toolbar command file. If you specify both the showIf attribute and the showif() function, the
function overrides the attribute.
Example
showIf="dw.canLiveDebug()"
image="image_path"
This attribute is required for buttons, check buttons, radio buttons, menu buttons, and combo
buttons. The image attribute is optional for color pickers and is ignored for other item types. The
image attribute specifies the path, relative to the Configuration folder, of the icon file that
displays on the button. The icon can be in any format that Dreamweaver can render, but typically
it is a GIF or JPEG file format.
disabledImage="image_path"
Optional. Dreamweaver ignores the disabledImage attribute for items other than buttons, check
buttons, radio buttons, menu buttons, color pickers, and combo buttons. This attribute specifies
the path, relative to the Configuration folder, of the icon file that Dreamweaver displays if the
button is disabled. If you do not specify the disabledImage attribute, Dreamweaver displays the
image that is specified in the image attribute when the button is disabled.
Example
disabledImage="Toolbars/images/MM/codenav_dis.gif"
overImage="image_path"
Optional. Dreamweaver ignores the overImage attribute for items other than buttons, check
buttons, radio buttons, menu buttons, color pickers, and combo buttons. This attribute specifies
the path, relative to the Configuration folder, of the icon file that Dreamweaver displays when the
user moves the mouse over the button. If you do not specify the overImage attribute, the button
does not change when the user moves the mouse over it, except for a ring that Dreamweaver
draws around the button.
Example
overImage="Toolbars/images/MM/codenav_ovr.gif"
tooltip="tooltip string"
Required. This attribute specifies the identifying text, or tooltip, that appears when the mouse
pointer hovers over the toolbar item.
Example
tooltip="Code Navigation"
label="label string"
Optional. This attribute specifies a label that displays next to the item. Dreamweaver does not
automatically add a colon to labels. Labels for nonbutton items are always positioned on the left
of the item. Dreamweaver places labels for buttons, check buttons, radio buttons, menu buttons,
and combo buttons inside the button and to the right of the icon.
Example
label="Title: "
menuID="menu_id"
This attribute is required for menu buttons and combo buttons, unless you specify the
getMenuID() function in an associated command file. Dreamweaver ignores the menuID attribute
for other types of items. This attribute specifies the ID of the menu bar that contains the context
menu to pop up when the user clicks the button, menu button, or combo button. The ID comes
from the ID attribute of a menubar tag in the menus.xml file.
Example
menuID="DWCodeNavPopup"
Example
colorRect=”0 12 16 16”
file="command_file_path"
Required for pop-up menus and combo boxes. The file attribute is optional for other types of
items. The file attribute specifies the path, relative to the Configuration folder, of a command
file that contains JavaScript functions to populate, update, and execute the item. The file
attribute overrides the enabled, checked, value, update, domRequired, menuID, showIf, and
command attributes. In general, if you specify a command file with the file attribute,
Dreamweaver ignores all the equivalent attributes that are specified in the tag. For more
information about command files, see “The toolbar command API” on page 187.
Example
file="Toolbars/MM/EditTitle.htm"
domRequired="true" or "false"
Optional. As with menus, the domRequired attribute specifies whether the Design view should be
synchronized with the Code view before Dreamweaver runs the associated command. If you do
not specify this attribute, it defaults to a true value. This attribute is equivalent to the
isDOMRequired() function in a toolbar command file.
Example
domRequired="false"
Example
enabled="dw.getFocus() == 'textView' || dw.getFocus() == 'html'"
checked="script"
This attribute is required for check buttons and radio buttons. Dreamweaver ignores the checked
attribute for other types of items. As with menus, the script returns a value that specifies whether
the item is checked or unchecked. The checked attribute is equivalent to isCommandChecked()
in a toolbar command file. If you do not specify this attribute, it defaults to unchecked.
Example
checked="dw.getDocumentDOM() != null && dw.getDocumentDOM().getView() ==
'code'"
value="script"
This attribute is required for pop-up menus, combo boxes, text boxes, and color pickers.
Dreamweaver ignores the value attribute for other types of items.
To determine what value to display for pop-up menus and combo boxes, Dreamweaver first calls
isCommandchecked() for each item in the menu. If the isCommandchecked() function returns a
true value for any items, Dreamweaver displays the value for the first one. If no items return a
true value or the isCommandChecked() function is not defined, Dreamweaver calls the
getCurrentValue() function or executes the script that the value attribute specifies. If the
control is a combo box, Dreamweaver displays the returned value. If the control is a pop-up
menu, Dreamweaver temporarily adds the returned value to the list and displays it.
In all other cases, the script returns the current value to display. For pop-up menus or combo
boxes, this value should be one of the items in the menu list. For combo boxes and text boxes, the
value can be any string that the script returns. For color pickers, the value should be a valid color
but Dreamweaver does not enforce this.
The value attribute is equivalent to the getCurrentValue() function in a toolbar command file.
update="update_frequency_list"
Optional. This attribute specifies how often the enabled, checked, showif, and value handlers
should run to update the visible state of the item. The update attribute is equivalent to the
getUpdateFrequency() function in a toolbar command file.
You must specify the update frequency for toolbar items because these items are always visible,
unlike menu items. For this reason, you should always select the lowest frequency possible and
make sure your handlers for the enabled, checked, and value handlers are as simple as possible.
Example
update="onViewChange"
command="script"
This attribute is required for all items except menu buttons. Dreamweaver ignores the command
attribute for menu buttons. Specifies the JavaScript function to execute when the user performs
one of the following actions:
• Clicks a button
• Selects an item from a pop-up menu or combo box
• Tabs out of, presses Return in, or clicks away from a text box or combo box
• Selects a color from a color picker
The command attribute is equivalent to the receiveArguments() function in a toolbar
command file.
Example
command="dw.toggleLiveDebug()"
arguments="argument_list"
Optional. This attribute specifies the comma-separated list of arguments to pass to
the receiveArguments() function in a toolbar command file. If you do not specify the
arguments attribute, Dreamweaver passes the ID of the toolbar item. In addition, pop-up menus,
combo boxes, text boxes, and color pickers pass their current value as the first argument, before
any arguments that the arguments attribute specifies, and before the item ID if no arguments
are specified.
On a toolbar that has Undo and Redo buttons, each button calls the menu command file,
Edit_Clipboard.htm, and passes an argument that specifies the action, as shown in the
following example:
<button id="DW_Undo"
image="Toolbars/images/MM/undo.gif"
disabledImage="Toolbars/images/MM/undo_dis.gif"
tooltip="Undo"
file="Menus/MM/Edit_Clipboard.htm"
arguments="'undo'"
update="onEveryIdle"/>
<button id="DW_Redo"
image="Toolbars/images/MM/redo.gif"
disabledImage="Toolbars/images/MM/redo_dis.gif"
tooltip="Redo"
file="Menus/MM/Edit_Clipboard.htm"
arguments="'redo'"
update="onEveryIdle"/>
canAcceptCommand()
Availability
Dreamweaver MX.
Description
Determines whether the toolbar item is enabled. The enabled state is the default condition for an
item, so you should not define this function unless it returns a false value in at least one case.
Arguments
For pop-up menus, combo boxes, text boxes, and color pickers, the first argument is the current
value within the control. The getDynamicContent() function can optionally attach individual
IDs to items within a pop-up menu. If the selected item in the pop-up menu has an ID attached,
Dreamweaver passes that ID to canAcceptCommand() instead of the value. For combo boxes, if
the current contents of the text box do not match an entry in the pop-up menu, Dreamweaver
passes the contents of the text box. Dreamweaver compares against the pop-up menu without
case-sensitivity to determine whether the contents of the text box match an entry in the list.
If you specify the arguments attribute for this toolbar item in the toolbars.xml file, those
arguments are passed next. If you did not specify the arguments attribute, Dreamweaver passes
the ID of the item.
Dreamweaver expects a Boolean value; true if the item is enabled; false otherwise.
Example
function canAcceptCommand()
{
return (dw.getDocumentDOM() != null);
}
getCurrentValue()
Availability
Dreamweaver MX.
Description
Returns the current value to display in the item. Dreamweaver calls the getCurrentValue()
function for pop-up menus, combo boxes, text boxes, and color pickers. For pop-up menus, the
current value should be one of the items in the menu. If the value is not in the pop-up menu,
Dreamweaver selects the first item. For combo boxes and text boxes, this value can be any string
that the function returns. For color pickers, the value should be a valid color, but Dreamweaver
does not enforce this. This function is equivalent to the value attribute.
Arguments
None.
Returns
Dreamweaver expects a string that contains the current value to display. For the color picker, the
string contains the RGB form of the selected color (for example #FFFFFF for the color white).
Example
function getCurrentValue()
{
var title = "";
var dom = dw.getDocumentDOM();
if (dom)
title = dom.getTitle();
return title;
}
getDynamicContent()
Availability
Dreamweaver MX.
Description
This function is required for pop-up menus and combo boxes. As with menus, this function
returns an array of strings that populate the pop-up menu. Each string can optionally end with
";id=id". If an ID is specified, Dreamweaver passes the ID to the receiveArguments()
function instead of the actual string to appear in the menu.
None.
Returns
Dreamweaver MX.
Description
Only valid for menu buttons. Dreamweaver calls the getMenuID() function to get the ID of the
menu that should appear when the user clicks the button.
Arguments
None.
Returns
Dreamweaver expects a string that contains a menu ID, which is defined in the menus.xml file.
Example
function getMenuID()
{
var dom = dw.getDocumentDOM();
var menuID = '';
if (dom)
{
var view = dom.getView();
var focus = dw.getFocus();
if (view == 'design')
{
menuID = 'DWDesignOnlyOptionsPopup';
}
else if (view == 'split')
{
if (focus == 'textView')
{
menuID = 'DWSplitCodeOptionsPopup';
}
else
{
menuID = 'DWSplitDesignOptionsPopup';
}
}
else if (view == 'code')
{
menuID = 'DWCodeOnlyOptionsPopup';
}
else
{
menuID = 'DWBrowseOptionsPopup';
}
}
return menuID;
}
Dreamweaver MX.
Description
Specifies how often to run the handlers for the enabled, checked, showIf, and value attributes
to update the visible state of the item.
You must specify the update frequency for toolbar items because they are always visible, unlike
menus. For this reason, you should always select the lowest frequency possible and make sure your
enabled, checked, and value handlers are as simple as possible.
This function is equivalent to the update attribute in a toolbar item.
Arguments
None.
Returns
Dreamweaver expects a string that contains a comma-separated list of update handlers. For a
complete list of the possible update handlers, see “update="update_frequency_list"” on page 185.
Example
function getUpdateFrequency()
{
return onSelChange”;
}
isCommandChecked()
Availability
Dreamweaver MX.
Description
Returns a value that specifies whether the item is selected. For a button, checked means that the
button appears on or depressed. The isCommandChecked() function is equivalent to the checked
attribute in a toolbar item tag.
Arguments
For pop-up menus, combo boxes, text boxes, and color pickers, the first argument is the current
value within the control. The getDynamicContent() function can optionally attach individual
IDs to items within a pop-up menu. If the selected item in the menu has an ID attached,
Dreamweaver passes that ID to the isCommandChecked() function instead of the value. For
combo boxes, if the current contents of the text box do not match an entry in the pop-up menu,
Dreamweaver passes the contents of the text box. For determining whether the text box matches,
Dreamweaver compares against the menu without case-sensitivity.
If you specified the arguments attribute, those arguments are passed next. If you do not specify
the arguments attribute, Dreamweaver passes the ID of the item.
Dreamweaver expects a Boolean value: true if the item is checked; false otherwise.
Example
The following example determines which item, if any, should be checked in a pop-up menu of
paragraph formats and CSS styles:
function isCommandChecked()
{
var bChecked = false;
var style = arguments[0];
var textFormat = dw.getDocumentDOM().getTextFormat();
if (dw.getDocumentDOM() == null)
bChecked = false;
if (style == "(None)")
bChecked = (dw.cssStylePalette.getSelectedStyle() == '' || textFormat ==
"" || textFormat == "P" || textFormat == "PRE");
else if (style == "Heading 1")
bChecked = (textFormat == "h1");
else if (style == "Heading 2")
bChecked = (textFormat == "h2");
else if (style == "Heading 3")
bChecked = (textFormat == "h3");
else if (style == "Heading 4")
bChecked = (textFormat == "h4");
else if (style == "Heading 5")
bChecked = (textFormat == "h5");
else if (style == "Heading 6")
bChecked = (textFormat == "h6");
else
bChecked = (dw.cssStylePalette.getSelectedStyle() == style);
return bChecked;
}
isDOMRequired()
Availability
Dreamweaver MX.
Description
Specifies whether the toolbar command requires a valid DOM to operate. If this function returns
a true value or if the function is not defined, Dreamweaver assumes that the command requires a
valid DOM and synchronizes the Code view and Design view for the document before executing
the associated command. This function is equivalent to the domRequired attribute in a toolbar
item tag.
Arguments
None.
Returns
Dreamweaver expects a Boolean value: true if the DOM is required; false otherwise.
receiveArguments()
Availability
Dreamweaver MX.
Description
Processes any arguments that pass from a toolbar item. The receiveArguments() function is
equivalent to the command attribute in a toolbar item tag.
Arguments
For pop-up menus, combo boxes, text boxes, and color pickers, the first argument is the current
value within the control. The getDynamicContent() function can optionally attach individual
IDs to items within a pop-up menu. If the selected item in the pop-up menu has an ID attached,
Dreamweaver passes that ID to the receiveArguments() function instead of the value. For
combo boxes, if the current contents of the text box do not match an entry in the pop-up menu,
Dreamweaver passes the contents of the text box. To determine whether the text box matches,
Dreamweaver compares against the pop-up menu without case-sensitivity.
If you specified the arguments attribute, those arguments are passed next. If you did not specify
the arguments attribute, Dreamweaver passes the ID of the item.
Returns
showIf()
Availability
Dreamweaver MX.
Description
Specifies that an item appears on the toolbar only if the function returns a true value. For
example, you can use the showIf() function to show certain buttons only when the page has a
certain server model. If the showif() function is not defined, the item always appears. The
showIf() function is the same as the showIf attribute in a toolbar item tag.
The showIf() function is called whenever the item’s enabler runs; that is, according to the value
that the getUpdateFrequency() function returns.
None.
Returns
Dreamweaver expects a Boolean value: true if the item appears; false otherwise.
Example
function showif()
{
var retval = false;
var dom = dw.getDocumentDOM();
if(dom)
{
var view = dom.getView();
if(view == ‘design’)
{
retval = true;
}
}
return retval;
}
You can use the Reports API functions to create custom site reports or modify the set of
prewritten reports that come with Macromedia Dreamweaver MX 2004. You can access site
reports only through the Site Reports dialog box.
You can use the Results Window API to create a stand-alone report. Stand-alone reports are
regular commands that directly use the Results Window API rather than the Reports API. You
can access a stand-alone report the same way as any other command, through the menus or
through another command.
Site reports reside in the Dreamweaver Configuration/Reports folder. The Reports folder has
subfolders that represent report categories. Each report can belong to only one category. The
category name cannot exceed 31 characters. Each subfolder can have a file in it named
_foldername.txt. If this file is present, Dreamweaver uses its contents as the category name. If
_foldername.txt is not present, Dreamweaver uses the folder name as the category name.
Stand-alone reports reside in the Dreamweaver Configuration/Commands folder.
When the user selects multiple site reports from the Site Reports dialog box, Dreamweaver places
all the results in the same Results window under the Site Reports tab. Dreamweaver replaces these
results the next time the user runs any site report.
In contrast, Dreamweaver creates a new Results window each time the user runs a new stand-
alone report.
197
How site reports work
1 Reports are accessible through the Site > Reports... menu. When it is selected, this menu item
displays a dialog box from which the user selects reports to run on a choice of targets.
2 The user selects which files to run the selected reports on using the Report On: pop-up menu.
This menu contains Current Document, Entire Current Local Site, Selected Files In Site, and
Folder. When the user selects the Folder option, a Browse button and text field appear, so the
user can select a folder.
3 The user can customize reports that have parameters by selecting the Settings button and
entering values for the parameters. Each report must include a Settings dialog box, if a user
needs to set report parameters. This dialog box is optional; not every report requires the user to
set the report’s parameters. If a report does not have a Settings dialog box, then the Report
Settings... button is dimmed when the report is selected in the list.
4 After the reports are selected and their settings are set, the user clicks the Run button.
At this point, Dreamweaver clears all items from the Site Reports tab of the Results panel.
Dreamweaver calls the beginReporting() function in each report before the reporting
process begins. If a report returns a false value from this function, it is removed from the
report run.
5 Each file is passed to each report that was selected in the Reports dialog box using the
processFile() function. If the report needs to include information about this file in the results
list, it should call the dw.resultsPalette.siteReports.addResultItem() function. This
process continues until all files that pertain to the user’s selection are processed or the user clicks
the Stop button in the bottom of the window. Dreamweaver displays the name of each file being
processed and the number of files that remain to be processed.
Dreamweaver calls the endReporting() function in each report after all the files have been
processed and the reporting process completes.
processFile()
Availability
Dreamweaver 4.
Description
This function is called when there is a file to process. The Report command should process the
file without modifying it and use the dw.ResultsPalette.SiteReports() function, the
addResultItem() function, or the resWin.addItem() function to return information about the
file. Dreamweaver automatically releases each file’s DOM when it finishes.
Arguments
strFilePath
• The strFilePath argument is the full path and filename of the file to process.
Returns
beginReporting()
Availability
Dreamweaver 4.
Description
This function is called at the start of the reporting process, before any reports are run. If the
Report command returns a false value from this function, the Report command is excluded
from the report run.
Arguments
target
• The target argument is a string that indicates the target of the report session. It can be one of
the following values: "CurrentDoc", "CurrentSite", "CurrentSiteSelection" (for the
selected files in a site), or "Folder:+ the path to the folder the user selected" (for
example, "Folder:c:temp").
Returns
Dreamweaver expects a Boolean value: true if the report runs successfully; false if target is
excluded from the report run.
Dreamweaver 4.
Description
None.
Returns
commandButtons()
Availability
Dreamweaver 4.
Description
Defines the buttons that should appear on the right side of the Options dialog box and their
behavior when they are clicked. If this function is not defined, no buttons appear, and the BODY
section of the report file expands to fill the entire dialog box.
Arguments
None.
Returns
Dreamweaver expects an array that contains an even number of elements. The first element is a
string that contains the label for the topmost button. The second element is a string of JavaScript
code that defines the behavior of the topmost button when it is clicked. The remaining elements
define additional buttons in the same manner.
Example
The following instance of the commandButtons() function defines the OK, Cancel, and Help
buttons.
function commandButtons(){
return new Array("OK" , "doCommand()" , "Cancel" , ¬
"window.close()" , "Help" , "showHelp()");
}
Dreamweaver 4.
Description
Determines whether the Report Settings button should be enabled in the Reports dialog box
when this report is selected.
Arguments
None.
Returns
Dreamweaver expects a Boolean value: true if the Report Settings button should be enabled;
false otherwise.
windowDimensions()
Availability
Dreamweaver 4.
Description
Sets specific dimensions for the Parameters dialog box. If this function is not defined, the window
dimensions are computed automatically.
Note: Do not define this function unless you want an Options dialog box that is larger than
640 x 480 pixels.
Arguments
platform
• The value of the platform argument is either "macintosh" or "windows", depending on the
user’s platform.
Returns
The following instance of the windowDimensions() function sets the dimensions of the
Parameters dialog box to 648 x 520 pixels:
function windowDimensions(){
return "648,520";
}
Macromedia Dreamweaver MX 2004 users can use tag editors to insert new tags, edit existing
tags, and access reference information about tags. Dreamweaver comes with editors for the
following languages: HTML, ASP.Net, CFML, JRun, and JSP. You can customize tag editors that
come with Dreamweaver, and you can create new tag editors. You can also add new tags to the
tag libraries.
The Tag Chooser uses information that is stored in the tag libraries to let Dreamweaver users view
available tags and select them to use in the active document.
Dreamweaver stores information about each tag, including all tag attributes, in a set of subfolders
that reside in the Configuration/TagLibraries folder. The tag editor and Tag Chooser functions
use the information that is stored in this folder when manipulating and editing tags. Before you
can create custom tag editors, you should understand the tag library structure.
203
Tag library file format
A tag library consists of a single root file, the TagLibraries.vtm file, that lists every installed tag,
plus a VTML file for each tag in the tag library. The TagLibraries.vtm file functions as a table of
contents and contains pointers to each individual tag’s VTML file. The following figure shows
how Dreamweaver organizes the VTML files by markup language:
Macromedia HomeSite users can recognize the VTML file structure, but Dreamweaver does not
use VTML files in the same way as HomeSite. The most important difference is that
Dreamweaver contains its own HTML renderer that displays extension user interfaces (UIs), so
the Dreamweaver VTML files are not used in the GUI rendering process.
The following example illustrates the structure of the TagLibraries.vtm file:
<taglibraries>
<taglibrary name="Name of tag library" doctypes="HTML,ASP-JS,ASP-VB"
tagchooser="relative path to TagChooser.xml file" id="DWTagLibrary_html">
<tagref name="tag name" file="relative path to tag .vtm file"/>
</taglibrary>
Because the tagref.prefix attribute can override the taglibrary.prefix attribute, the
relationship between the two attributes can be confusing. The following table shows the
relationship between the taglibrary.prefix and tagref.prefix attributes:
No No '<' + tagref.name
Yes No taglibrary.prefix +
tagref.name
No Yes tagref.prefix
To define tags, Dreamweaver uses a modified version of the Macromedia VTML file format. The
following example demonstrates all the elements that Dreamweaver must use to define an
individual tag:
<tag name="input" bind="value" casesensitive="no" endtag="no">
<tagformat indentcontents="yes" formatcontents="yes" nlbeforetag ¬
nlbeforecontents=0 nlaftercontents=0 nlaftertag=1 />
<tagdialog file = "input.HTM"/>
<attributes>
<attrib name="name"/>
<attrib name="wrap" type="Enumerated">
<attriboption value="off"/>
<attriboption value="soft"/>
<attriboption value="hard"/>
</attrib>
<attrib name="onFocus" casesensitive="yes"/>
<event name="onFocus"/>
</attributes>
</tag>
Note: In versions before Dreamweaver MX, tag information is stored in the Configuration/
TagAttributeList.txt file.
TagChooser.xml files
The TagChooser.xml file provides the metadata for organizing tag groupings that appear in the
Tag Chooser. Each tag that comes with Dreamweaver is stored in a functional grouping and is
available in the Tag Chooser. By editing the TagChooser.xml file, you can regroup existing tags
and group new tags. You can customize how tags are organized for your users by creating
subcategories so they can easily access their most important tags.
The TagLibraries.vtm file supports the use of the TAGLIBRARY.TAGCHOOSER attribute, which
points to the TagChooser.xml file. If you change existing TagChooser.xml files or create new ones,
the TAGLIBRARY.TAGCHOOSER attribute must point to the correct location for the Tag Chooser to
be fully functional.
If there is no TAGLIBRARY.TAGCHOOSER attribute, the Tag Chooser displays the tree structure that
is in the TagLibraries.vtm file.
TagChooser.xml files are stored in Configuration/TagLibraries/TagLibraryName folder. The
following example shows the structure of TagChooser.xml files:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<tclibrary name="Friendly name for library node" desc='Description for
incorporated reference' reference="Language[,Topic[,Subtopic]]">
The CATEGORY tag represents all other nodes in the Tree view under the TCLIBRARY ’s node, as
shown in the following table:
The following table lists the attributes of the ELEMENT tag, which represents the tag to insert:
Attribute Description
zip A five-digit ZIP code
tempaturescale The temperature scale (Celsius or Farhenheit)
The cfweather tag is a ColdFusion tag, so an appropriate tag library group already exists that you
can use to register the cfweather tag.
To register the tag:
1 Open the TagLibraries.vtm file in a text editor.
2 Scroll through the existing tag libraries to find the CFML tags taglibrary group.
3 Add a new tag reference element, as shown in the following example:
<tagref name="cfweather" file="cfml/cfweather.vtm"/>
4 Save the file.
The tag is now registered in the tag library, and it has a file pointer to the cfweather.vtm tag
definition file.
<ATTRIBUTES>
<ATTRIB NAME="zip" TYPE="TEXT"/>
<ATTRIB NAME="tempaturescale" TYPE="ENUMERATED">
<ATTRIBOPTION VALUE="Celsius"/>
<ATTRIBOPTION VALUE="Fahrenheit"/>
</ATTRIB>
</ATTRIBUTES>
</TAG>
2 Save the cfweather.vtm file in the Configuration/Taglibraries/CFML folder.
Using the tag definition file, Dreamweaver can perform code hinting, code completion, and
tag formatting functionality for the cfweather tag.
/****************************************************************/
function applyTag(tagNodeObj)
{
// call into a common library version of applyTagCommon defined
function initializeUI()
{
// define two arrays for the values and display captions for the list control
var theTempatureScaleCap = new Array("celsius","fahrenheit");
var theTempatureScaleVal = new Array("celsius","fahrenheit");
</head>
<body onLoad="initializeUI()">
<div name="General">
<table border="0" cellspacing="4">
<tr>
<td valign="baseline" align="right" nowrap="nowrap">Zip Code: </td>
<td nowrap="nowrap">
<input type="text" id="attr:cfargument:zip" name="thezip" attname="zip"
style="width:100px" />
</td>
</tr>
<tr>
<td valign="baseline" align="right" nowrap="nowrap">Type: </td>
<td nowrap="nowrap">
<select name="thetempaturescale" id="attr:cfargument:tempaturescale"
attname="tempaturescale" editable="false" style="width:200px">
</select>
</td>
</tr>
</table>
</div>
</body>
</html>
2 Verify that the tag editor is working by performing the following steps:
■ Launch Dreamweaver.
■ Type cfweather in Code view.
■ Right click on the tag.
2 Verify the cfweather tag now appears in the Tag Chooser by performing the following steps:
■ Select Insert > Tag.
■ Expand the CFML Tags group.
■ Select the Third Party Tags group that appears at the bottom of the Tag Chooser.
inspectTag()
Availability
Dreamweaver MX.
Description
The function is called when the tag editor first appears. The function receives as an argument the
tag that the user is editing, which is expressed as a dom object. The function extracts attribute
values from the tag that is being edited and uses these values to initialize form elements in the
tag editor.
Arguments
tag
• The tag argument is the DOM node of the edited tag.
Returns
validateTag()
Availability
Dreamweaver MX.
Description
When a user clicks on a node in the tree control or clicks OK, the function performs input
validation on the currently displayed HTML form elements.
Arguments
None.
Returns
Dreamweaver expects a Boolean value: true if the input for HTML form elements is valid; false
if input values are not valid.
Example
When the user creates a table, a negative integer is entered for the number of table rows. The
validateTag() function detects the invalid input, displays an alert message, and returns a
false value.
Dreamweaver MX.
Description
When the user clicks OK, Dreamweaver calls the validateTag() function. If the
validateTag() function returns a true value, Dreamweaver calls this function and passes the
dom object that represents the current tag (the tag that is being edited). The function reads the
values out of the form elements and writes them into the dom object.
Arguments
tag
• The tag argument is the DOM node of the tag being edited.
Returns
Continuing the cfweather example, in the following code, if the user changes the ZIP code from
94065 to 53402, in order to update the user’s document to use the new ZIP code, the dom object
must be updated:
function applyTag(tag)
{
tag.zip = document.forms[0].zip.value
}
The Property inspector is perhaps the most familiar floating panel in the Macromedia
Dreamweaver MX 2004 interface. It is indispensable for defining, reviewing, and changing the
name, size, appearance, and other attributes of the selection as well as for launching internal and
external editors for the selected element.
Dreamweaver has several built-in interfaces for the Property inspector that let you set properties
for many standard HTML tags. These built-in inspectors are part of the core Dreamweaver code;
for this reason, you cannot find corresponding Property inspector files for them in the
Configuration folder. Custom Property inspector files let you override these built-in interfaces or
create new ones to inspect custom tags. Custom Property inspector files are HTML files that
reside in the Configuration/Inspectors folder inside the Dreamweaver application folder. Property
inspector files must contain a comment (in addition to the doctype comment) immediately
preceding the opening HTML tag, as shown in the following example:
<!-- tag:tagNameOrKeyword,priority:1to10,selection:¬
exactOrWithin,hline,vline, serverModel-->
<!DOCTYPE HTML SYSTEM "-//Macromedia//DWExtension layout-engine5.0//pi">
This comment has the following elements:
• The tagNameOrKeyword element is the tag to be inspected or one of the following keywords:
*COMMENT* (for comments), *LOCKED* (for locked regions), or *ASP* (for ASP tags).
• The 1to10 element is the priority of the Property inspector file: 1 indicates that this inspector
should be used only when no others can inspect the selection; 10 indicates that this inspector
takes precedence over all others that can inspect the selection.
• The exactOrWithin element indicates whether the selection can be within the tag (within)
or must exactly contain the tag (exact).
• The hline element (optional) indicates that a horizontal gray line should appear between the
upper and lower halves of the inspector in expanded mode.
• The vline element (optional) indicates that a vertical gray line should appear between the tag
name field and the rest of the properties in the inspector (for an example, see an HTML file in
the Configuration/Inspectors folder).
• The serverModel element (optional) indicates the server model of the Property inspector. If
the server model of the Property inspector is not the same as the server model for the
document, Dreamweaver does not use the Property inspector to display the properties of the
current selection.
217
The following comment is appropriate for an inspector that is designed to inspect the HAPPY tag:
<!-- tag:HAPPY, priority:8,selection:exact,hline,vline, ¬
serverModel:ASP -->
In some cases, you might want to specify that your extension use only Dreamweaver extension
rendering (and not the previous rendering engine) by inserting the following line immediately
before the Tag comment, as shown in the following example:
<!--DOCTYPE HTML SYSTEM “-//Macromedia//DWEtension layout-engine 5.0//pi”-->
The BODY section of a Property inspector file contains an HTML form. Instead of displaying the
form contents in a dialog box, however, Dreamweaver uses the form to define the input areas and
layout of the inspector.
canInspectSelection()
Description
Determines whether the Property inspector is appropriate for the current selection.
Arguments
None.
Use dom.getSelectedNode() to get the current selection as a JavaScript object (for more
information about dom.getSelectedNode(), see the Dreamweaver API Reference).
Returns
Dreamweaver expects a Boolean value: true if the inspector can inspect the current selection;
false otherwise.
Example
The following instance of the canInspectSelection() function returns a true value if the
selection contains the CLASSID attribute, and the value of that attribute is "clsid:D27CDB6E-
AE6D-11cf-96B8-444553540000" (the class ID for Flash Player):
function canInspectSelection(){
var theDOM = dw.getDocumentDOM();
var theObj = theDOM.getSelectedNode();
return (theObj.nodeType == Node.ELEMENT_NODE && ¬
theObj.hasAttribute("classid") && ¬
theObj.getAttribute("classid").toLowerCase()== ¬
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
}
displayHelp()
Description
If this function is defined, a question mark (?) icon appears in the upper-right corner of the
Property inspector. This function is called when the user clicks the icon.
Arguments
None.
Returns
The following example of the displayHelp() function opens a file in a browser window. The file
explains the fields of the Property inspector.
function displayHelp(){
dw.browseDocument(‘http://www.hooha.com/dw/inspectors/inspHelp.html’);
}
inspectSelection()
Description
Refreshes the contents of the text fields based on the attributes of the current selection.
Arguments
maxOrMin
• The maxOrMin argument is either max or min, depending on whether the Property inspector is
in its expanded or contracted state.
Returns
The following example of the inspectSelection() function gets the value of the CONTENT
attribute and uses it to populate a form field called keywords:
function inspectSelection(){
var dom = dreamweaver.getDocumentDOM();
var theObj = dom.getSelectedNode();
document.forms[0].keywords.value = ¬
theObj.getAttribute("content");
}
function canInspectSelection(){
return true;
}
// Get the value of the TYPE attribute on the INTJ tag var
// theType = theObj.getAttribute('type');
// Initialize a variable called typeIndex to -1. This will be
// used to store the menu index that corresponds to
// the value of the TYPE attribute
var typeIndex = -1;
function setInterjectionTag(){
// Get the DOM of the current document
var theDOM = dw.getDocumentDOM();
// Get the selected node
var theObj = theDOM.getSelectedNode();
</SCRIPT>
</HEAD>
<BODY>
<SPAN ID="image" STYLE="position:absolute; width:23px; ¬
height:17px; z-index:16; left: 3px; top: 2px">
<IMG SRC="interjection.gif" WIDTH="36" HEIGHT="36" ¬
</BODY>
</HTML>
You can create any kind of floating panel or inspector without the size and layout limitations of
Property inspectors.
Although a custom Property inspector should be your first choice for setting the properties of the
current selection, custom floating panels offer more room and flexibility for displaying
information about the entire document or multiple selections.
Custom floating panel files are HTML files that reside in the Configuration/Floaters folder inside
the Macromedia Dreamweaver MX 2004 application folder. The BODY section of a floating panel
file contains an HTML form; event handlers that are attached to form elements can call
JavaScript code that performs arbitrary edits to the current document.
Dreamweaver has several built-in floating panels that are accessible from the Window menu.
(These built-in panels are part of the core Dreamweaver code and do not have corresponding
floating panel files for them in the Configuration/Floaters folder.)
You can create custom panels and add them to the Window menu. For more information on
adding items to the menu system, see Chapter 8, “Menus and Menu Commands,” on page 145.
223
When one of the files inside the Configuration folder calls the
dw.getFloaterVisibility(floaterName), dw.setFloaterVisibility(floaterName), or
dw.toggleFloater(floaterName) functions, the following events occur:
1 If floaterName is not one of the reserved floating panel names, Dreamweaver searches the
Configuration/Floaters folder for a file called floaterName.htm. (For a complete list of reserved
floating panel names, see the dreamweaver.getFloaterVisibility() function in the
Dreamweaver API Reference. If floaterName.htm is not found, Dreamweaver searches for
floaterName.html. If no file is found, nothing happens.
2 If the floating panel file is being loaded for the first time, the initialPosition() function
is called, if it is defined, to determine the floating panel’s default position on the screen, and
the initialTabs() function is called, if it is defined, to determine the floating panel’s default
tab grouping.
3 The selectionChanged() and documentEdited() functions are called on the assumption that
changes probably occurred while the floating panel was hidden.
4 When the floating panel is visible, the following actions occur:
■ When the selection changes, the selectionChanged() function is called, if it is defined.
■ When the user makes changes to the document, the documentEdited() function is called,
if it is defined.
■ Event handlers that are attached to the fields in the floating panel interface execute as the
user encounters them. (For example, a button with an onClick event handler that executes
dw.getDocumentDOM().body.innerHTML='' removes everything between the opening and
closing BODY tags in the document when it is clicked.)
5 When the user quits Dreamweaver, the current visibility, position, and tab grouping of the
floating panel are saved. The next time Dreamweaver starts up, it loads the floating panel files
for any floating panels that were visible at the last shutdown and displays the floating panels in
their last position and tab grouping.
displayHelp()
Description
If this function is defined, a Help button appears below the OK and Cancel buttons in your
dialog box. This function is called when the user clicks the Help button.
Arguments
None.
Returns
documentEdited()
Description
This function is called when the floating panel becomes visible and after the current series of edits
is complete; that is, multiple edits might occur before this function is called. This function should
be defined only if the floating panel must track edits to the document.
Note: Define the documentEdited() function only if you require it because its existence
impacts performance.
Arguments
None.
Returns
The following example of the documentEdited() function scans the document for layers and
updates a text field that displays the number of layers in the document:
function documentEdited(){
/* create a list of all the layers in the document */
var theDOM = dw.getDocumentDOM();
var layersInDoc = theDOM.getElementsByTagName("layer");
var layerCount = layersInDoc.length;
getDockingSide()
Availability
Dreamweaver MX.
Description
Specifies the locations at which a floating panel can dock. The function returns a string that
contains some combination of the words "left", "right", "top", and "bottom". If the label is in
the string, you can dock a floating panel to that side. If the function is missing, you cannot dock
a floating panel to any side.
You can use this function to prevent certain panels from docking on a certain side of the
Dreamweaver workspace or to each other.
None.
Returns
Dreamweaver expects a string containing the words "left", "right", "top", and "bottom", or a
combination of them, that specifies where Dreamweaver can dock the floating panel.
Example
getDockingSide()
{
return dock_side = “left top”;
}
initialPosition()
Description
Determines the initial position of the floating panel the first time it is called. If this function is
not defined, the default position is the center of the screen.
Arguments
platform
• The platform argument has a value of either "Mac" or "Win", depending on the
user’s platform.
Returns
The following example of the initialPosition() function specifies that the first time the
floating panel appears, it should be 420 pixels from the left and 20 pixels from the top in
Windows, and 390 pixels from the left side of the screen and 20 pixels from the top of the screen
on the Macintosh:
function initialPosition(platform){
var initPos = "420,20";
if (platform == "macintosh"){
initPos = "390,20";
}
return initPos;
}
initialTabs()
Description
Determines which other floating panels are tabbed together the first time that this floating panel
appears. If any listed floating panel has appeared previously, it is not included in the tab group. To
ensure that two custom floating panels are tabbed together, each panel should reference the other
with the initialTabs() function.
Arguments
None.
The following example of the initialTabs() function specifies that the first time the floating
panel appears, it should be tabbed with the scriptEditor floating panel:
function initialTabs(){
return "scriptEditor";
}
isATarget()
Availability
Specifies whether other panels can dock to this floating panel. If the isATarget() function is not
specified, Dreamweaver prevents other panels from docking to this one. Dreamweaver calls this
function when the user tries to combine this panel with others.
Arguments
None.
Returns
Dreamweaver expects a Boolean value: true if other floating panels can dock to this one; false
otherwise.
Example
IsATarget()
{
return true;
}
isAvailableInCodeView()
Description
Determines whether the floating panel should be enabled when Code view is selected. If this
function is not defined, the floating panel is disabled in the Code view.
Arguments
None.
Returns
Dreamweaver expects a Boolean value: true if the floating panel should be enabled in Code view;
false otherwise.
Dreamweaver 4.
Description
Determines whether a user can resize a floating panel. If the function is not defined or returns a
true value, the user can resize the floating panel. If the function returns a false value, the user
cannot resize the floating panel.
Arguments
None.
Returns
Dreamweaver expects a Boolean value: true if the user can resize the floating panel;
false otherwise.
Example
The following example prevents the user from resizing the floating panel:
function isResizable()
{
return false;
}
selectionChanged()
Description
Called when the floating panel becomes visible and when the selection changes (when focus
switches to a new document or when the insertion pointer moves to a new location in the current
document). This function should be defined only if the floating panel must track the selection.
Note: Define selectionChanged() only if you absolutely require it because its existence impacts
performance.
Arguments
None.
Returns
The following example of selectionChanged() shows a different layer in the floating panel,
depending on whether the selection is a script marker. If the selection is a script marker,
Dreamweaver makes the script layer visible. Otherwise, Dreamweaver makes the blank
layer visible.
function selectionChanged(){
/* get the selected node */
var theDOM = dw.getDocumentDOM();
var theNode = theDOM.getSelectedNode();
About performance
Declaring the selectionChanged() or documentEdited() function in your custom floating
panels can impact Dreamweaver performance adversely. Consider that the documentEdited()
and selectionChanged() functions are called after every keystroke and mouse click when
Dreamweaver is idle for more than one-tenth of a second. It’s important to use different scenarios
to test your floating panel, using large documents (100K or more of HTML) whenever possible,
to test performance impact.
To help avoid performance penalties, the setTimeout() function was implemented as a global
method in Dreamweaver 3. As in the browsers, the setTimeout() function takes two arguments:
the JavaScript to be called and the amount of time in milliseconds to wait before calling it.
The setTimeout() method lets you build pauses into your processing. These pauses let the user
continue interacting with the application. You must build in these pauses explicitly because the
screen freezes while scripts process, which prevents the user from performing further edits. The
pauses also prevent you from updating the interface or the floating panel.
The following example is from a floating panel that displays information about every layer in the
document. It uses the setTimeout() method to pause for a half second after processing
each layer.
/* create a flag that specifies whether an edit is being processed, and set it
to false. */
document.running = false;
</body>
</html>
Both div tags use the style attribute to specify the position (absolute), size (width: 422px
and height:181px), and default visibility setting (visible) of the floating panels. The
blanklayer panel uses the center attribute and a series of break (br) tags to position the text in
the center of the panel. The scriptlayer panel creates a form with a single textarea to display
the selected JavaScript code. The textarea tag also specifies that when an onBlur event occurs,
indicating that the selected code has changed, the updateScript() function is called to write the
changed text back to the document.
Script marker
</script>
</head>
If you select a Script marker in Design view for the current document and then select the Script
Editor menu item, it invokes the Script Editor floating panel and displays the JavaScript code that
underlies the Script marker. If you select the menu item when a Script marker has not been
selected, it displays the blanklayer panel that contains the text (no script selected).
Behaviors let users make their HTML pages interactive. They offer web designers an easy way to
assign actions to page elements by filling in an HTML form.
You should write behavior actions when you want to share functions with users or when you want
to insert the same JavaScript function repeatedly but change the parameters each time.
Note: You cannot use behaviors to insert VBScript functions directly; however, you can add a
VBScript function indirectly by editing the DOM in the applyBehavior() function.
The term behavior refers to the combination of an event (such as onClick, onLoad, or onSubmit)
and an action (such as Check Plugin, Go to URL, Swap Image). The browser determines which
HTML elements accept which events. Files that list events that each browser supports are stored
in the Configuration/Behaviors/Events folder within the Macromedia Dreamweaver MX 2004
application folder.
Actions are the part of a behavior that you can control; when you write a behavior, you’re really
writing an Action file. Actions are HTML files. The BODY section of an Action file generally
contains an HTML form that accepts parameters for the action (for example, parameters that
indicate which layers are to be shown or hidden). The HEAD section of an Action file contains
JavaScript functions that process form input from the BODY content and control the functions,
arguments, and event handlers that are inserted into a user’s document.
Note: For information about server behaviors that provide web application functionality, see “Server
Behaviors” on page 247.
235
How Behaviors work
When a user selects an HTML element in a Dreamweaver document and clicks the Plus (+)
button, the following events occur:
1 Dreamweaver calls the canAcceptBehavior() function in each Action file to see whether this
action is appropriate for the document or the selected element.
If the return value of this function is the value false, Dreamweaver dims the action in the
Actions pop-up menu. (For example, the Control Shockwave action is dimmed when the user’s
document has no SWF files.) If the return value is a list of events, Dreamweaver compares each
event with the valid events for the currently selected HTML element and target browser until
it finds a match. Dreamweaver populates the Events pop-up menu with the matched event
from the canAcceptBehavior() function at the top of the list; if no match exists, the default
event for the HTML element (marked in the Event file with an asterisk [*]) becomes the top
item. The remaining events in the menu are assembled from the Event file.
2 The user selects an action from the Actions pop-up menu.
3 Dreamweaver calls the windowDimensions() function to determine the size of the Parameters
dialog box. If the windowDimensions() function is not defined, the size is
determined automatically.
A dialog box always appears, with OK and Cancel buttons appearing at the right edge,
regardless of the contents of the BODY element.
4 Dreamweaver displays a dialog box that contains the BODY elements of the Action file. If the
Action file’s BODY tag contains an onLoad handler, Dreamweaver executes it.
5 The user fills in the parameters for the action. Dreamweaver executes event handlers that are
associated with the form fields as the user encounters them.
6 The user clicks OK.
7 Dreamweaver calls the behaviorFunction() and applyBehavior() functions in the selected
Action file. These functions return strings that are inserted into the user’s document.
8 If the user later double-clicks the action in the Actions column, Dreamweaver reopens the
Parameters dialog box and executes the onLoad handler. Dreamweaver then calls the
inspectBehavior() function in the selected Action file, which fills in the fields with the data
that the user previously entered.
applyBehavior()
Description
This function inserts into the user’s document an event handler that calls the function that the
behaviorFunction() function inserts. The applyBehavior() function can also perform other
edits on the user’s document, but it must not delete the object to which the behavior is being
applied or the object that receives the action.
Arguments
uniqueName
• The argument is a unique identifier among all instances of all behaviors in the user’s
document. Its format is functionNameInteger, where functionName is the name of the
function that behaviorFunction() inserts. This argument is useful if you insert a tag into the
user’s document and you want to assign a unique value to its NAME attribute.
Returns
Dreamweaver expects a string that contains the function call to be inserted in the user’s
document, usually after accepting parameters from the user. If the applyBehavior() function
determines that the user made an invalid entry, the function can return an error string instead of
the function call. If the string is empty (return "";), Dreamweaver does not report an error; if
the string is not empty and not a function call, Dreamweaver displays a dialog box with the text
Invalid input supplied for this behavior: [the string returned from applyBehavior()]. If the
return value is null (return;), Dreamweaver indicates that an error occurred but gives no
specific information.
Note: Quotation marks ("")within the returned string must be preceded by a backslash (\) to avoid
errors that the JavaScript interpreter reports.
Example
behaviorFunction()
Description
This function inserts one or more functions—surrounded by the following tags, if they don’t yet
exist—into the HEAD section of the user’s document:
<SCRIPT LANGUAGE="JavaScript"></SCRIPT>
Arguments
None.
Returns
Dreamweaver expects either a string that contains the JavaScript functions or a string that
contains the names of the functions to be inserted in the user’s document. This value must be
exactly the same every time (it cannot depend on user input). The functions are inserted only
once, regardless of how many times the action is applied to elements in the document.
Note: Quotation marks ("")within the returned string must be preceded by a backslash (\) escape
character to avoid errors that the JavaScript interpreter reports.
Example
function behaviorFunction(){
return "MM_popupMsg";
}
This function determines whether the action is allowed for the selected HTML element and
specifies the default event that should trigger the action. Can also check for the existence of
certain objects (such as SWF files) in the user’s document and not allow the action if these objects
do not appear.
Arguments
HTMLElement
• The argument is the selected HTML element.
Returns
The following instance of the canAcceptBehavior() function returns a list of preferred events
for the behavior if the document has any named images:
function canAcceptBehavior(){
var theDOM = dreamweaver.getDocumentDOM();
// Get an array of all images in the document
var allImages = theDOM.getElementsByTagName('IMG');
if (allImages.length > 0){
return "onMouseOver, onClick, onMouseDown";
}else{
return false;
}
}
displayHelp()
Description
If this function is defined, a Help button appears below the OK and Cancel buttons in the
Parameters dialog box. This function is called when the user clicks the Help button.
Arguments
None.
Returns
deleteBehavior()
Description
This function undoes any edits that the applyBehavior() function performed.
Note: Dreamweaver automatically deletes the function declaration and the event handler that are
associated with a behavior when the user deletes the behavior in the Behaviors panel. It is necessary
to define the deleteBehavior() function only if the applyBehavior() function performs additional
edits on the user’s document (for example, if it inserts a tag).
Arguments
applyBehaviorString
• This argument is the string that the applyBehavior() function returns.
Returns
identifyBehaviorArguments()
Description
This function identifies arguments from a behavior function call as navigation links, dependent
files, URLs, Netscape Navigator 4.0-style references, or object names so that URLs in behaviors
can update if the user saves the document to another location and so the referenced files can
appear in the site map and be considered dependent files for the purposes of uploading to and
downloading from a server.
Arguments
theFunctionCall
• This argument is the string that the applyBehavior() function returns.
Returns
Dreamweaver expects a string that contains a comma-separated list of the types of arguments in
the function call. The length of the list must equal the number of arguments in the function call.
Argument types must be one of the following types:
• The nav argument type specifies that the argument is a navigational URL, and therefore, it
should appear in the site map.
• The dep argument type specifies that the argument is a dependent file URL, and therefore, it
should be included with all other dependent files when a document that contains this behavior
is downloaded from or uploaded to a server.
This simple example of the identifyBehaviorArguments() function works for the Open
Browser Window behavior action, which returns a function that always has three arguments (the
URL to open, the name of the new window, and the list of window properties):
function identifyBehaviorArguments(fnCallStr) {
return "URL,other,other";
}
A more complex version of the identifyBehaviorArguments() function is necessary for
behavior functions that have a variable number of arguments (such as Show/Hide Layer). For this
example version of the identifyBehaviorArguments() function, there is a minimum number
of arguments, and additional arguments always come in multiples of the minimum number. In
other words, a function with a minimum number of arguments of 4 may have 4, 8, or 12
arguments, but it cannot have 10 arguments:
function identifyBehaviorArguments(fnCallStr) {
var listOfArgTypes;
var itemArray = dreamweaver.getTokens(fnCallStr, '(),');
This function inspects the function call for a previously applied behavior in the user’s document
and sets the values of the options in the Parameters dialog box accordingly. If the
inspectBehavior() function is not defined, the default option values appear.
Note: The inspectBehavior() function must rely solely on information that the applyBehaviorString
argument passes to it. Do not attempt to obtain other information about the user’s document (for
example, using dreamweaver.getDocumentDOM()) within this function.
Arguments
applyBehaviorString
• This argument is the string that the applyBehavior() function returns.
Returns
The following instance of the inspectBehavior() function, taken from the Display Status
Message.htm file, fills in the Message field in the Parameters dialog box with the message that the
user selected when the behavior was originally applied:
function inspectBehavior(msgStr){
var startStr = msgStr.indexOf("'") + 1;
var endStr = msgStr.lastIndexOf("'");
if (startStr > 0 && endStr > startStr) {
document.theForm.message.value = ¬
unescQuotes(msgStr.substring(startStr,endStr));
}
}
Note: For more information about the unescQuotes() function, see the dwscripts.js file in the
Configuration/Shared/Common/Scripts/CMN folder.
windowDimensions()
Description
This function sets specific dimensions for the Parameters dialog box. If this function is not
defined, the window dimensions are computed automatically.
Note: Do not define this function unless you want an Parameters dialog box that is larger than
640 x 480 pixels.
Arguments
platform
• The value of the argument is either "macintosh" or "windows", depending on the user’s
platform.
Returns
The following instance of windowDimensions() sets the dimensions of the Parameters dialog box
to 648 x 520 pixels:
function windowDimensions(){
return "648,520";
}
function canAcceptBehavior(){
return true;
}
Macromedia Dreamweaver MX 2004 provides users with an interface for adding server behaviors
into their documents to perform server-side tasks such as filtering records based on user criteria,
paging through records, linking result lists to details pages, and inserting records into a result set.
If a Dreamweaver user repeatedly inserts the same runtime code into documents, you can create a
new extension to automate updating a document with these frequently used code blocks. For
details about working with the Server Behavior Builder interface to implement a custom server
behavior, see “Adding Custom Server Behaviors” in Getting Started with Dreamweaver. Then, refer
to this chapter for details about working with the supporting server behavior files and the
functions that interact with established server behaviors. For individual function information, see
“Server Behavior functions” and “Extension Data Manager functions” in the Dreamweaver API
Reference. Dreamweaver currently supports server behavior extensions that add runtime code for
the following server models: ASP.Net/C#, ASP.Net/VisualBasic, ASP/JavaScript, ASP/VBScript,
ColdFusion, JSP, and PHP/MySQL.
The following terms are used throughout this chapter:
• Server behavior extension: The server behavior extension is the interface between server-side
code and Dreamweaver. A server behavior extension consists of JavaScript, HTML, and
Extension Data Markup Language (EDML), which is XML that is created specifically for
extension data. Examples of these files reside in your installation folder in the Configuration/
ServerBehaviors folder, arranged according to server model. When you script an extension, use
the dwscripts.applySB() function to instruct Dreamweaver to read the EDML files,
retrieve the components of your extension, and add the appropriate code blocks to the
user’s document.
• Server behavior instance: When Dreamweaver adds code blocks to a user’s document, the
inserted code constitutes an instance of the server behavior. The user can apply most server
behaviors more than once, which results in multiple server behavior instances. Each server
behavior instance is listed in the Server Behaviors panel of the Dreamweaver interface.
• Runtime code: Runtime code is the set of code blocks that are added to a document when a
server behavior is applied. These code blocks usually include some server-side code, such as
ASP script that is enclosed in <% ... %> tags.
• Participants: Your server behavior extension inserts code blocks into the user’s document. A
code block is a single, continuous block of script, such as a server-side tag, an HTML tag, or an
attribute that adds server-side functionality to a web page. An EDML file defines each code
block as a participant. All the participants for a given server behavior comprise one
participant group.
247
Note: For information about participants, participant groups, and how Dreamweaver EDML files are
structured, see “Extension Data Markup Language” on page 248.
Dreamweaver architecture
When you use the Server Behavior Builder to create a Dreamweaver-specific extension,
Dreamweaver creates several files (EDML and HTML script files) that support inserting the
Server Behavior code into a Dreamweaver document (some behaviors also reference JavaScript
files for additional functionality). The architecture simplifies your implementation of the API and
also separates your runtime code from how Dreamweaver deploys it. This chapter discusses ways
of modifying these files.
Group files
Group files contain a list of participants, and participant files have all server-model-specific code
data. Participant files can be used by more than one extension, so several group files can refer to
the same participant file.
The following example shows a high-level view of the Server Behavior Group EDML file. For a
complete list of elements and attributes, see “Group EDML file tags” on page 262.
<group serverBehavior="Go To Detail Page.htm" dataSource="Recordset.htm">
<groupParticipants selectParticipant="goToDetailPage_attr">
<groupParticipant name="moveTo_declareParam" partType="member"/>
<groupParticipant name="moveTo_keepParams" partType="member"/>
<groupParticipant name="goToDetailPage_attr" partType="identifier" />
</groupParticipants>
</group>
In the groupParticipants block tag, each groupParticipant tag indicates the EDML
participant file that contains the code block to use. The value of the name attribute is the
participant file name minus the .edml extension (for example, the moveTo_declareParam
attribute).
Note: If the Server Behaviors panel is not open and visible, select the Window > Server Behaviors
menu option.
1 In the Server Behaviors panel, select the Plus (+) button, and then select the New Server
Behavior menu option.
2 In the New Server Behavior dialog box, select Document Type: ASP JavaScript and Name:
Hello World
(Leave the “Copy existing server behavior” checkbox unchecked.)
3 Click OK.
To define the code to insert:
1 Select the Plus (+) button for Code Blocks to Insert.
2 In the Create a New Code Block dialog box, enter Hello_World_block1 (Dreamweaver might
automatically enter this information for you).
3 Click OK.
4 In the Code Block text field, enter <% Response.Write(“Hello World”) %>.
5 In the Insert Code pop-up menu, select Relative to the Selection so the user can control where
this code goes in the document.
6 In the Relative Position pop-up menu, select After the Selection.
7 Click OK.
In the Server Behaviors panel, you can see that the Plus (+) menu contains the new server
behavior in the pop-up list. Also, in the installation folder for your Dreamweaver files, the
Configuration/ServerBehaviors/ASP_Js folder now contains the following three files:
• The group file: Hello World.edml
• The participant file: Hello World_block1.edml
• A script file: Hello World.htm
Note: If you are working in a multiuser configuration, these files appear in your Application
Data folder.
analyzeServerBehavior()
Availability
Dreamweaver UltraDev 1
Description
Arguments
serverBehavior, [serverBehaviorArray]
• The serverBehavior argument is a JavaScript object that represents the behavior to analyze.
• The [serverBehaviorArray] argument is an array of JavaScript objects that represents all the
server behaviors that are found on a page.
Returns
Dreamweaver UltraDev 1.
Description
Reads values from the form elements in the dialog box and adds the behavior to the user’s
document. Dreamweaver calls this function when the user clicks OK in the Server Behaviors
dialog box. If this function returns successfully, the Server Behaviors dialog box closes. If this
function fails, it displays an error message without closing the Server Behaviors dialog box. This
function can edit a user’s document.
For more information, see “dwscripts.applySB()” on page 259.
Arguments
serverBehavior
• The serverBehavior JavaScript object represents the server behavior; it is necessary to modify
an existing behavior. If this is a new behavior, the argument is null.
Returns
Dreamweaver expects an empty string if successful or an error message if this function fails.
canApplyServerBehavior()
Availability
Dreamweaver UltraDev 1.
Description
Determines whether a behavior can be applied. Dreamweaver calls this function before the Server
Behaviors dialog box appears. If this function returns a true value, the Server Behaviors dialog
box appears. If this function returns a false value, the Server Behaviors dialog box does not
appear and the attempt to add a server behavior stops.
Arguments
serverBehavior
• The serverBehavior JavaScript object represents the behavior; it is necessary to modify an
existing behavior. If this is a new behavior, the argument is null.
Returns
Dreamweaver expects a Boolean value: true if the behavior can be applied; false otherwise.
Dreamweaver UltraDev 1.
Description
Implementing the copyServerBehavior() function is optional. Users can copy instances of the
specified server behavior. In the following example, this function is implemented for recordsets. If
a user selects a recordset in the Server Behaviors panel or the Data Binding panel, using the Copy
command copies the behavior to the Clipboard; using the Cut command cuts the behavior to the
Clipboard. For server behaviors that do not implement this function, the Copy and Cut
commands do nothing. For more information, see “How the Server Behavior API functions are
called” on page 251.
The copyServerBehavior() function should rely only on behavior object properties that can be
converted into strings to exchange information with the pasteServerBehavior() function. The
Clipboard stores only raw text, so participant nodes in the document should be resolved and
the resulting raw text should be saved into a secondary property.
Note: The pasteServerBehavior() function must also be implemented to let the user paste the
behavior into any Dreamweaver document.
Arguments
serverBehavior
• The serverBehavior JavaScript object represents the behavior.
Returns
Dreamweaver expects a Boolean value: true if the behavior copies successfully to the Clipboard;
false otherwise.
deleteServerBehavior()
Availability
Dreamweaver UltraDev 1.
Description
Removes the behavior from the user’s document. It is called when the user clicks the Minus (-)
button on the Server Behaviors panel. It can edit a user’s document.
For more information, see “dwscripts.deleteSB()” on page 259.
Arguments
serverBehavior
• The serverBehavior JavaScript object represents the behavior.
Returns
If this function is defined, a Help button appears below the OK and Cancel buttons in the dialog
box. This function is called when the user clicks the Help button.
Arguments
None.
Returns
findServerBehaviors()
Availability
Dreamweaver UltraDev 1.
Description
Searches the user’s document for instances of itself. For each instance it finds, the
findServerBehaviors() function creates a JavaScript object, and it attaches state information as
JavaScript properties of the object.
The four required properties are incomplete, participants, title, and selectedNode. You
can set additional properties as necessary.
For more information, see dwscripts.findSBs() and dreamweaver.getParticipants() in the
Dreamweaver API Reference.
Arguments
None.
Returns
Dreamweaver expects an array of JavaScript objects; the length of the array is equal to the number
of behavior instances that are found in the page.
Dreamweaver UltraDev 1.
Description
Determines the settings for the Server Behavior dialog box, based on the specified behavior
object. Dreamweaver calls the inspectServerBehavior() function when a user opens a Server
Behavior dialog box. Dreamweaver calls this function only when a user edits an existing behavior.
Arguments
serverBehavior
• The serverBehavior argument is a JavaScript object that represents the behavior. It is the
same object that findServerBehaviors() returns.
Returns
pasteServerBehavior()
Availability
Dreamweaver UltraDev 1.
Description
If this function is implemented, users can paste instances of the specified server behavior using the
pasteServerBehavior() function. When the user pastes the server behavior, Dreamweaver
organizes the contents of the Clipboard and generates a new behavior object. The new object is
identical to the original, except that it lacks pointer properties. Dreamweaver passes the new
behavior object to the pasteServerBehavior() function. The pasteServerBehavior()
function relies on the properties of the behavior object to determine what to add to the user’s
document. The pasteServerBehavior() function then adds the behavior to the user’s
document. After pasteServerBehavior() returns, Dreamweaver calls the
findServerBehaviors() functions to get a new list of all the server behaviors in the user’s
document.
Implementing the pasteServerBehavior() function is optional. For more information, see
“How the Server Behavior API functions are called” on page 251.
Note: If you implement this function, you must also implement the copyServerBehavior() function.
Arguments
behavior
• The behavior JavaScript object represents the behavior.
Returns
Dreamweaver expects a Boolean value: true if the behavior pastes successfully from the
Clipboard; false otherwise.
dwscripts.findSBs()
Availability
Dreamweaver MX (this function replaces the findSBs() function from earlier versions
of Dreamweaver).
Description
Finds all instances of a server behavior and all the participants on the current page. It sets the title,
type, participants array, weights array, types array, selectedNode value, and incomplete flag. This
function also creates a parameter object that holds an array of user-definable properties such as
recordset, name, and column name. You can return this array from the findServerBehaviors()
function.
Arguments
serverBehaviorTitle
• The serverBehaviorTitle argument is an optional title string that is used if no title is
specified in the EDML title, which is useful for localization.
Returns
Dreamweaver expects an array of JavaScript objects where the required properties are defined.
Returns an empty array if no instances of the server behavior appear on the page.
Example
The following example searches for all instances of a particular server behavior in the current
user document:
function findServerBehaviors() {
allMySBs = dwscripts.findSBs();
return allMySBs;
}
Dreamweaver MX (this function replaces the applySB() function from earlier versions
of Dreamweaver).
Description
Inserts or updates runtime code for the server behavior. If the sbObj parameter has a null value,
it inserts new runtime code; otherwise, it updates existing runtime code that is indicated by the
sbObj object. User settings should be set as properties on a JavaScript object and passed in as
paramObj. These settings should match all the parameters that are declared as @@paramName@@ in
the EDML insertion text.
Arguments
paramObj, sbObj
• The paramObj argument is the object that contains the user parameters.
• The sbObj argument is the prior server behavior object if you are updating an existing server
behavior; null otherwise.
Returns
Dreamweaver expects a Boolean value: true if the server behavior is added successfully to the
user’s document; false otherwise.
Example
In the following example, you fill the paramObj object with the user’s input and call the
dwscripts.applySB() function, passing in the input and your server behavior, sbObj:
function applyServerBehaviors(sbObj) {
dwscripts.applySB(paramObj, sbObj);
}
dwscripts.deleteSB()
Availability
Dreamweaver MX (this function replaces the deleteSB() function from earlier versions of
Dreamweaver).
Description
Deletes all the participants of the sbObj server behavior instance. The entire participant is
deleted, unless the EDML file indicates special delete instructions with the delete tag. It
does not delete participants that belong to more than one server behavior instance (reference
count > 1).
The following example deletes all the participants of the sbObj server behavior, except the
participants that are protected by the EDML file’s delete tag.
function deleteServerBehavior(sbObj) {
dwscripts.deleteSB(sbObj);
}
Regular expressions
You must understand regular expressions as they are implemented in JavaScript 1.5. You must also
know when it is appropriate to use them in the server behavior EDML files. For example, regular
expressions cannot be used in quickSearch values, but they are used in the content of the
searchPattern tag to find and extract data.
Regular expressions describe text strings by using characters that are assigned with special
meanings (metacharacters) to represent the text, break it up, and process it according to
predefined rules. Regular expressions are powerful parsing and processing tools because they
provide a generalized way to represent a pattern.
Good reference books on JavaScript 1.5 have a regular expression section or chapter. This section
examines how Dreamweaver server behavior EDML files use regular expressions in order to find
parameters in your runtime code and extract their values. Each time a user edits a server behavior,
prior parameter values need to be extracted from the instances of the runtime code. You use
regular expressions for the extraction process.
You should understand a few metacharacters and metasequences (special character groupings)
that are useful in server behavior EDML files, as described in the following table:
The runtime code for your server behavior resides inside the EDML files. The EDML parser
should not confuse any of your runtime code with EDML markup, so the CDATA tag must wrap
around your runtime code. The CDATA tag represents character data and is any text that is not
EDML markup. When you use the CDATA tag, the EDML parser won’t try to interpret it as
markup, but instead, considers it as a block of plain text. The CDATA-marked blocks begin with
<![CDATA[ and end with ]]>.
If you insert the text Hello, World, it is simple to specify your EDML, as shown in the
following example:
<insertText>Hello, World</insertText>
However, if you insert content that has tags in it, such as <img src='foo.gif'>, it can confuse
the EDML parser. In that case, embed it in the CDATA construct, as shown in the following
example:
<insertText><![CDATA[<img src='foo.gif'>]]></insertText>
<group>
Description
None.
Type
Block tag.
Required
Yes.
<group> attributes
The following items are valid attributes of the group tag.
version
Description
This attribute defines which version of Dreamweaver server behavior processing the current server
behavior targets. For Dreamweaver MX 2004, the version number is 7. If no version is specified,
Dreamweaver assumes version 7. For this release of Dreamweaver, all groups and participants that
the Server Behavior Builder creates have the version attribute set to 7.0. The group version of this
attribute currently has no effect.
Parent
group
Type
Attribute.
No.
serverBehavior
Description
The serverBehavior attribute indicates which server behavior can use the group. When any of
the group’s participant quickSearch strings are found in the document, the server behavior that
is indicated by the serverBehavior attribute has Dreamweaver call the
findServerBehaviors() function.
In some cases, if multiple groups are associated with a single server behavior, the server behavior
must resolve which particular group to use.
Parent
group
Type
Attribute.
Required
No.
Value
The value is the exact name (without a path) of any server behavior HTML file within a
Configuration/ServerBehaviors folder, as shown in the following example:
<group serverBehavior="redirectIfEmpty.htm">
dataSource
Description
This advanced feature supports new data sources that can be added to Dreamweaver.
Multiple versions of a server behavior can differ, depending on which data source you use. For
example, the Repeat Region server behavior is designed for the standard Recordset.htm data
source. If Dreamweaver is extended to support a new type of data source (such as a COM object),
you can set dataSource="COM.htm" in a group file with a different implementation of Repeat
Region. The Repeat Region server behavior then applies the new implementation of Repeat
Region if you select the new data source.
Parent
group
Type
Attribute.
Required
No.
The exact name of a data source file within a Configuration/DataSources folder, as shown in the
following example:
<group serverBehavior="Repeat Region.htm" ¬
dataSource="myCOMdataSource.htm">
This group defines a new implementation of the Repeat Region server behavior to use if you use
the COM data source. In the applyServerBehaviors() function, you can indicate that this
group should be applied by setting the MM_dataSource property on the parameter object, as
shown in the following example:
function applyServerBehavior(ssRec) {
var paramObj = new Object();
paramObj.rs = getComObjectName();
paramObj.MM_dataSource = "myCOMdataSource.htm";
dwscripts.applySB(paramObj, sbObj);
}
subType
Description
Type
Attribute.
Required
No.
Value
The value is a unique string that determines which group to apply, as shown in the following
example:
<group serverBehavior="myServerBehavior.htm" ¬
subType="longVersion">
<title>
Description
This string appears in the Server Behaviors panel for each server behavior instance that is found in
the current document.
Parent
group
Type
Block tag.
Required
No.
Value
The value is a plain text string that can include parameter names to make each instance unique, as
shown in the following example:
<title>Redirect If Empty (@@recordsetName@@)</title>
<groupParticipants>
Description
Type
Block tag.
Required
Yes.
selectParticipant
Description
Indicates which participant should be selected and highlighted in the document when an
instance is selected in the Server Behaviors panel. The server behavior instances that are listed in
this panel are ordered by the selected participant, so set the selectParticipant attribute even if
the participant is not visible.
Parent
groupParticipants
Type
Attribute.
Required
No.
Value
The participantName value is the exact name (without the .edml extension) of a single
participant file that is listed as a group participant, as shown in the following example. See “name”
on page 267.
<groupParticipants selectParticipant="redirectIfEmpty_link">
<groupParticipant>
Description
Type
Tag.
Required
<groupParticipant> attributes
The following items are valid attributes of the groupParticipant tag.
This attribute names a particular participant to be included in the group. The name attribute on
the groupParticipant tag should be the same as the filename of the participant (without the
.edml file extension).
Parent
groupParticipant
Type
Attribute.
Required
Yes.
Value
The value is the exact name (without the .edml extension) of any participant file, as shown in the
following example:
<groupParticipant name="redirectIfEmpty_init">
This example refers to the redirectIfEmpty_init.edml file.
partType
Description
Type
Attribute.
Required
No.
Values
• The identifier value is a participant that identifies the entire group. If this participant is
found in the document, the group is considered to exist whether other group participants are
found. This is the default value if the partType attribute is not specified.
• The member value is a normal member of a group. If it is found by itself, it does not identify a
group. If it is not found in a group, the group is considered incomplete.
• The option value indicates that the participant is optional. If it is not found, the group is still
considered complete and no incomplete flag is set in the Server Behaviors panel.
<participant>
Description
None.
Type
Block tag.
Required
Yes.
<participant> attributes
The following items are valid attributes of the participant tag.
version
Description
This attribute defines which version of Dreamweaver server behavior processing the current server
behavior targets. For Dreamweaver MX 2004, the version number is 7. If no version is specified,
Dreamweaver assumes version 7. For this release of Dreamweaver, all groups and participants that
the Server Behavior Builder creates have the version attribute set to 7.0.
Note: The participant version attribute overrides the group version attribute if they are different. But,
the participant file will use the group version attribute if the participant does not specify one.
For participant files, this attribute determines if code-block merging should occur. For
participants without this attribute (or have it set to 4 or earlier), the inserted code blocks are not
merged with other code blocks on the page. Participants that have this set to version 5 or later are
merged with other code blocks on the page when possible. Please note that code-block merging
occurs only for participants above and below the HTML tag.
Parent
participant
Type
Attribute.
No.
<quickSearch>
Description
This tag is a simple search string that is used for performance reasons. It cannot be a regular
expression. If the string is found in the current document, the rest of the search patterns are called
to locate specific instances. This string can be empty to always use the search patterns.
Parent
participant
Type
Block tag.
Required
No.
Value
The searchString value is a literal string that exists on the page if the participant exists. The
string should be as unique as possible to maximize performance, but the string does not have to
be definitively unique. It is not case-sensitive, but be careful with nonessential spaces that can be
changed by the user, as shown in the following example:
<quickSearch>Response.Redirect</quickSearch>
If the quickSearch tag is empty, it is considered to match, and more precise searches use the
regular expressions that are defined in the searchPattern tags. This is helpful if a simple string
cannot be used to express a reliable search pattern and regular expressions are required.
<insertText>
Description
This tag provides information about what to insert in the document and where to insert it. It
contains the text to insert. Parts of the text that are customized should be indicated by using the
@@parameterName@@ format.
In some cases, such as a translator-only participant, you might not need this tag.
Parent
implementation
Type
Block tag.
Required
No.
The value is the text to insert in the document. If any parts of the text need customizing, they can
be passed in later as parameters. Parameters should be embedded within two at (@@) signs.
Because this text can interfere with the EDML structure, it should use the CDATA construct, as
shown in the following example:
<insertText location="aboveHTML">
<![CDATA[<%= @@recordset@@).cursorType %>]]>
</insertText>
When the text is inserted, the @@recordset@@ parameter is replaced by a recordset name that the
user supplies. For more information on conditional and repeating code blocks, see the “Adding
Custom Server Behaviors” chapter in Getting Started with Dreamweaver.
<insertText> attributes
The following items are valid attributes of the insertText tag.
location
Description
This attribute specifies where the participant text should be inserted. The insert location is related
to the whereToSearch attribute of the searchPatterns tag, so be sure to set both carefully (see
whereToSearch on page 273).
Parent
insertText
Type
Attribute.
Required
Yes.
Values
nodeParamName
Description
This attribute is used only for node-relative insert locations. It indicates the name of the
parameter that passes the node in at insertion time.
Parent
insertText
Type
Attribute.
This attribute is required only if the insert location contains the word node.
Value
The tagtype__Tag value is a user-specified name for the node parameter that passes with the
parameter object to the dwscripts.applySB() function. For example, if you insert some text
into a form, you might use a form__tag parameter. In your server behavior
applyServerBehavior() function, you could use the form__tag parameter to indicate the exact
form to update, as shown in the following example:
function applyServerBehavior(ssRec) {
var paramObj = new Object();
paramObj.rs = getRecordsetName();
paramObj.form__tag = getFormNode();
dwscripts.applySB(paramObj, sbObj);
}
You can indicate the form__tag node parameter in your EDML file, as shown in the
following example:
<insertText location="lastChildOfNode" nodeParamName="form__tag">
<![CDATA[<input type="hidden" name="MY_DATA">]]>
</insertText>
The text is inserted as the lastChildOfNode value, and the specific node passes in using the
form__tag property of the parameter object.
<searchPatterns>
Description
This tag provides information about finding the participant text in the document, and it contains
a list of patterns that are used when searching for a participant. If multiple search patterns are
defined, they must all be found within the text being searched (the search patterns have a logical
AND relationship), unless they are marked as optional using the isOptional flag.
Parent
implementation
Type
Block tag.
Required
No.
whereToSearch
Description
This attribute specifies where to search for the participant text. This attribute is related to the
insert location, so be sure to set each attribute carefully (see “location” on page 270).
Parent
searchPatterns
Type
Attribute.
Required
Yes.
Values
• The directive value searches all server directives (server-specific tags). For ASP and JSP, this
means search all <% ... %> script blocks.
Note: Tag attributes are not searched, even if they contain directives.
• The tag+tagName value searches the contents of a specified tag, as shown in the
following example:
<searchPatterns whereToSearch="tag+FORM">
This example searches only form tags. By default, the entire outerHTML node is searched. For
INPUT tags, specify the type after a slash (/). In the following example, to search all submit
buttons, use the following code:
<searchPatterns whereToSearch="tag+INPUT/SUBMIT">.
• The tag+* value searches the contents of any tag, as shown in the following example:
<searchPatterns whereToSearch="tag+*">
This example searches all tags.
• The comment value searches only within the HTML comments <! ... >, as shown in the
following example:
<searchPatterns whereToSearch="comment">
This example searches tags such as <!-- my comment here -->.
• The text value searches only within raw text sections, as shown in the following example:
<searchPatterns whereToSearch="text">
<searchPattern>XYZ</searchPattern>
</searchPatterns>
This example finds a text node that contains the text XYZ.
This tag is a pattern that identifies participant text and extracts parameter values from it. Each
parameter subexpression must be enclosed in parentheses ().
You can have patterns with no parameters (which are used to identify participant text), patterns
with one parameter, or patterns with many parameters. All non-optional patterns must be found,
and each parameter must be named and found exactly once.
For more information about using the searchPattern tag, see “Finding server behaviors”
on page 286.
Parent
searchPatterns
Type
Block tag.
Required
Yes.
Values
• The searchString value is a simple search string that is case-sensitive. It cannot be used to
extract parameters.
• The /regularExpression/ value is a regular expression search pattern.
• The <empty> value is used if no pattern is given. It is always considered a match, and the entire
value is assigned to the first parameter.
In the following example, to identify the participant text
<%= RS1.Field.Items("author_id") %>, you can define a simple pattern, followed by a
precise pattern that also extracts the two parameter values:
<searchPattern>Field.Items</searchPattern>
<searchPattern paramNames="rs,col">
<![CDATA[
/<%=\s*(\w+)\.Field\.Items\("(\w+)"\)/
]]>
</searchPattern>
This example matches the pattern precisely and assigns the value of the first subexpression
(\w+) to parameter "rs" and the second subexpression (\w+) to parameter "col".
Note: It is important that regular expressions start and end with a slash (/). Otherwise, the
expression is used as a literal string search. Regular expressions can be followed by the regular-
expression modifier "i" to indicate case-insensitivity (as in /pattern/i). For example, VBScript is
not case-sensitive, so it should use /pattern/i. JavaScript is case-sensitive and should use /
pattern/.
<searchPattern> attributes
The following items are valid attributes of the searchPattern tag.
paramNames
Description
This attribute is a comma-separated list of parameter names whose values are being extracted.
These parameters are assigned in the order of the subexpression. You can assign single parameters
or use a comma-separated list to assign multiple parameters. If other parenthetical expressions are
used but do not indicate parameters, extra commas can be used as placeholders in the Parameter
Name list.
The parameter names should match the ones that are specified in the insertion text and the
update parameters.
Parent
searchPattern
Type
Attribute.
Required
Yes.
Values
limitSearch
Description
This attribute limits the search to some part of the whereToSearch tag.
Parent
searchPattern
Type
Attribute.
Required
No.
Values
• The all value (default) searches the entire tag that is specified in the whereToSearch attribute.
• The attribute+attribName value searches only within the value of the specified attribute, as
shown in the following example:
<searchPatterns whereToSearch="tag+FORM">
<searchPattern limitSearch="attribute+ACTION">
/MY_PATTERN/
</searchPattern>
</searchPatterns>
This example indicates that only the value of the ACTION attribute of FORM tags should be
searched. If that attribute is not defined, the tag is ignored.
• The tagOnly value searches only the outer tag and ignores the innerHTML tag. This value is
valid only if whereToSearch is a tag.
• The innerOnly value searches only the innerHTML tag and ignores the outer tag. This value is
valid only if whereToSearch is a tag.
isOptional
Description
This attribute is a flag that indicates that the search pattern is not required to find the participant.
This is useful for complex participants that might have non-critical parameters to extract. You can
create some patterns for distinctly identifying a participant and have some optional patterns for
extracting non-critical parameters.
Parent
searchPattern
Attribute.
Required
No.
Values
true, false
• The value is true if the searchPattern is not necessary to identify the participant.
• The value is false (default) if the searchPattern tag is required.
For example, consider the following simple recordset string:
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = "dsn=andescoffee;";
Recordset1.Source = "SELECT * FROM PressReleases";
Recordset1.CursorType = 3;
Recordset1.Open();
%>
The search patterns must identify the participant and extract several parameters. However,
if a parameter such as cursorType is not found, you should still recognize this pattern as a
recordset. The cursor parameter is optional. In the EDML, the search patterns might look like
the following example:
<searchPattern paramNames="rs">/var (\w+) = Server.CreateObject/
</searchPattern>
<searchPattern paramNames="src">/ActiveConnection = "([^\r\n]*)"/¬
</searchPattern>
<searchPattern paramNames="conn">/Source = "([^\r\n]*)"/¬
</searchPattern>
<searchPattern paramNames="cursor" isOptional="true">¬
/CursorType = (\d+)/
</searchPattern>
The first three patterns are required to identify the recordset. If the last parameter is not found,
the recordset is still identified.
<updatePatterns>
Description
This optional advanced feature lets you update the participant precisely. Without this tag, the
participant is updated automatically by replacing the entire participant text each time. If you
specify an <updatePatterns> tag, it must contain specific patterns to find and replace each
parameter within the participant.
This tag is beneficial if the user edits the participant text. It performs precise updates only to the
parts of the text that need changing.
Parent
implementation
Block tag.
Required
No.
<updatePattern>
Description
This tag is a specific type of regular expression that lets you update participant text precisely.
There should be at least one update pattern definition for every unique parameter that is declared
in the insertion text (of the form @@paramName@@).
Parent
updatePatterns
Type
Block tag.
Required
The value is a regular expression that finds a parameter between two parenthetical subexpressions,
in the form /(pre-pattern)parameter-pattern(post-pattern)/. You need to define at least
one update pattern for each unique @@paramName@@ in the insertion text. The following example
shows how your insertion text might look:
<insertText location="afterSelection">
<![CDATA[<%= @@rs@@.Field.Items("@@col@@") %>]]>
</insertText>
A particular instance of the insertion text on a page might look like the following example:
<%= RS1.Field.Items("author_id") %>
There are two parameters, rs and col. To update this text after you insert it on the page, you
need two update pattern definitions:
<updatePattern paramName="rs" >
/(\b)\w+(\.Field\.Items)/
</updatePattern>
<updatePattern paramName="col">
/(\bItems\(")\w+("\))/
</updatePattern>
The literal parentheses, as well as other special regular expression characters, are escaped by
preceding them with a backslash (\). The middle expression, defined as \w+, is updated with the
latest value that passed in for parameters "rs" and "col", respectively. The values "RS1" and
"author_id" can be precisely updated with new values.
Multiple occurrences of the same pattern can be updated simultaneously by using the regular
expression global flag "g" after the closing slash (such as /pattern/g).
<updatePattern> attributes
The following items are valid attributes of the updatePattern tag.
paramName
Description
This attribute indicates the name of the parameter whose value is used to update the
participant. This parameter should match the ones that are specified in the insertion text and
search parameters.
Parent
updatePattern
Type
Attribute.
Required
Yes.
Values
The value is the exact name of a parameter that is used in the insertion text. In the following
example, if the insertion text contains an @@rs@@ value, you should have a parameter with
that name:
<updatePattern paramName="rs">pattern</updatePattern>
This tag is an optional advanced feature lets you control how to delete a participant. Without this
tag, the participant is deleted by removing it completely but only if no server behaviors refer to it.
By specifying a <delete> tag, you can specify that it should never be deleted or that only portions
should be deleted.
Parent
implementation
Type
Tag.
Required
No.
<delete> attributes
The following items are valid attributes of the delete tag.
deleteType
Description
This attribute is used to indicate the type of delete to perform. It has different meanings,
depending on whether the participant is a directive, a tag, or an attribute. By default, the entire
participant is deleted.
Parent
delete
Type
Attribute.
Required
No.
Values
• The all value (default) deletes the entire directive or tag. For attributes, it deletes the
entire definition.
• The none value is never automatically deleted.
• The tagOnly value removes only the outer tag but leaves the contents of the innerHTML tag
intact. For attributes, it also removes the outer tag if it is a block tag. It is meaningless for
directives.
• The innerOnly value, when applied to tags, removes only the contents (the innerHTML tag).
For attributes, it removes only the value. It is meaningless for directives.
<translator>
Description
This tag provides information for translating a participant so that it can be rendered differently
and have a custom Property inspector.
Parent
implementation
Type
Block tag.
Required
No.
<searchPatterns>
Description
This tag lets Dreamweaver find each specified instance in a document. If multiple search patterns
are defined, they must all be found within the text being searched (the search patterns have a
logical AND relationship), unless they are marked as optional using the isOptional flag.
Parent
translator
Type
Block tag.
Required
Yes.
This tag contains a list of translation instructions where each instruction indicates where to search
for the participant and what to do with the participant.
Parent
translator
Type
Block tag.
Required
No.
<translation>
Description
This tag contains a single translation instruction that includes the location for the participant,
what type of translation to perform, and the content that should replace the participant text.
Parent
translations
Type
Block tag.
Required
No.
<translation> attributes
The following items are valid attributes of the translation tag.
whereToSearch
Description
This attribute specifies where to search for the text, which is related to the insert location, so be
sure to set each location carefully (see “location” on page 270).
Parent
translation
Type
Attribute.
Required
Yes.
This attribute limits the search to some part of the whereToSearch tag.
Parent
translation
Type
Attribute.
Required
No.
translationType
Description
This attribute indicates the type of translation to perform. These types are preset and give the
translation specific functionality. For example, if you specify "dynamic data", any data that is
translated should behave the same as Dreamweaver dynamic data; that is, it should have the
dynamic data placeholder look in the Design view (curly braces ({}) notation with dynamic
background color) and appear in the Server Behaviors panel.
Parent
translation
Type
Attribute.
Required
Yes.
Values
dynamic data, dynamic image, dynamic source, tabbed region start, tabbed region
end, custom
• The dynamic data value indicates that the translated directives look and behave the same as
Dreamweaver dynamic data, as shown in the following example:
<translation whereToSearch="tag+IMAGE"
limitSearch="attribute+SRC"
translationType="dynamic data">
• The dynamic image value indicates that the translated attributes should look and behave the
same as Dreamweaver dynamic images, as shown in the following example:
<translation whereToSearch="IMAGE+SRC"
translationType="dynamic image">
• The dynamic source value indicates that the translated directives should behave the same as
Dreamweaver dynamic sources, as shown in the following example:
<translation whereToSearch="directive"
translationType="dynamic source">
<openTag>
Description
This optional tag can be inserted at the beginning of the translation section. This tag lets certain
other extensions, such as custom Property inspectors, find the translation.
Parent
translation
Type
Block tag.
Required
No.
Values
The tagName value is a valid tag name. It should be unique to prevent conflicts with known tag
types. For example, if you specify <openTag>MM_DYNAMIC_CONTENT</openTag> the dynamic
data is translated to the MM_DYNAMIC_CONTENT tag.
<attributes>
Description
This tag contains a list of attributes to add to the translated tag that is specified by the openTag
tag. Alternatively, if the openTag tag is not defined and the searchPattern tag specifies tag, this
tag contains a list of translated attributes to add to the tag that is found.
Parent
translation
Type
Block tag.
Required
No.
This tag specifies a single attribute (or translated attribute) to add to the translated tag.
Parent
attributes
Type
Block tag.
Required
<display>
Description
This tag is an optional display string that should be inserted in the translation.
Parent
translation
Type
Block tag.
Required
No.
Values
The displayString value is any string comprising text and HTML. It can include parameter
references that are extracted by the parameter patterns. For example,
<display>{@@rs@@.@@col@@}</display> causes the translation to render as
{myRecordset.myCol}.
This optional tag should be inserted at the end of the translated section. This tag enables certain
other extensions, such as custom Property inspectors, to find the translation.
Parent
translation
Type
Block tag.
Required
No.
Values
The tagName value is a valid tag name; it should match a translation openTag tag.
Example
The Macromedia Dreamweaver MX 2004 Data Sources API functions let you add data sources,
which appear in the Plus (+) menu in the Bindings panel (for related information, see the
function dreamweaver.dbi.getDataSources() in the Dreamweaver API Reference).
Data source files are stored in the Configuration/DataSources/ServerModelName folder.
Dreamweaver currently supports the following server models: ASP.Net/C#, ASP.Net/VisualBasic,
ASP/JavaScript, ASP/VBScript, ColdFusion, JSP, and PHP/MySQL. Within each server model
subfolder are HTML and EDML files that are associated with the data sources for that
server model.
293
3 Dreamweaver goes through each file in the appropriate server model folder, calling the
findDynamicSources() function in each file. For each value in the returned array,
Dreamweaver calls the generateDynamicSourceBindings() function in the same file to get a
new list of all the fields in each data source for the user’s document. Those fields are presented
to the user as a tree control in the Dynamic Data or the Dynamic Text dialog box or in the
Bindings panel. The data source tree for an ASP document might appear as shown in the
following example:
Recordset (Recordset1)
ColumnOneInRecordset
ColumnTwoInRecordset
Recordset (Recordset2)
ColumnOfRecordset
Request
NameOfRequestVariable
NameOfAnotherRequestVariable
Session
NameOfSessionVariable
4 If the user double-clicks on a data source name in the Bindings panel to edit the data source,
Dreamweaver calls the editDynamicSource() function to handle the user edits within the tree.
5 If the user clicks the Minus (-) button, Dreamweaver gets the current node selection from the
tree and passes it to the deleteDynamicSource() function, which deletes the code that was
added earlier with the addDynamicSource() function. If it cannot delete the current selection,
the function returns an error message. After the deleteDynamicSource() function returns,
Dreamweaver refreshes the data source tree by calling the findDynamicSources() and the
generateDynamicSourceBindings() functions.
6 If the user selects a data source and clicks OK in the Dynamic Data or the Dynamic Text dialog
box, or clicks Insert or Bind in the Bindings panel, Dreamweaver calls the
generateDynamicDataRef() function. The return value is inserted in the document at the
current insertion point.
7 If the user displays the Dynamic Data or the Dynamic Text dialog box to edit an existing
dynamic data object, the selection in the data source tree needs to be initialized to the dynamic
data object. To initialize the tree control, Dreamweaver goes through each file in the
appropriate server model folder (for example, the Configuration/DataSources/ASP_Js folder),
calling the implementation of the inspectDynamicDataRef() function in each file.
Dreamweaver calls the inspectDynamicDataRef() function to convert the dynamic data
object back from the code in the user’s document to an item in the tree. (This process is the
reverse of what occurs when the generateDynamicDataRef() function is called.) If the
inspectDynamicDataRef() function returns an array that contains two elements,
Dreamweaver shows with a visual cue which item in the tree is bound to the current selection.
8 Every time the user changes the selection, Dreamweaver calls the inspectDynamicDataRef()
function to determine whether the new selection is dynamic text or a tag with a dynamic
attribute. If it is dynamic text, Dreamweaver displays the bindings for the current selection in
the Bindings panel.
9 Using the Dynamic Data or the Dynamic Text dialog box or the Bindings panel, it’s possible
to change the data format for a dynamic text object or a dynamic attribute that the user has
already added to the page. When the format changes, Dreamweaver calls the
generateDynamicDataRef() function to get the string to insert into the user’s document and
passes that string to the formatDynamicDataRef() function (see “formatDynamicDataRef()”
on page 311). The string that the formatDynamicDataRef() function returns is inserted in the
user’s document.
addDynamicSource()
Availability
Dreamweaver UltraDev 1.
Description
Adds a dynamic data source. Because there is one implementation of this function in each data
source file, Dreamweaver calls the appropriate implementation of the addDynamicSource()
function when you select a data source from the Plus (+) menu.
For example, for recordsets or commands, Dreamweaver calls the
dw.serverBehaviorInspector.popupServerBehavior() function, which inserts a new server
behavior into the document. For request, session, and application variables, Dreamweaver
displays an HTML/JavaScript dialog box to collect the name of the variable; the behavior stores
the variable name for future use.
After the addDynamicSource() function returns, Dreamweaver erases the contents of the data
source tree and calls the findDynamicSources() and generateDynamicSourceBindings()
functions to repopulate the data source tree.
Returns
deleteDynamicSource()
Availability
Dreamweaver UltraDev 1.
Description
Dreamweaver calls this function when a user selects a data source in the tree and clicks the Minus
(-) button.
For example, in Dreamweaver, if the selection is a recordset or command, the
deleteDynamicSource() function calls the
dw.serverBehaviorInspector.deleteServerBehavior() function. If the selection is a
request, session, or application variable, the function remembers that the variable was deleted and
does not display it any more. After the deleteDynamicSource() function returns, Dreamweaver
erases the contents of the data source tree and calls the findDynamicSources() and the
generateDynamicSourceBindings() functions to get a new list of all the data sources for the
user’s document.
sourceName, bindingName
• The sourceName argument is the name of the top-level node to which the child node is
associated.
• The bindingName argument is the name of the child node.
Returns
displayHelp()
Description
If this function is defined, a Help button appears below the OK and Cancel buttons in the dialog
box. This function is called when the user clicks the Help button.
Arguments
None.
Returns
editDynamicSource()
Availability
Dreamweaver MX.
Description
This function is called when the user double clicks on a data source name in the Bindings panel to
edit the data source. An extension developer can implement this function to handle user edits
within the tree. Otherwise, the server behavior that matches the data source is automatically
invoked. The extension developer can use this function to override the default implementation of
server behaviors and provide a custom handler.
Arguments
sourceName, bindingName
• The sourceName argument is the name of the top-level node to which the child node is
associated.
• The bindingName argument is the name of the child node.
Dreamweaver expects a Boolean value: true if the function has handled the edit;
false otherwise.
findDynamicSources()
Availability
Dreamweaver UltraDev 1.
Description
Returns the top-level nodes from the data source tree that appears in the Dynamic Data or the
Dynamic Text dialog box or in the Bindings panel. Each data source file has an implementation
of the findDynamicSources() function. When Dreamweaver refreshes the tree, Dreamweaver
reads through all the files in the DataSources folder and calls the findDynamicSources()
function in each file.
Returns
Dreamweaver expects an array of JavaScript objects where each object can have as many as
five attributes, which are described in the following list:
• The title property is the label string that appears to the right of the icon for each parent
node. The title property is always required.
• The imageFile property is the path of a file that contains the icon (a GIF image), which
represents the parent node in the tree control in the Dynamic Data or the Dynamic Text dialog
box or in the Bindings panel. The imageFile property is required.
• The allowDelete property is optional. If this property is set to a value of false, when the
user clicks this node in the Bindings panel, the Minus (-) button is disabled. If the property is
set to the value true, the Minus (-) button is enabled. If the property is not defined, the
default is the value true.
• The dataSource property is the simple name of the file in which the findDynamicSources()
function is defined. For example, the findDynamicSources() function in the Session.htm
file, which is located in the Configuration/DataSources/ASP_Js folder, sets the dataSource
property to session.htm. The dataSource property is required.
• The name property is the name of the server behavior that is associated with the data source, if
one exists. Some data sources, such as recordsets, are associated with server behaviors. When
you create a recordset and name it rsAuthors, the name property must equal rsAuthors. The
name property is always defined, but can be an empty string ("") if no server behavior is
associated with the data source (such as a session variable).
Note: A JavaScript class that defines these properties exists in the DataSourceClass.js file, which is
located in the Configuration/Shared/Common/Scripts folder.
generateDynamicDataRef()
Availability
Dreamweaver UltraDev 1.
Description
sourceName, bindingName
• The sourceName argument is the name of the top-level node that is associated with the
child node.
• The bindingName argument is the name of the child node from which you want to generate a
dynamic data object.
Returns
generateDynamicSourceBindings()
Availability
Dreamweaver UltraDev 1.
Description
Dreamweaver expects an array of JavaScript objects where each object can have as many as
four properties, which are described in the following list:
• The title property is the label string that appears on the right of the icon for each parent
node. The title property is required.
• The allowDelete property is optional. If this property is set to the value false, when the user
clicks this node in the Bindings panel, the Minus (-) button is disabled. If this property is set to
the value true, the Minus (-) button is enabled. If the property is not defined, the default is
the value true.
• The dataSource property is the simple name of the file in which the findDynamicSources()
function is defined. For example, the findDynamicSources() function in the Session.htm
file, which is located in the Configuration/DataSources/ASP_Js folder, sets the dataSource
property to session.htm. This is a required property.
• The name property is the name of the server behavior that is associated with the data source, if
one exists. It is a required property. Some data sources, such as recordsets, are associated with
server behaviors. When you create a recordset and name it rsAuthors, the name property
must equal rsAuthors. Other data sources, such as session variables, do not have a
corresponding server behavior. Their name property must be the empty string ("").
Note: A JavaScript class that defines these properties exists in the DataSourceClass.js file, which is
located in the Configuration/Shared/Common/Scripts folder.
Dreamweaver UltraDev 1.
Description
Determines the corresponding node in the data source tree from a dynamic data object. The
inspectDynamicDataRef() function compares the string that Dreamweaver passes in to the
string that generateDynamicDataRef() returns for each node in the tree. If a match is found,
the inspectDynamicDataRef() function indicates which node in the tree matches the passed-in
string. The function identifies the node by using an array that contains two elements. The first
element is the name of the parent node, and the second element is the name of the child node. If
no match is found, the inspectDynamicDataRef() function returns an empty array.
Each implementation of the inspectDynamicDataRef() function checks only for matches of its
own object type. For example, the recordset implementation of the inspectDynamicDataRef()
function finds a match only if the passed-in string matches a recordset node in the tree.
Arguments
string
• The string argument is the dynamic data object.
Returns
Dreamweaver expects an array of two elements (parent name and child name) for the matched
node; it returns a null value if no matches are found.
function findDynamicSources()
{
var retList = new Array();
if (siteURL.length)
{
var bindingsArray = dwscripts.getListValuesFromNote(siteURL,
"MyDatasource");
if (bindingsArray.length > 0)
{
return retList;
}
function generateDynamicSourceBindings(sourceName)
{
var retVal = new Array();
if (siteURL.length)
{
var bindingsArray = dwscripts.getListValuesFromNote(siteURL, sourceName);
retVal = getDataSourceBindingList(bindingsArray,
DATASOURCELEAF_FILENAME,
true,
"MyDatasource.htm");
}
return retVal;
}
// We need to strip the cfoutput tags if we are inserting into a CFOUTPUT tag
// or binding to the attributes of a ColdFusion tag. So, we use the
// dwscripts.canStripCfOutputTags() function from dwscriptsServer.js
if (dwscripts.canStripCfOutputTags(dropObject, true))
{
retStr = dwscripts.stripCFOutputTags(retStr, true);
}
return retStr;
}
function inspectDynamicDataRef(expression)
{
var retArray = new Array();
if(expression.length)
{
var params = extPart.findInString("MyDatasource_DataRef", expression);
if (params)
return retArray;
}
if (siteURL.length)
{
//For localized object name
if (sourceName != "MyDatasource")
{
sourceName = "MyDatasource";
}
function commandButtons(){
return new Array(MM.BTN_OK,"okClicked()",MM.BTN_Cancel,"window.close()");
}
function okClicked(){
var nameObj = document.forms[0].theName;
if (nameObj.value) {
if (IsValidVarName(nameObj.value)) {
MM.MyDatasourceContents = nameObj.value;
MM.retVal = "OK";
window.close();
} else {
alert(nameObj.value + " " + MM.MSG_InvalidParamName);
}
} else {
alert(MM.MSG_NoName);
}
}
Save this JavaScript file in the Configuration/Commands folder as MyDatasource_Variable.js.
2 Click the MyDatasource data source option, and the MyDatasource Variable dialog box you
created appears:
Chapter 16, “Data Sources,” on page 293, discusses how Macromedia Dreamweaver MX 2004
inserts dynamic data into a user’s document by adding a server expression at the appropriate
location. When a visitor requests the document from the web server, that server expression is
converted to a value from a database, the contents of a request variable, or some other dynamic
value. The Dreamweaver server formats let you format how this dynamic value is presented to
the visitor.
This chapter discusses the API that formats the dynamic data that is returned by the functions
described in “Data Sources”. The functions that are described in both chapters work together to
format dynamic data. If the user selects a format for the dynamic data, Dreamweaver calls the
data source function generateDynamicDataRef(), see “generateDynamicDataRef()”
on page 297, to get the string to insert into the user’s document. Before inserting the string into
the user’s document, Dreamweaver passes that string to the formatDynamicDataRef() function,
which is described in this chapter. The string that the formatDynamicDataRef() function
returns is the formatted dynamic data that is finally inserted in the user’s document.
Dreamweaver users can format data with built-in formats, create new formats that are based on
built-in format types, or create new formats that are based on custom format types.
The user can format dynamic data in several ways. By using the Format menu in the Dynamic
Data or the Dynamic Text dialog box or in the Bindings panel, the user can format the data
before inserting it into an HTML document. If the user wants to create a format, he or she can
select the Edit Format List command from the Format menu and select a format type from the
Plus (+) menu. The Plus (+) menu contains a list of format types. Format types are basic format
categories, such as Currency, DateTime, or AlphaCase. Format types collect all the common
parameters for a category of format, letting you streamline the work to create a new format.
One example might be to create a new currency format. Essentially, all currency formatting
consists of converting a number to a string, inserting commas and decimal points, and inserting a
currency symbol, such as a dollar ($) sign. The Currency format data type collects all the common
parameters and prompts you for the required values.
307
How data formatting works
All format files reside in the Configuration/ServerFormats/currentServerModel folder. Each
subfolder contains one XML file and multiple HTML files.
The Formats.xml file describes all the choices in the Format menu. Dreamweaver automatically
adds the Edit Format List and None options.
The folder also contains one HTML file for each currently installed format type, which includes
AlphaCase, Currency, DateTime, Math, Number, Percent, Simple, and Trim.
applyFormat()
Availability
Dreamweaver UltraDev 1.
Description
This function can edit a user’s document by adding a format function declaration to it. When a
user selects a format from the Format text field in the Dynamic Data or the Dynamic Text dialog
box or in the Bindings panel, Dreamweaver makes two changes to the user’s document: It adds
the appropriate format function before the HTML tag (if it’s not already there), and it changes
the dynamic data object to call the appropriate format function.
Dreamweaver adds the function declaration by calling the applyFormat() JavaScript
function in the data format file. It changes the dynamic data object by calling the
formatDynamicDataRef() function.
The applyFormat() function should use the DOM to add function declarations to the top of the
user’s document. For example, if the user selects Currency - Default, the function adds the
Currency function declaration.
Arguments
format
• The format argument is a JavaScript object that describes the format to apply. The JavaScript
object is the node that corresponds to the format tag in the Formats.xml file. The object has a
JavaScript property for each attribute of the corresponding format tag.
Returns
applyFormatDefinition()
Availability
Dreamweaver UltraDev 1.
Description
Commits the changes to a format that was created using the Edit Format dialog box.
Users can create, edit, or delete formats with the Edit Format List dialog box. This function is
called to commit any modifications that are made to a format. It can also set other, arbitrarily
named properties on the object. Each property is stored as an attribute of the format tag in the
Formats.xml file.
Dreamweaver expects the format object, if the function completes successfully. If an error occurs,
the function returns an error string. If it returns an empty string, the form is closed, but the new
format is not created, which is the same as a Cancel operation.
deleteFormat()
Availability
Dreamweaver UltraDev 1.
Description
Removes the format function declaration from the top of the user’s document.
When the user changes the format of a dynamic data object (in the Dynamic Data or the
Dynamic Text dialog box or in the Bindings panel) or deletes a formatted dynamic data object,
Dreamweaver removes the function declaration from the top of the document and also removes
the function call from the dynamic data object by calling the deleteFormat() function.
Use the DOM with the deleteFormat() function to remove the function declaration from the
top of the current document.
Arguments
format
• The format argument is a JavaScript object that describes the format to remove. The
JavaScript object is the node that corresponds to the format tag in the Formats.xml file.
Returns
formatDynamicDataRef()
Availability
Dreamweaver UltraDev 1.
Description
Adds the format function call to the dynamic data object. When a user selects a format from the
Format text box in the Dynamic Data or the Dynamic Text dialog box or in the Bindings panel,
Dreamweaver makes two changes to the user’s document: It adds the appropriate format function
before the HTML tag (if it’s not already there), and it changes the dynamic data object to call the
appropriate format function.
dynamicDataObject, format
• The dynamicDataObject argument is a string that contains the dynamic data object.
• The format argument is a JavaScript object that describes the format to apply. The JavaScript
object is the node that corresponds to the format tag in the Formats.xml file. The object has a
JavaScript property for each attribute of the corresponding format tag.
Returns
Dreamweaver expects the new value for the dynamic data object.
If an error occurs, the function displays an alert message under certain conditions. If the function
returns an empty string, the Format text box is set to None.
inspectFormatDefinition()
Availability
Dreamweaver UltraDev 1.
Description
Initializes form controls when a user edits a format in the Edit Format List dialog box.
Arguments
format
• The format argument is a JavaScript object that describes the format to apply. The JavaScript
object is the node that corresponds to the format tag in the Formats.xml file. The object has a
JavaScript property for each attribute of the corresponding format tag.
Returns
Programmers use various strategies to encapsulate their work because experience shows that well-
organized programs are easier to maintain, enhance, and reuse. Different technologies offer
programmers different ways to accomplish this encapsulation, and different names describe these
strategies: functions, modules, and others. Macromedia Dreamweaver MX 2004 uses the term
component to refer to some of the more popular and modern encapsulation strategies, including
web services, JavaBeans, and ColdFusion components (CFCs). So, when users build web
applications in Dreamweaver, the Components panel assists them in using available web services,
JavaBeans, and CFCs.
If you have invented (or simply use) a component strategy that is not represented in
Dreamweaver’s current Component panel, you can extend the Component panel’s logic so the
panel can handle new kinds of components. The files you need to alter are discussed in this
chapter. In some cases, you need to write some JavaScript code that calls certain component-
related functions.
Components from recent technologies (such as web services, JavaBeans, or CFCs) can describe
themselves. In other words, a program such as Dreamweaver can ask a component for a list of the
functions it exposes (meaning functions that can be invoked from another program). Depending
on the technology in use, a component can reveal other information about itself. For example, a
web service might describe new data types.
To add a new kind of component to the Dreamweaver Component panel, you need to locate the
available components (in the user’s environment) and request descriptions from each component
(or parse them if they are written using ASCII files).
The precise way that the location of components and how component details are retrieved varies
among technologies. Additionally, it can vary based on the server model (ASP.NET, JSP/J2EE,
ColdFusion, or others). So, the JavaScript you write to extend the Component panel depends on
the component technology you need to add. The functions described here are meant to assist you
in getting information to appear in the Component panel, but you must write much of the logic
for locating components and introspecting them (querying the internal structure of the
component and making its fields, methods, and properties available through Dreamweaver).
Finally, server models such as ASP.NET, JSP/J2EE, or ColdFusion tend to support some, but not
all, component types. For example, ASP.NET supports web services but not JavaBeans.
ColdFusion also supports web services and CFCs. When you add a new component type to the
Component panel, it must be server-model specific.
313
How to customize the Component panel
The Dreamweaver Component panel lets users load and work with components. It lists all the
available component types that are compatible with each enabled server model. For instance,
because JavaBeans can work only on a JavaServer Page (JSP), JavaBeans components appear only
in the JSP server model within the Component panel. Likewise, because CFCs can work only
on a ColdFusion page, they appear only in the ColdFusion server model within the
Component panel.
Extensibility lets you add new component types into the panel. After you add the new
components, they appear in the Components pop-up list. You can also add instructions for
setting up components that appear in the Component panel or in a dialog box (depending on the
extension for which the steps are implemented) as numbered steps. The Setup Steps then display
interactively as users load the new components, with check marks appearing next to any
completed step.
.js The extension file that implements the Component API Required
callback.
.gif The image that appears in the Components pop-up list. Required
Note: Keep the same prefix throughout all the files that correspond to one component so that
each file and its corresponding component can be identified easily.
For example, the following WebServicesClass node has web methods as its children:
this.name = "TrafficLocatorWebService";
this.image = "Components/Common/WebServices/WebServices.gif";
this.hasChildren = true;
this.toolTipText = "TrafficLocatorWebService";
this.isCodeViewDraggable = true;
// the following allows of enabling/disabling of the button that appears
// above the Component Tree
this.allowDelete = true;
this.isDesignViewDraggable = false;
getComponentChildren()
Availability
Dreamweaver MX.
Description
This function returns a list of child ComponentRec objects for the active parent ComponentRec
object. To load the root-level tree items, this function needs to read its metadata from its
persistent store.
Arguments
{parentComponentRec}
• The parentComponentRec argument is the componentRec object of the parent. If it is
omitted, Dreamweaver expects a list of ComponentRec objects for the root node.
getContextMenuId()
Availability
Dreamweaver MX.
Description:
Returns the Context Menu ID for the component type. Every component type can have a context
menu associated with it. The Context Menu pop-up menus are defined in the
ComponentNameMenus.xml file, and they work the same way as the menu.xml file. The menu
string can be static or dynamic. Shortcut keys (accelerator keys) are supported.
Arguments
None.
Returns
The following example sets the menu options for the Component panel for web services
associated with the ASP.NET/C# server model and defines the shortcut keys for that menu:
function getContextMenuId()
{
return "DWWebServicesContext";
}
Where DWWebServicesContext is defined in the file in the Configuration/Components/
ASP.NET_CSharp/WebServices/WebServicesMenus.xml as follows:
<shortcutlist id="DWWebServicesContext">
<shortcut key="Del" domRequired="false"
enabled="(dw.serverComponentsPalette.getSelectedNode() != null &&
(dw.serverComponentsPalette.getSelectedNode().objectType=='Root'))"
command="clickedDelete();" id="DWShortcuts_ServerComponent_Delete" />
</shortcutlist>
Dreamweaver MX.
Description
This function gets the code that is dragged and dropped in Code view from the Component
panel or the code that is cut, copied, or pasted from the Component panel.
Arguments
componentRec
• The componentRec argument is an object.
Returns
The following example identifies the code for a common web service:
function getCodeViewDropCode(componentRec)
{
var codeToDrop="";
if (componentRec)
{
if (componentRec.objectType=="Class")
{
codeToDrop =¬
dw.getExtDataValue("webservices_constructor","insertText");
codeToDrop =¬
codeToDrop.replace(RegExp("@@Id@@","g"),componentRec.name);
codeToDrop =¬
codeToDrop.replace(RegExp("@@Class@@","g"),componentRec.name);
}
else if (componentRec.objectType=="Method")
{
codeToDrop = componentRec.dropCode;
}
if(componentRec.dropCode)
{
codeToDrop = componentRec.dropCode;
}
else
{
codeToDrop = componentRec.name;
}
}
return codeToDrop;
}
Dreamweaver MX.
Description
None.
Returns
An array of n+1 strings, where n is the number of steps, as described in the following list:
• The title that appears above the list of setup steps
• For each step, the text instructions, which can include any HTML markup that is legal inside a
li tag
You can include hypertext links (a tags) in the list of steps by using the following form:
<a href=”#” onMouseDown="handler">Blue Underlined Text</a>
The "handler" value can be replaced by any of the following strings or any JavaScript
expression, such as "dw.browseDocument('http://www.macromedia.com')":
• An "Event:SetCurSite" handler opens a dialog box to set the current site.
• An "Event:CreateSite" handler opens a dialog box to create a new site.
• An "Event:SetDocType" handler opens a dialog box to change the document type of the
user’s document.
• An "Event:CreateConnection" handler opens a dialog box to create a new
database connection.
• An "Event:SetRDSPassword" handler opens a dialog box to set the Remote Development
Service (RDS) user name and password (ColdFusion only).
• An "Event:CreateCFDataSource" handler opens the ColdFusion administrator in a browser.
The following example sets four steps for ColdFusion components, and provides a hypertext link
in the fourth step so the user can enter the RDS user name and password:
function getSetupSteps()
{
var doSDK = false;
dom = dw.getDocumentDOM();
if (dom && dom.serverModel)
{
var aServerModelName = dom.serverModel.getDisplayName();
}
else
{
var aServerModelName = site.getServerDisplayNameForSite();
}
if (aServerModelName.length)
{
if(aServerModelName != "ColdFusion")
{
if(needsSDKInstalled != null)
{
doSDK = needsSDKInstalled();
}
}
}
return someSteps;
}
setupStepsCompleted()
Availability
Dreamweaver MX.
Description
Dreamweaver calls this function before the Components tab appears. Dreamweaver then calls
the getSetupSteps() function if the setupStepsCompleted() function returns zero or a
positive integer.
Arguments
None.
An integer that represents the number of setup steps the user has completed, as described in the
following list:
• A value of either zero or a positive integer indicates the number of completed steps.
• A value of -1 indicates that all the necessary steps are complete, so the instruction list does
not appear.
handleDesignViewDrop()
Availability
Dreamweaver MX.
Description
Handles the drop operation when the user drags a table or view from the Database panel or a
component from the Component panel to the Design view.
Arguments
componentRec
• The componentRec argument is an object that contains the following properties:
■ The name property is the name of the tree node item.
■ The image property is an optional icon for the tree node item. If omitted, Dreamweaver
MX uses a default icon.
■ The hasChildren property is a Boolean value that indicates whether the tree node item is
expandable: if true, Dreamweaver MX displays the Plus (+) and Minus (-) buttons for the
tree node item; if false, the item is not expandable.
■ The toolTipText property is optional tool tip text for the tree node item.
■ The isCodeViewDraggable property is a Boolean value that indicates whether the tree
node item can be dragged and dropped into the Code view.
■ The isDesignViewDraggable property is a Boolean value that indicates whether the tree
node item can be dragged and dropped into the Design view.
Returns
A Boolean value that indicates whether the drop operation was successful: true if successful;
false otherwise.
The following example determines if the component is a table or view, and then returns the
appropriate bHandled value:
function handleDesignViewDrop(componentRec)
{
var bHandled = false;
if (componentRec)
{
if ((componentRec.objectType == "Table")||
(componentRec.objectType == "View"))
{
alert("popup Recordset Server Behavior");
bHandled = true;
}
}
return bHandled;
}
handleDoubleClick()
Availability
Dreamweaver MX.
Description
When the user double-clicks the node in the tree, the event handler is called to allow editing. This
function is optional. The function can return a false value, which indicates that the event
handler is not defined. In this case, double-clicking causes the default behavior, which expands or
collapses the tree nodes.
Arguments
componentRec
• The componentRec argument is an object that contains the following properties:
■ The name property is the name of the tree node item.
■ The image property is an optional icon for the tree node item. If this icon is omitted,
Dreamweaver uses a default icon.
■ The hasChildren property is a Boolean value that indicates whether the tree node item is
expandable: if true, Dreamweaver displays the Plus (+) and Minus (-) buttons for the tree
node item; if false, the item is not expandable.
■ The toolTipText property is an optional tooltip text for the tree node item.
■ The isCodeViewDraggable property is a Boolean value that indicates whether the tree
node item can be dragged and dropped into Code view.
■ The isDesignViewDraggable property is a Boolean value that indicates whether the tree
node item can be dragged and dropped into Design view.
Returns
Nothing.
In the following example, the extension has a chance to handle a double-click on the tree node
item; if it returns the value false, the default behavior is to expand/collapse the nodes.
function handleDoubleClick(componentRec)
{
var selectedObj = dw.serverComponentsPalette.getSelectedNode();
if(dwscripts.IS_WIN)
{
if (selectedObj && selectedObj.wsRec &&
selectedObj.wsRec[ProxyGeneratorNamePropName])
{
if (selectedObj.objectType == "Root")
{
editWebService();
return true;
}
else if (selectedObj.objectType == "MissingProxyGen")
{
displayMissingProxyGenMessage(componentRec);
editWebService();
return true;
}
}
}
return false;
}
toolbarControls()
Availability
Dreamweaver MX.
Description
Every component type returns a list of toolBarButtonRec objects, which represents the toolbar
icons, in left-to-right order. Each toolBarButtonRec object contains the following properties:
Arguments
None.
Returns
dom = dw.getDocumentDOM();
var plusButton = new ToolbarControlRec();
var aServerModelName = null;
if (dom && dom.serverModel)
{
aServerModelName = dom.serverModel.getDisplayName();
}
else
{
//look in the site for potential server model
aServerModelName = site.getServerDisplayNameForSite();
}
if (aServerModelName.length)
{
if(aServerModelName == "ColdFusion")
{
plusButton.image= PLUS_BUTTON_UP;
plusButton.pressedImage= PLUS_BUTTON_DOWN;
plusButton.disabledImage= PLUS_BUTTON_UP;
plusButton.toolStyle= "left";
plusButton.toolTipText= MM.MSG_WebServicesAddToolTipText;
plusButton.enabled= "dwscripts.IS_WIN";
plusButton.command= "invokeWebService()";
}
else
{
plusButton.image= PLUSDROPBUTTONUP;
plusButton.pressedImage= PLUSDROPBUTTONDOWN;
plusButton.disabledImage= PLUSDROPBUTTONUP;
plusButton.toolStyle= "left";
plusButton.toolTipText= MM.MSG_WebServicesAddToolTipText;
plusButton.enabled= "dwscripts.IS_WIN";
plusButton.menuId = "DWWebServicesChoosersContext";
}
return toolBarBtnArray;
Server models are the technologies that run scripts on a server. When users define a new site, they
can identify the server model that they want to use at the site level and at the individual document
level. This server model handles any dynamic elements that the user adds to the document.
Server model configuration files are stored in the Configuration/ServerModels folder. Within that
folder, each server model has its own HTML file that implements a set of functions that the server
model requires.
327
The Server Model API functions
This section describes the functions that configure server models for Dreamweaver.
canRecognizeDocument()
Availability
Dreamweaver MX.
Description
When opening a document (and when more than one server model claims a file extension),
Dreamweaver calls this function for each of the extension-associated server models to see whether
any of the functions can identify whether the document is its file. If more than one server model
claims the file extension, Dreamweaver gives priority to the server model that returns the
highest integer.
Note: All Dreamweaver-defined server models return a value of 1, so third-party server models can
override the file-extension association.
Arguments
dom
• The dom argument is the Macromedia document object, which is returned by the
dreamweaver.getDocumentDOM() function.
Returns
Dreamweaver expects an integer that indicates the priority that you give to the server model for
the file extension. This function should return a value of -1 if the server model does not claim the
file extension; otherwise, this function should return a value greater than zero.
Example
In the following example, if the user opens a JavaScript document for the current server model,
the sample code returns a value of 2. This value lets the current server model take precedence over
the Dreamweaver default server model.
var retVal = -1;
var langRE = /@\s*language\s*=\s*(\"|\')?javascript(\"|\')?/i;
// Search for the string language="javascript"
var oHTML = dom.documentElement.outerHTML;
if (oHTML.search(langRE) > -1)
retVal = 2;
return retVal;
getFileExtensions()
Availability
Returns the document file extensions with which a server model can work. For example, the ASP
server model supports .asp and .htm file extensions. This function returns an array of strings, and
Dreamweaver uses these strings to populate the Default Page Extension list that is found in the
App Server category in the Site Definition dialog box.
Note: The Default Page Extension list exists only in Dreamweaver 4 and earlier. For
Dreamweaver MX, and later, the Site Definition dialog box does not list file extension settings.
Instead, Dreamweaver reads the Extensions.txt file and parses the documenttype element in the
mmDocumentTypes.xml file. (For more information on these two files and the documenttype element,
see “Extensible document types in Dreamweaver” on page 42.)
Arguments
None.
Returns
Dreamweaver expects an array of strings that represent the allowed file extensions.
getLanguageSignatures()
Availability
Dreamweaver MX.
Description
This function returns an object that describes the method and array signatures that the scripting
language uses. The getLanguageSignatures() function helps map generic signature mapping
to language-specific mapping for the following elements:
• The function
• Constructors
• Drop code (return values)
• Arrays
• Exceptions
• Data type mappings for primitive data types
The getLanguageSignatures() function returns a map of these signature declarations.
Extension developers can use this map to generate language-specific code blocks that
Dreamweaver drops on the page (based on the appropriate server model for the page) when the
user drags and drops a Web Services method, for example.
For examples of how to write this function, see the HTML implementation files for the JSP and
the ASP.Net server models. Server model implementation files are located in the Configuration/
ServerModels folder.
Arguments
None.
Returns
Dreamweaver expects an object that defines the scripting language signatures. This object should
map the generic signatures to language-specific ones.
This function returns the default file extension of files that use the current server model. The
serverModel object is set to the server model of the currently selected site if no user document is
currently selected.
Arguments
None.
Returns
getServerInfo()
Availability
Dreamweaver MX.
Description
This function returns a JavaScript object that can be accessed from within the JavaScript code.
You can retrieve this object by calling the dom.serverModel.getServerInfo() JavaScript
function. Furthermore, serverName, serverLanguage, and serverVersion are special
properties, which you can access through the following JavaScript functions:
dom.serverModel.getServerName()
dom.serverModel.getServerLanguage()
dom.serverModel.getServerVersion()
Arguments
None.
Returns
Dreamweaver expects an object that contains the properties of your server model.
Example
var obj = new Object();
obj.serverName = "ASP";
obj.serverLanguage = "JavaScript";
obj.serverVersion = "2.0";
...
return obj;
This function returns the supported scripting languages of a server model with an array of strings.
Dreamweaver uses these strings to populate the Default Scripting Language list that is found in
the App Server category in the Site Definition dialog box.
Note: The Default Scripting Language list exists only in Dreamweaver 4 and earlier. For
Dreamweaver MX and later, the Site Definition dialog box does not list supported scripting
languages, nor does Dreamweaver use the getServerLanguages() function. Dreamweaver does not
use this function because each server model has only one server language in Dreamweaver.
In earlier versions of Dreamweaver, a server model could support multiple scripting languages; for
example, the ASP server model supports JavaScript and VBScript.
If you want a file in the ServerFormats folder to apply only to a specific scripting language, add
the following statement so it is the first line in the HTML file:
<!-- SCRIPTING-LANGUAGE=XXX -->
In this example, XXX represents the scripting language. This statement causes the server behavior
to appear in the Plus (+) menu of the Server Behaviors panel only when the currently selected
scripting language is XXX.
Arguments
None.
Returns
Dreamweaver expects an array of strings that represent the supported scripting languages.
getServerModelExtDataNameUD4()
Availability
Dreamweaver MX.
Description
This function returns the server model implementation name that Dreamweaver should
use when accessing the UltraDev 4 extension data files that reside in the Configurations/
ExtensionData folder.
Arguments
None.
Returns
Dreamweaver MX.
Description
This function returns the script delimiters that the application server uses, and it indicates
whether each delimiter can participate in merging code blocks. You can access this returned value
from JavaScript by calling the dom.serverModel.getDelimiters() function.
Arguments
None.
Returns
Dreamweaver expects an array of objects where each object contains the following three
properties:
• The startPattern property is a regular expression that matches the opening script delimiter
(such as "<%").
• The endPattern property is a regular expression that matches the closing script delimiter
(such as "%>").
• The participateInMerge property is a Boolean value that specifies whether the content
enclosed in the listed delimiters should (true) or should not (false) participate in
block merging.
getServerModelDisplayName()
Availability
Dreamweaver MX.
Description
This function returns the name that should appear in the user interface for this server model. You
can access this value from JavaScript by calling the dom.serverModel.getDisplayName()
function.
Arguments
None.
Returns
Dreamweaver MX.
Description
This function returns the folder name to use for this server model within the Configuration
folder. You can access this value from JavaScript by calling the
dom.serverModel.getFolderName() function.
Arguments
None.
Returns
getServerSupportsCharset()
Availability
Dreamweaver MX.
Description
This function returns a true value if the current server supports the specified character set. From
JavaScript, you can determine whether the server model supports a specific character set by calling
the dom.serverModel.getServerSupportsCharset() function.
Arguments
metaCharSetString
• The metaCharSetString argument is a string that holds the value of the documents
"charset=" attribute.
Returns
This function retrieves the mapping of server technologies to version numbers. This function is
called by the dom.serverModel.getServerVersion() function.
Arguments
None.
Returns
Dreamweaver expects an array of version objects, each with a version name and version value, as
listed in the following examples:
• ASP version 2.0
• ADODB version 2.1
Dreamweaver also calls the translateMarkup() function in all applicable translator files (as
specified in the Translation preferences) whenever the user might add new or changed existing
content that needs translation. Dreamweaver calls the translateMarkup() function when the
user performs one of the following actions:
• Opens a file in Dreamweaver
• Switches back to Design view after making changes in the HTML panel or in Code view
• Changes the properties of an object in the current document
• Inserts an object (using either the Objects panel or the Insert menu)
• Refreshes the current document after making changes to it in another application
• Applies a template to the document
335
• Pastes or drags content into or within the Document window
• Saves changes to a dependent file
• Invokes a command, behavior, server behavior, Property inspector, or other extension that sets
the innerHTML or outerHTML property of any tag object or the data property of any comment
object
• Selects File > Convert > 3.0 Browser Compatible
• Selects Modify > Convert > Convert Tables to Layers
• Selects Modify > Convert > Convert Layers to Tables
• Changes a tag or attribute in the Quick Tag Editor and presses Tab or Enter
getTranslatorInfo()
Description
This function provides information about the translator and the files it can affect.
Arguments
None.
Returns
An array of strings. The elements of the array must appear in the following order:
1 The translatorClass string uniquely identifies the translator. This string must begin with a
letter and can contain only alphanumeric characters, hyphens (-), and underscores (_).
2 The title string describes the translator in no more than 40 characters.
3 The nExtensions string specifies the number of file extensions to follow. If nExtensions is
zero, the translator can run on any file. If nExtensions is zero, nRegExps is the next element
in the array.
4 The extension string specifies a file extension (for example, "htm" or "SHTML") that works
with this translator. This string is not case-sensitive and should not contain a leading period.
The array should contain the same number of extension elements that are specified
in nExtensions.
5 The nRegExps string specifies the number of regular expressions that follow. If nRegExps is
zero, runDefault is the next element in the array.
6 The regExps string specifies a regular expression that you can check. The array should contain
the same number of regExps elements as are specified in nRegExps, and at least one of the
regExps must match a piece of the document’s source code before the translator can act on
a file.
String Definition
"allFiles" Sets the translator to always execute.
"noFiles" Sets the translator to never execute.
"byExtension" Sets the translator to execute for files that have one of the file
extensions that are specified in the extension.
"byExpression" Sets the translator to execute if the document contains a match for one
of the specified regular expressions.
"bystring" Sets the translator to execute if the document contains a match for one
of the specified strings.
Note: If you set runDefault to "byExtension" but do not specify any extensions (see step 4), the
effect is the same as setting "allFiles". If you set runDefault to "byExpression" but do not
specify any expressions (see step 6), the effect is the same as setting "noFiles".
8 The priority string specifies the default priority for running this translator. The priority is a
number between 0 and 100. If you do not specify a priority, the default priority is 100. The
highest priority is 0, and 100 is lowest. When multiple translators apply to a document, this
setting controls the order in which the translators are applied. The highest priority is applied
first. When multiple translators have the same priority, they are applied in alphabetical order by
translatorClass.
Example
transArray[0] = "SSI";
transArray[1] = "Server-Side Includes";
transArray[2] = "4";
transArray[3] = "htm";
transArray[4] = "stm";
transArray[5] = "html";
transArray[6] = "shtml";
transArray[7] = "2";
transArray[8] = "<!--#include file";
transArray[9] = "<!--#include virtual";
transArray[10] = "byExtension";
transArray[11] = "50";
return transArray;
}
• The docName argument is a string that contains the file:// URL for the document to be
translated.
• The siteRoot argument is a string that contains the file:// URL for the root of the site that
contains the document to be translated. If the document is outside a site, this string might be
empty.
• The docContent argument is a string that contains the contents of the document.
Returns
A string that contains the translated document or an empty string if nothing is translated.
Example
liveDataTranslateMarkup()
Availability
Dreamweaver UltraDev 1.
Description
This function translates documents when users are using the Live Data window. When the user
selects the View > Live Data menu item or clicks the Refresh button, Dreamweaver calls the
liveDataTranslateMarkup() function instead of the translateMarkup() function.
• The docName argument is a string that contains the file:// URL for the document to
be translated.
• The siteRoot argument is a string that contains the file:// URL for the root of the site that
contains the document to be translated. If the document is outside a site, this string might be
empty.
• The docContent argument is a string that contains the contents of the document.
Returns
A string that contains the translated document or an empty string if nothing is translated.
Example
The value of the mmTranslatedValue attribute must be a URL-encoded string that contains at
least one valid attribute/value pair. This means that
mmTranslatedValue="src=%22open.jpg%22" is a valid translation for both src="<? if
(dayType == weekday) then open.jpg else closed.jpg" ?> and <? if (dayType ==
weekday) then src="open.jpg" else src="closed.jpg" ?>.
mmTranslatedValue="%22open.jpg%22" is not valid for either example because it contains only
the value, not the attribute.
/*************************************************************
* This translator handles the following statement syntaxes: *
* <# if (condition) then foo else bar #> *
* <# if (condition) then att="foo" else att="bar" #> *
* <# if (condition) then att1="foo" att2="jinkies" *
* att3="jeepers" else att1="bar" att2="zoinks" #> *
* *
* It does not handle statements with no else clause. *
*************************************************************/
var count = 1;
function getTranslatorInfo(){
returnArray = new Array(7);
return returnArray
}
</script>
</head>
<body>
</body>
</html>
The markup appears whether or not a translator is associated with it. The translator runs
whenever the user edits the server markup that appears in the Property inspector.
When server markup controls more than one attribute in a tag, the server markup does not appear
in the Property inspector. However, the lightning bolt icon shows that translated markup exists
for the selected element
Note: The lightning bolt icon does not appear when text or table cells, rows, or columns are selected.
Translation continues if the user edits server markup in the panel, and a translator exists to handle that
type of markup.
The text fields in the Property inspector are editable; users can enter values for attributes that
might be controlled by server markup, which results in duplicate attributes. If both a translated
value and a regular value are set for a particular attribute, Dreamweaver displays the translated
value in the Document window. You must decide whether your translator searches for duplicate
attributes and removes them.
<BR>
/************************************************************************
* The translateMarkup() function performs the actual translation. *
* In this translator, the translateMarkup() function is written *
* entirely in JavaScript (that is, it does not rely on a C library) -- *
* and it's also extremely inefficient. It's a simple example, however, *
* which is good for learning. *
**************************************************************************/
function translateMarkup(docNameStr, siteRootStr, inStr){
var outStr = ""; // The string to be returned after
translation
var start = inStr.indexOf('<kent>'); // The first position of the KENT
tag
//If the document does not contain any content, terminate the translation.
if ( inStr.length <= 0 ){
return "";
}
// Use the string you just created for the next trip through
// the document. This is the most inefficient part of all.
inStr = outStr;
start = inStr.indexOf('<kent>');
}
// When there are no more KENT tags in the document, return outStr.
return outStr;
}
/**************************************************************
* The replaceKentTag() function assembles the HTML that will *
* replace the KENT tag and the special locking tags that will *
* surround the HTML. It calls the getImage() function to *
* determine the SRC of the IMG tag. *
**************************************************************/
function replaceKentTag(){
// The image to display.
var image = getImage();
// The location of the image on the local disk.
var depFiles = dreamweaver.getSiteRoot() + image;
// The IMG tag that will be inserted between the lock tags.
var imgTag = '<IMG SRC="/' + image + '" WIDTH="320" HEIGHT="240"
ALT="Kent">\n';
// 1st part of the opening lock tag. The remainder of the tag is assembled
below.
var start = '<MM:BeginLock translatorClass="DREAMWEAVER_TEAM" type="kent"';
// The closing lock tag.
var end = '<MM:EndLock>';
return replCode;
}
/******************************************************************
* The getImage() function determines which image to display *
* based on the day of the week, the time of day and the *
* user's platform. The day and time are figured based on UTC *
* time (Greenwich Mean Time) minus 8 hours, which gives *
* Pacific Standard Time (PST). No allowance is made for Daylight *
* Savings Time in this routine. *
******************************************************************/
function getImage(){
var today = new Date(); // Today's date & time.
var day = today.getUTCDay(); // Day of the week in the GMT time zone.
// 0=Sunday, 1=Monday, and so on.
var hour = today.getUTCHours(); // The current hour in GMT, based on the
// 24-hour clock.
var SFhour = hour - 8; // The time in San Francisco, based on the
// 24-hour clock.
var platform = navigator.platform; // User's platform. All Windows machines
// are identified by Dreamweaver as "Win32",
// all Macs as "MacPPC".
var imageRef; // The image reference to be returned.
// If SFhour is negative, you have two adjustments to make.
// First, subtract one from the day count because it is already the wee
// hours of the next day in GMT. Second, add SFhour to 24 to
// give a valid hour in the 24-hour clock.
if (SFhour < 0){
day = day - 1;
// The day count back one would make it negative, and it's Saturday,
// so set the count to 6.
if (day < 0){
day = 6;
}
SFhour = SFhour + 24;
}
return imageRef;
}
</script>
</head>
<body>
</body>
</html>
if (theObj.nodeType != Node.ELEMENT_NODE) {
return;
}
document.layers['timelayer'].document.timeForm.timefield.¬
value = timeValue;
}
The C-level extensibility mechanism lets you implement Macromedia Dreamweaver MX 2004
extensibility files using a combination of JavaScript and custom C code. You define functions
using C, bundle them in a dynamic linked library (DLL) or a shared library, save the library in the
Configuration/JSExtensions folder within the Dreamweaver application folder, and then call the
functions from JavaScript using the Dreamweaver JavaScript interpreter.
For example, you might want to define a Dreamweaver object that inserts the contents of a user-
specified file into the current document. Because client-side JavaScript does not provide support
file input/output (I/O), you must write a function in C to provide this functionality.
<BODY>
<FORM>
Enter the name of the file to be inserted:
<INPUT TYPE="file" NAME="myFile">
</FORM>
</BODY>
</HTML>
The readContentsOfFile() function accepts a list of arguments from the user, retrieves the
filename argument, reads the contents of the file, and returns the contents of the file. For more
information about the JavaScript data structures and functions that appear in the
readContentsOfFile() function, see “C-level extensibility and the JavaScript interpreter”
on page 355.
JSBool
353
readContentsOfFile(JSContext *cx, JSObject *obj, unsigned int ¬
argc, jsval *argv, jsval *rval)
{
char *fileName, *fileContents;
JSBool success;
unsigned int length;
/* Use the string (the file name) to open and read a file */
fileContents = exerciseLeftToTheReader(fileName);
Data types
The JavaScript interpreter defines the following data types.
JSBool JS_DefineFunction()
Description
This function registers a C-level function with the JavaScript interpreter in Dreamweaver. After
the JS_DefineFunction() function registers the C-level function that you specify in the call
argument, you can invoke it in a JavaScript script by referring to it with the name that you specify
in the name argument. The name is case-sensitive.
Typically, this function is called from the MM_Init() function, which Dreamweaver calls
during startup.
Arguments
This function extracts a function argument from a jsval structure, converts it to a string, if
possible, and passes the converted value back to the caller.
Note: Do not modify the returned buffer pointer or you might corrupt the data structures of the
JavaScript interpreter. To change the string, you must copy the characters into another buffer and
create a new JavaScript string.
Arguments
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The v argument is the jsval structure from which the string is to be extracted.
• The pLength argument is a pointer to an unsigned integer. This function sets *plength equal
to the length of the string in bytes.
Returns
A pointer that points to a null-terminated string if successful or to a null value on failure. The
calling routine must not free this string when it finishes.
JSBool JS_ValueToInteger()
Description
This function extracts a function argument from a jsval structure, converts it to an integer (if
possible), and passes the converted value back to the caller.
Arguments
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The v argument is the jsval structure from which the integer is to be extracted.
• The lp argument is a pointer to a 4-byte integer. This function stores the converted value
in *lp.
Returns
This function extracts a function argument from a jsval structure, converts it to a double (if
possible), and passes the converted value back to the caller.
Arguments
• The cx argument is the opaque JSContext pointer that passed to the JavaScript function.
• The v argument is the jsval structure from which the double is to be extracted.
• The dp argument is a pointer to an 8-byte double. This function stores the converted value
in *dp.
Returns
JSBool JS_ValueToBoolean()
Description
This function extracts a function argument from a jsval structure, converts it to a Boolean value
(if possible), and passes the converted value back to the caller.
Arguments
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The v argument is the jsval structure from which the Boolean value is to be extracted.
• The bp argument is a pointer to a JSBool Boolean value. This function stores the converted
value in *bp.
Returns
JSBool JS_ValueToObject()
Description
This function extracts a function argument from a jsval structure, converts it to an object (if
possible), and passes the converted value back to the caller. If the object is an array, use
JS_GetArrayLength() and JS_GetElement() to read its contents.
Arguments
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The v argument is the jsval structure from which the object is to be extracted.
• The op argument is a pointer to a JSObject pointer. This function stores the converted value
in *op.
JSBool JS_StringToValue()
Description
This function stores a string return value in a jsval structure. It allocates a new JavaScript string
object.
Arguments
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The bytes argument is the string to be stored in the jsval structure. The string data is copied,
so the caller should free the string when it is not needed. If the string size is not specified (see
the sz argument), the string must be null-terminated.
• The sz argument is the size of the string, in bytes. If sz is 0, the length of the null-terminated
string is computed automatically.
• The vp argument is a pointer to the jsval structure into which the contents of the string
should be copied.
Returns
JSBool JS_DoubleToValue()
Description
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The dv argument is an 8-byte floating-point number.
• The vp argument is a pointer to the jsval structure into which the contents of the double
should be copied.
Returns
A JSVal structure that contains the Boolean value that passes to the function as an argument.
JSVal JS_IntegerToValue()
Description
A JSVal structure that contains the integer that was passed to the function as an argument.
JSVal JS_ObjectToValue()
Description
This function stores an object return value in a JSVal. Use JS_ NewArrayObject() to create an
array object; use JS_SetElement() to define its contents.
Arguments
JSObject *obj
• The obj argument is a pointer to the JSObject object that you want to convert to a JSVal
structure.
Returns
A JSVal structure that contains the object that you passed to the function as an argument.
char *JS_ObjectType()
Description
Given an object reference, the JS_ObjectType() function returns the class name of the object.
For example, if the object is a DOM object, the function returns "Document". If the object is a
node in the document, the function returns "Element". For an array object, the function
returns "Array".
Note: Do not modify the returned buffer pointer or you might corrupt the data structures of the
JavaScript interpreter.
A pointer to a null-terminated string. The caller should not free this string when it finishes.
JSObject *JS_NewArrayObject()
Description
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The length argument is the number of elements that the array can hold.
• The v argument is an optional pointer to the jsvals to be stored in the array. If the return
value is not null, v is an array that contains length elements. If the return value is null,
the initial content of the array object is undefined and can be set using the
JS_SetElement() function.
Returns
long JS_GetArrayLength()
Description
Given a pointer to an array object, this function gets the number of elements in the array.
Arguments
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The obj argument is a pointer to an array object.
Returns
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The obj argument is a pointer to an array object.
• The index argument is an integer index into the array. The first element is index 0, and the
last element is index (length - 1).
• The v argument is a pointer to a jsval where the contents of the jsval structure in the array
should be copied.
Returns
JSBool JS_SetElement()
Description
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The obj argument is a pointer to an array object.
• The index argument is an integer index into the array. The first element is index 0, and the
last element is index (length - 1).
• The v argument is a pointer to a jsval structure whose contents should be copied to the
jsval in the array.
Returns
This function compiles and executes a JavaScript string. If the script generates a return value, it
returns in *rval.
Arguments
JSContext *cx, JSObject *obj, char *script, unsigned int sz, jsval *rval
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The obj argument is a pointer to the object in whose context the script executes. While the
script is running, the this keyword is equal to this object. Usually this is the JSObject pointer
that passes to the JavaScript function.
• The script argument is a string that contains JavaScript code. If the string size is not specified
(see the sz argument), the string must be null-terminated.
• The sz argument is the size of the string, in bytes. If sz is 0, the length of the null-terminated
string is computed automatically.
• The rval argument is a pointer to a single jsval structure. The function’s return value is
stored in *rval.
Returns
JSBool JS_ReportError()
Description
This function describes the reason for a script error. Call this function before returning the value
JS_FALSE for a script error to give the user information about why the script failed (for example,
“wrong number of arguments”).
Arguments
• The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
• The error argument is a string that contains the error message. The string is copied, so the
caller should free the string when it is not needed. If the string size is not specified (see the sz
argument), the string must be null-terminated.
• The sz argument is the size of the string, in bytes. If sz is 0, the length of the null-terminated
string is computed automatically.
Returns
When you delete a file from the Dreamweaver Configuration folder, Dreamweaver adds an entry
to a mask file to indicate which files in the Configuration folder should not appear in the user
interface. A masked file or folder does not appear to exist to Dreamweaver although it might
physically exist in the folder.
For example, if you use the trash can icon in the Snippets panel to delete a Snippets folder called
javascript and a file called onepixelborder.csn, Dreamweaver writes a file in the user
Configuration folder called mm_deleted_files.xml, which looks like the following example:
<?xml version = "1.0" encoding="utf-8" ?>
<deleteditems>
<item name="snippets/javascript/" />
<item name="snippets/html/onepixelborder.csn" />
</deleteditems>
As Dreamweaver populates the Snippets panel, it reads all the files in the user’s Configuration/
Snippets folder and all the files in the Dreamweaver Configuration/Snippets folder, except the
Configuration/Snippets/javascript folder and the Configuration/Snippets/html/
onepixelborder.csn file, and it adds the resulting list of files to the Snippets panel list.
If a C-level extension calls the MM_ConfigFileExists() function for the file:///c|Program Files/
Macromedia/Dreamweaver/Configuration/Snippets/javascript/onepixelborder.csn URL, it
returns a value of false. Likewise, if a JavaScript extension tries to call
dw.getDocumentDom("file:///c|Program Files/Macromedia/Dreamweaver/
Configuration/Snippets/javascript/onepixelborder.csn"), it returns a null value.
You can modify the mm_deleted_files.xml file to prevent Dreamweaver from showing files in the
user interface, such as objects, canned content in the new dialog box, and so on. You can call the
MM_DeleteConfigfile() function to add file paths to the mm_deleted_files.xml file.
JS_Object MM_GetConfigFolderList()
Availability
Dreamweaver MX.
Description
This function gets a list of files, folders, or both for the specified folder. If you specify a
configuration folder, the function gets a list of the folders that exists in both the user
Configuration folder and the Dreamweaver Configuration folder, subject to filtering by the
mm_deleted_files.xml file.
JSObject is an array that contains the list of files or folders in either the user Configuration folder
or the Dreamweaver Configuration folder, subject to filtering by the mm_deleted_files.xml file.
Examples
JSObject *jsobj_array;
jsobj_array = MM_GetConfigFolderList("file:///¬
c|/Program Files/Macromedia/Dreamweaver/Configuration", "directories" );
JSBool MM_ConfigFileExists()
Availability
Dreamweaver MX.
Description
This function checks whether the specified file exists. If it is a file in a configuration folder, the
function searches for the file in the user Configuration folder or the Dreamweaver Configuration
folder. The function also checks whether the filename is listed in the mm_deleted_files.xml file. If
the name is listed in this file, the function returns a false value.
Arguments
char *fileUrl
• The char *fileUrl argument is a pointer to a string that names the desired file, which is
provided in the format of a file:// URL.
Returns
Dreamweaver MX.
Description
This function opens the file and returns an operating system file handle. You can use the
operating system file handle in calls to system file functions. You must close the file handle with a
call to the system _close function.
If the file is a configuration file, it finds the file in either the user Configuration folder or the
Dreamweaver Configuration folder. If you open the Configuration file for writing, the function
creates the file in the user Configuration folder, even if it exists in the Dreamweaver
Configuration folder.
Note: If you want to read the file before writing to it, open the file in "read" mode. When you want to
write to the file, close the read handle and open the file again in "write" or "append" mode.
Arguments
char *fileURL, char *mode
• The char *fileURL argument is a pointer to a string that names the file that you are opening,
which is provided as a file:// URL. If it specifies a path in the Dreamweaver Configuration
folder, the MM_OpenConfigFile() function resolves the path before opening the file.
• The char *mode argument points to a string that specifies how you want to open the file. You
can specify null, "read", "write", or "append" mode. If you specify "write" and the file does
not exist, the MM_OpenconfigFile() function creates it. If you specify "write", the
MM_OpenConfigFile() function opens the file with an exclusive share. If you specify "read",
the MM_OpenConfigFile() function opens the file with a nonexclusive share.
If you open the file in "write" mode, any existing data in the file is truncated before writing
new data. If you open the file in "append" mode, any data you write is appended to the end
of the file.
Returns
An integer that is the operating system file handle for this file. Returns -1 if the file cannot be
found or does not exist.
Example
char *dwConfig = "file:///c|/Program Files/Macromedia/Dreamweaver/
Configuration/Extensions.txt";
int = fileno;
if(MM_ConfigFileExists(dwConfig))
{
fileno = MM_OpenConfigFile(dwConfig, "read");
}
Dreamweaver MX.
Description
This function finds the file and returns the attributes of the file. You can set any of the arguments
except fileURL to null if you do not need the value.
Arguments
char *fileURL, unsigned long *attrs, unsigned long *filesize,
unsigned long *modtime, unsigned long *createtime
• The char *fileURL argument is a pointer to a string that names the file for which you want
the attributes. You must provide this argument as a file:// URL. If fileURL specifies a path in
the Dreamweaver Configuration folder, the MM_GetConfigFileAttributes() function
resolves the path before opening the file.
• The unsigned long *attrs argument is the address of an integer that contains the returned
attribute bits (see JSBool MM_SetConfigFileAttributes() for available attributes).
• The unsigned long *filesize argument is the address of an integer in which the function
returns the file size in bytes.
• The unsigned long *modtime argument is the address of an integer in which the function
returns the time that the file was last modified. The time is given as the operating-system time
value. For more information about the operating-system time value, see
DWfile.getModificationDate() in the Dreamweaver API Reference.
• The unsigned long *createtime argument is the address of an integer in which the
function returns the time that the file was created. The time is given as the operating-system
time value. For more information on the operating system time value, see
DWfile.getCreationDate() in the Dreamweaver API Reference.
Returns
A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. Returns JS_FALSE if the
file does not exist or an error occurs while getting the attributes.
Example
char dwConfig = "file:///c|/Program Files/Macromedia/Dreamweaver/
Configuration/Extensions.txt";
unsigned long attrs;
unsigned long filesize;
unsigned long modtime;
unsigned long createtime;
MM_GetConfigAttributes(dwConfig, &attrs, &filesize, &modtime, &createtime);
Dreamweaver MX.
Description
This function sets the attributes that you specify for the file, if they are different from the
current attributes.
If the specified file URL is in the Dreamweaver Configuration folder, this function first copies the
file to the user Configuration folder before it sets the attributes. If the attributes are the same as
the current file attributes, the file is not copied.
Arguments
char *fileURL, unsigned long attrs
• The char *fileURL argument is a pointer to a string that names the file for which you want
to set the attributes, which is provided as a file:// URL.
• The unsigned long attrs argument specifies the attribute bits to set on the file. You can use
a logical OR on the following constants to set the attributes:
MM_FILEATTR_NORMAL
MM_FILEATTR_RDONLY
MM_FILEATTR_HIDDEN
MM_FILEATTR_SYSTEM
MM_FILEATTR_SUBDIR
Returns
A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. Returns JS_FALSE if the
file does not exist or it is marked for deletion.
Example
char *dwConfig = "file:///c|/Program Files/Macromedia/Dreamweaver/
Configuration/Extensions.txt";
unsigned long attrs;
attrs = (MM_FILEATTR_NORMAL | MM_FILEATTR_RDONLY);
int fileno = 0;
if(MM_SetConfigFileAttrs(dwConfig, attrs))
{
fileno = MM_OpenConfigFile(dwConfig);
}
JSBool MM_CreateConfigFolder()
Availability
Dreamweaver MX.
Description
JSBool MM_RemoveConfigFolder()
Availability
Dreamweaver MX.
Description
This function removes the folder and its files and subfolders. If the folder is in the Dreamweaver
Configuration folder, it marks the folder for deletion in the mm_deleted_files.xml file.
Arguments
char *fileURL
• The char *fileURL argument is a pointer to a string that names the folder to remove, which
is provided as a file:// URL.
Returns
JSBool MM_DeleteConfigFile()
Availability
Dreamweaver MX.
Description
This function deletes the file, if it exists. If the file exists below the Dreamweaver Configuration
folder, the function marks the file for deletion in the mm_deleted_files.xml file.
If the fileURL argument does not specify a folder in the Dreamweaver Configuration folder, the
function deletes the specified file.
PART III
Appendix
Find information about supporting files and reference resources that can aid in developing
Macromedia Dreamweaver MX 2004 extensions.
Appendix A: The Shared Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
APPENDIX A
The Shared Folder
The Shared folder is the central repository for utility functions, classes, and images that are
commonly used by all extensions. Any extension can reference the files in the Shared folder’s
subfolders, and you can add custom common utilities to the ones already provided by
Macromedia Dreamweaver MX 2004. The multiple user Configuration folders installed for users
on Windows XP, Windows 2000, and Macintosh OS X also contain a Shared folder for individual
customizations. For example, when you install an extension from the Macromedia exchange, you
might notice that the new extension adds contents to your user Configuration/Shared folder
rather than the Dreamweaver application Configuration/Shared folder. For more information on
the Dreamweaver Configuration folders on a multiuser computer, see “Multiuser Configuration
folders” on page 25.
In addition to looking at the JavaScript files in the Shared folder, you should also search for
HTML files in the Configuration folder that include these JavaScript files so that you can
investigate how they are used.
Generally, you use the functions and resources in the Common and Macromedia (MM) folders or
add resources to the Common folder for use in new extensions. You should always look in the
Shared/Common/Scripts folder first for utilities and functions. These functions and utilities are
the most current and comprise the formal interface to the Shared folder. Use files in other folders
at your own risk because they might be out of date.
Specifically, the Shared folder contains the following useful folders.
375
The Common folder
The Common folder has shared scripts and classes for use in third-party extensions.
DBTreeControlClass.js Contains functions that build a database tree control. This class is
used to create and interact with a database tree control. To
create a database tree control, such as the one in the advanced
recordset server behaviors, create a special <select> list with
type="mmdatabasetree" in your HTML file. Attach a
CBTreeControl class to the HTML control by passing the
<select> list name to the class constructor. Then use the
DBTreeControl functions to manipulate the control.
dwscripts.js Look in the main file to find useful functions for all Dreamweaver
extensions. It includes functions for working with strings, files,
design notes, and so on.
dwscriptsExtData.js This file is an extension of the dwscripts.js file. This file facilitates
working with server behaviors, particularly with server behavior
EDML files. Used extensively in Dreamweaver’s implementation
of server behaviors.
GridControlClass.js Use this class to create and manipulate an editable grid. You add
a special select list in your HTML, and attach this class to it in
JavaScript to manipulate the grid.
RadioGroupClass.js Contains functions that define and manage a radio button group.
The methods of the RadioGroup object in this file set and get
values and behavior of a radio button group. You attach this class
to radio buttons in your HTML to control their behavior.
SQLStatementClass.js Contains functions that let you create and edit SQL statements
such as SELECT, INSERT, UPDATE, DELETE, and stored procedure
statements.
tagDialogsCmn.js Contains functions that help you develop custom tag dialog
boxes. The methods of the tagDialog object defined in this file
modify attributes and values for a particular tag.
TagEditClass.js Contains functions that edit tags without changing the DOM of
the current page. The methods of the TagEdit object defined in
this file get and set a tag’s value, attributes, and children. This
class is useful for making complex edits because the DOM does
not get stale.
XMLPropSheetClass.js Contains functions that manage the location and values of a XML
property sheet.
The MM folder
The MM folder contains the shared scripts, images, and classes used by the extensions that come
with Dreamweaver, including the scripts for building a navigation bar, specifying preload calls,
and the shortcut key definitions.
FlashObjects.js Contains functions that update a color picker, check for hex color,
check for an absolute link, add an extension to a filename,
generate error messages, set Flash attributes, check a link for
Flash object, and so on.
jumpMenuUI.js Contains functions for use with the Jump Menu object and Jump
Menu behavior. Functions populate menu options, create an
option label, add an option, delete an option, and so on.
navBar.js Contains classes and functions for working with a navigation bar
and navigation bar elements. Includes functions to add, remove,
and manipulate navigation bar elements.
RecordsetDialogClass.js Contains the static class and functions to display the recordset
server behaviors UI. Functions determine which interface, simple
or advanced, to display. Also, houses functionality shared
between the UI implementations and mediates switches between
the UIs.
The Scripts folder also contains two subfolders, Class and CMN.
FileClass.js Contains class that represents a file in the file system. The paths
are represented by URLs for cross-platform compatibility.
Methods include toString(), getName(), getSimpleName(),
getExtension(), getPath(), setPath(), isAbsolute(),
getAbsolutePath(), getParent(), getAbsoluteParent(),
exists(), getAttributes(), canRead(), canWrite(), isFile(),
isFolder(), listFolder(), createFolder(), getContents(),
setContents(), copyTo(), and remove().
PreferencesClass.js Contains an object and methods that contain all the preference
information for a command.
displayHelp.js Contains one function that displays the specified Help document.
handler.js Contains functions that get a function for an event handler, add a
function to an event handler, and delete a function for an
event handler.
menuItem.js Contains functions that add stars or values to a listed menu item,
or removes them.
Other folders
The following list describes other folders of interest in the Shared folder:
• Controls
The Controls folder contains the elements used to build a server behavior. These controls
include interfaces for text and recordset menus.
Note: These controls are used by the Dreamweaver Server Behavior Builder and by many of
Dreamweaver’s server behaviors but some are useful for managing a control in your extension.
• Fireworks
The Fireworks folder has the supporting files for Fireworks integration.
• UltraDev
Dreamweaver maintains this folder primarily for backward compatibility, and it should not be
used for new extensions. Use the Dreamweaver Configuration/Shared/Common folder, where
most of this functionality also exists. See “The Common folder” on page 376.
A attribute translators
action files 235 about 339
addDynamicSource() 295 creating 340
alert() 68 debugging 352
analyzeServerBehavior() 253 sample code 341
APIs, types of attributes
Behaviors 237 arguments 186
C-level extensibility 356 checked 185
Commands 136 colorRect 184
Component panel 316 command 186
data formatting 307 disabledImage 183
Data Sources 295 domRequired 184
Data Translator 335 enabled 185
Floating panel 224 file 184
Menu Commands 156 id 182
Objects 122 image 182
Property inspector 219 label 183
Reports 199 menu_ID 184
Server Behavior 253 overImage 183
Server Formats 310 showIf 182
Server Model 327 toolbar item tags 182
Tag editor 214 tooltip 183
toolbar command 187 update 185
appearance of dialog boxes 32 value 185
applyBehavior() 237 width 184
applyFormat() 310 attributes property 72
applyFormatDefinition() 310 attributes tag 284
applySB() 259
applyServerBehavior() 254 B
applyTag() 216 beginReporting() 199
appName property 74 behavior extensions, definition 22
appVersion property 74 behaviorFunction() 238
arguments behaviors
passed from menuitem 155 API 237
receiveArguments() 159 helper functions 236
arguments attribute 186 inserting multiple functions with 236
array object 68 required functions 237
383
sample code 243 JS_ObjectToValue() 360
user experience 236 JS_ObjectType() 360
Behaviors API JS_ReportError() 363
applyBehavior() 237 JS_SetElement() 362
behaviorFunction() 238 JS_StringToValue() 359
canAcceptBehavior() 239 JS_ValueToBoolean() 358
deleteBehavior() 240 JS_ValueToDouble() 358
displayHelp() 239 JS_ValueToInteger() 357
identifyBehaviorArguments() 240 JS_ValueToObject() 358
inspectBehavior() 242 JS_ValueToString() 357
windowDimensions() 242 MM_ConfigFileExists() 366
Binding inspector 293 MM_GetConfigFileAttributes() 368
block/tag translators MM_GetConfigFolderList() 365
about 339 MM_OpenConfigFile() 367
debugging 352 C functions
sample code 346 calling from JavaScript 371
blockEnd tag, code coloring 86 in the mm_jsapi.h file 355
blockStart attribute C-level extensibility, in translators 335
customText value 98 canAcceptBehavior() 239
description of 97 canAcceptCommand() 156, 187
innerTag value 99 canApplyServerBehavior() 254
innerText value 97 canDrag attribute 117
nameTag value 99 canInsertObject() 122
nameTagScript value 99 canRecognizeDocument() 328
outerTag value 98 category tag 115
blockStart tag, code coloring 86 changing default file type 33
blur() 68 charEnd tag, code coloring 87
body property 71 charEsc tag, code coloring 87
boolean object 68 charStart tag, code coloring 87
brackets tag, code coloring 87 checkbox object 68
browser profiles checkbutton tag 116, 178
changing 29 checked attribute 118, 185
creating and editing 41 childNodes property
css-support tag 108 of comment objects 74
formatting 39 of document objects 71
property tag 108 of tag objects 72
value tag 109 of text objects 73
working with 39 clearInterval() 68
button object 68 clearTimeout() 68
button tag 116, 177 close() 68
closeTag tag 286
C code coloring
C extensibility API about 83
JS_BooleanToValue() 360 blockEnd tag 86
JS_DoubleToValue() 359 blockStart tag 86
JS_ExecuteScript() 363 brackets tag 87
JS_GetArrayLength() 361 charEnd tag 87
JS_GetElement() 362 charEsc tag 87
JS_IntegerToValue() 360 charStart tag 87
JS_NewArrayObject() 361 commentEnd tag 88
384 Index
commentStart tag 88 color button control 63
CSS sample text 105 colorpicker tag 181
cssImport tag 88 colorRect attribute 184
cssMedia tag 88 Colors.xml file 83
cssProperty tag 89 combobox tag 180
cssSelector tag 89 command attribute 119, 186
cssValue tag 89 command extensions, definition 21
defaultAttribute tag 90 commandButtons() 136, 156, 200
defaultTag tag 90 commands
defaultText tag 90 adding Flash SWF files 63
editing schemes 103 adding to menus 136
endOfLineComment tag 91 menu commands 145
entity tag 91 sample code 138
examples 105 toolbar 172
file 83 user experience 135
functionKeyword tag 91 Commands API
idChar1 tag 92 canAcceptCommand() 136
idCharRest tag 92 commandButtons() 136
ignoreCase tag 92 isDomRequired() 137
ignoreMMTParams tag 92 receiveArguments() 137
ignoreTags tag 93 windowDimensions() 138
isLocked tag 93 Commands menu, modifying 154
JavaScript 106 comment object 74
keyword tag 93 commentEnd tag, code coloring 88
keywords tag 94 commentStart tag, code coloring 88
numbers tag 94 component extensions, definition 22
operators tag 94 Component panel
regexp tag 95 files 314
sampleText tag 95 tree control 316
scheme processing 99 Component panel API functions
scheme tag 85 getCodeViewDropCode() 318
searchPattern tag 96 getComponentChildren() 316
stringEnd tag 96 getContextMenuId() 317
stringEsc tag 97 getSetupSteps() 319
stringStart tag 96 handleDoubleClick() 322
style, Colors.xml file 83 setupStepsCompleted() 320
tagGroup tag 97 toolbarControls() 323
Code Hints Configuration folders and extensions 23
codehints tag 79 configureSettings() 201
definition 23, 77 confirm() 68
description tag 80 conventions, in this guide 17
function tag 82 copyServerBehavior() 255
menu tag 80 css-support tag, code validation 108
menugroup tag 79 cssImport tag, code coloring 88
menuitem tag 81 cssMedia tag, code coloring 88
code snippet extensions, definition 22 cssProperty tag, code coloring 89
code validation 107 cssSelector tag, code coloring 89
CodeHints.xml file cssValue tag, code coloring 89
contains 78 custom JavaScript controls 55
description of 77
Index 385
customizing delete tag 280
appearance of dialog boxes 32 deleteBehavior() 240
browser profiles 29 deleteditems tag 31
default documents 32 deleteDynamicSource() 295
definition of 29 deleteFormat() 311
Dreamweaver 13 deleteSB() 259
editing configuration files 29 deleteServerBehavior() 255
in a multiuser environment 29 deleteType attribute 280
Insert bar 29 description tag 80
interpretation of third-party tags 34 dialog boxes, customizing appearance 32
menus 29 disabledImage attribute 183
page designs 32 display tag 285
third-party tags 29 displayHelp()
customText value, blockStart 98 in Behaviors API 239
in Data Sources API 296
D in Floating panel API 224
data formatting 307 in object files 122
data property in Objects API 122
of comment objects 74 in Property inspector API 219
of text objects 73 in Server Behavior API 256
data source extensions, definition 22 docking toolbars 172
data sources 293 DOCTYPE 54
Data Sources API document extensions 49
addDynamicSource() 295 document node 71
deleteDynamicSource() 295 document object
displayHelp() 296 DOM Level 1 properties and methods of 71
editDynamicSource() 296 Netscape DOM properties and methods of 68
findDynamicSources() 297 Document Object Model
generateDynamicDataRef() 297 about 67
generateDynamicSourceBindings() 298 DOM Level 1 specification 68
inspectDynamicDataRef() 299 Dreamweaver 68
Data Translator API document types
getTranslatorInfo() 336 definition 22
liveDataTranslateMarkup() 338 definition file 43, 44
translateMarkup() 338 definition file, rules 51
data translator extensions, definition 22 dynamic templates 48
data translators extensible 42
debugging 352 extensions 49
for attributes 340 localizing 45, 50
for tags or blocks of code 345 opening, procedure for 51
kinds of 339 tags in definition file 45
user experience 335 document, opening 51
database controls 57 documentEdited() 225
database tree controls 58 documentElement property 71
date object 68 DOM. <italic>See Document Object Model.
default documents, customizing 32 domRequired attribute 184
defaultAttribute tag, code coloring 90 Dreamweaver DOM 68
defaultTag tag, code coloring 90 dreamweaver object 74, 75
defaultText tag, code coloring 90 Dreamweaver, customizing or extending 13
definition file, document type 43 dropdown tag 180
386 Index
dwscripts functions version attribute 268
applySB() 259 whereToSearch attribute 282
deleteSB() 259 EDML files
findSBs() 258 about 248
Dynamic Data dialog box 293 editing 260
dynamic menus EDML structure 261
sample code 164 group file tags 262
user experience 155 using regular expressions 260
dynamic templates 48 element node 72
Dynamic Text dialog box 293 enabled attribute 118, 185
endOfLineComment tag, code coloring 91
E endReporting() 200
Edit Format List Plus (+) pop-up menu 309 entity tag, code coloring 91
editcontrol tag 181 errata 16
editDynamicSource() 296 escape() 68
editing 151 event handlers
editing schemes, code coloring 103 in behavior dialog boxes 236
EDML definition 247 in extension files 26
EDML file tags returning a value from 243
attributes 284 events
closeTag 286 in extension files 68
delete 280 role in behaviors 235
deleteType attribute 280 extensible document types 42
display 285 extension APIs, types of 21
group 262 Extension Data Markup Language (EDML) 248
groupParticipant 266 Extension Manager
groupParticipants 265, 266 guidelines 53
insertText 269, 270 working with 28
isOptional attribute 276 extension user interface 53
limitSearch attribute 276, 283 extensions
location attribute 270 color button control for 63
name attribute 267 Dreamweaver 13
nodeParamName attribute 271 enabling features 21
openTag 284 installing 14
paramName attribute 279 Extensions.txt file 49
paramNames attribute 275 external JavaScript files 26
participant 268
partType attribute 267 F
quickSearch 269 file (field) object 68
searchPatterns 272, 273, 281 file attribute 119, 184
selectParticipant attribute 266 file type, changing default 33
subType attribute 264 files
title 265 CodeHints.xml 78
translation 282 insertbar.xml 121
translations 282 menus.xml 146
translationType attribute 283 mm_deleted_files.xml 30
translator 281 MMDocumentTypes.xml 43
updatePattern 278, 279 toolbars.xml 171
updatePatterns 277 XML 68
findDynamicSources() 297
Index 387
findSBs() 258 getServerSupportsCharset() 333
findServerBehaviors() 256 getSetupSteps() 319
Flash SWF files, displaying in Dreamweaver 63 getTranslatedAttribute() 72
Floating panel API getTranslatorInfo() 336
displayHelp() 224 getUpdateFrequency() 191
documentEdited() 225 getVersionArray() 334
getDockingSide() 225 group file tags 262
initialPosition() 226 group files 248
initialTabs() 226 groupParticipant tag 266
isATarget() 227 groupParticipants tag 265
isAvailableInCodeView() 227 groupParticipants tag attributes 266
isResizable() 228
selectionChanged() 228 H
floating panel extensions, definition 22 handleDoubleClick() 322
floating panels hasChildNodes()
performance issues 229 for comment objects 74
sample code 230 for document objects 71
user experience 223 for tag objects 72
focus() 68 for text objects 73
form object 68 hasTranslatedAttributes() 72
formatDynamicDataRef() 311 helper functions, in behaviors 236
formats 307 hidden (field) object 68
FTP mappings, changing 42 hline 217
function object 68 HTML
function tag 82 default formatting, changing 110
functionKeyword tag, code coloring 91 inner/outer properties 72
G I
generateDynamicDataRef() 297 id attribute 117, 182
generateDynamicSourceBindings() 298 idChar1 tag, code coloring 92
getAttribute() 72 idCharRest tag, code coloring 92
getCodeViewDropCode() 318 identifyBehaviorArguments() 240
getComponentChildren() 316 ignoreCase tag, code coloring 92
getContextMenuId() 317 ignoreMMTParams tag, code coloring 92
getCurrentValue() 188 ignoreTags tag, code coloring 93
getDockingSide() 225 image attribute 117, 182
getDynamicContent() 157, 188 image object 68
getElementsByTagName() include/ tag 175
for document objects 71 initialPosition() 226
for tag objects 72 initialTabs() 226
getFileExtensions() 328 innerHTML property 72
getLanguageSignatures() 329 innerTag value, blockStart 99
getMenuID() 190 innerText value, blockStart 97
getServerExtension() 330 Insert bar
getServerInfo() 330 adding objects 121
getServerLanguages() 331 definition file 114
getServerModelDelimiters() 332 modifying 29
getServerModelDisplayName() 332
getServerModelExtDataNameUD4() 331
getServerModelFolderName() 333
388 Index
Insert bar object JS_ValueToInteger() 357
example 126 JS_ValueToObject() 358
files 113 JS_ValueToString() 357
reordering 121 JSBool 355
Insert bar object extensions, definition 21 JSContext 355
insertbar tag 115 JSNative 356
insertbar.xml file 113, 121 JSObject 355
insertObject() 123 jsval 355
insertText tag 269, 270
inspectBehavior() 242 K
inspectDynamicDataRef() 299 keyboard shortcuts, changing 152
inspectFormatDefinition() 312 keyword tag, code coloring 93
inspector extensions, definition 22 keywords tag, code coloring 94
inspectServerBehavior() 257
inspectTag() 214 L
installing an extension 14 label attribute 183
isATarget() 227 language information 74
isAvailableInCodeView() 227 layer object 68
isCommandChecked() 158, 191 limitSearch attribute 276, 283
isDOMRequired() 192 liveDataTranslateMarkup() 338
isDomRequired() 123, 137 localized strings 45
isLocked tag, code coloring 93 location attribute 270
isOptional attribute 276 locked content, inspecting 349
isResizable() 228 *LOCKED* keyword 349
item tag 31
item tags, in toolbars 177 M
item() 68 manipulating tree control content 62
itemref/ tag 176 math object 68
itemtype/ tag 176 menu command extensions, definition 21
menu commands
J about 154
JavaScript sample code 161
controls 55 user experience 155
external files 26 Menu Commands API
URLs 26 canAcceptCommand() 156
JS_BooleanToValue() 360 commandButtons() 156
JS_DefineFunction() 356 getDynamicContent() 157
JS_DoubleToValue() 359 isCommandChecked() 158
JS_ExecuteScript() 363 receiveArguments() 159
JS_GetArrayLength() 361 setMenuText() 159
JS_GetElement() 362 windowDimensions() 160
JS_IntegerToValue() 360 menu folder, placing command file 164
JS_NewArrayObject() 361 menu tag 80, 147
JS_ObjectToValue() 360 MENU-LOCATION 252
JS_ObjectType() 360 menu_ID attribute 184
JS_ReportError() 363 menubar tag 146
JS_SetElement() 362 menubutton tag 116, 179
JS_StringToValue() 359 menugroup tag 79
JS_ValueToBoolean() 358 menuitem tag 81, 147
JS_ValueToDouble() 358
Index 389
menus nodes 68
changing 29, 151 nodeType property
commands 154 of comment objects 74
definition 23 of document objects 71
modifying pop-up and context 153 of tag objects 72
menus.xml file of text objects 73
about 146 number object 68
changing 151 numbers tag, code coloring 94
menu tag 147
menubar tag 146 O
menuitem tag 147 object object 68
separator tag 149 objects
shortcut tag 150 adding Flash SWF files 63
shortcutlist tag 150 adding to Insert bar 121
MM components of 113
TREECOLUMN 61 creating 113
TREENODE 61 how files work 121
MM_ConfigFileExists() 366 Objects API
mm_deleted_files.xml file canInsertObject() 122
about 30 displayHelp() 122
deleteditems tag 31 insertObject() 123
item tag 31 isDomRequired() 123
tag syntax 31 objectTag() 124
MM_GetConfigFileAttributes() 368 windowDimensions() 125
MM_GetConfigFolderList() 365 objectTag() 124
mm_jsapi.h file onBlur 68
including 355 onChange 68
sample 371 onClick 68
MM_OpenConfigFile() 367 onFocus 68
MM_returnValue 243 onLoad 68
MMDocumentTypes.xml file 43 onMouseOver 68
multiuser configuration onResize 68
customizing 29 opening a document 51
deleting configuration files in 30 openTag attribute 284
folders 25 operating system, user’s 75
reinstalling and uninstalling in 32 operators tag, code coloring 94
multiuser platforms, Configuration folder 49 option object 68
outerHTML property 72
N outerTag value, blockStart 98
name attribute 119, 267 overImage attributes 183
nameTag value, blockStart 99
nameTagScript value, blockStart 99 P
navigator object 68 page designs 32
node constants 68 panel extensions, definition 22
Node.COMMENT_NODE 68 paramName attribute 279
Node.DOCUMENT_NODE 68 paramNames attribute 275
Node.ELEMENT_NODE 68 parentNode property
Node.TEXT_NODE 68 of comment objects 74
nodelist object 68 of document objects 71
nodeParamName attribute 271
390 Index
of tag objects 72 processfile() 199
of text objects 73 windowDimensions() 201
parentWindow property 71 reset object 68
participant files 249 resizeTo() 68
participant tag 268
participants 247 S
partType attribute 267 sampleText tag, code coloring 95
password (field) object 68 scheme block delimiter coloring 97
pasteServerBehavior() 257 scheme processing
processFile() 199 code coloring 99
Property inspector API escape characters 101
canInspectSelection() 219 maximum string length 101
displayHelp() 219 precedence 102
inspectSelection() 220 wildcard characters 100
Property inspectors scheme tag, code coloring 85
*LOCKED* keyword 349 SCRIPTING-LANGUAGE statement 331
comment at top of file 217 search pattern resolution 290
custom 217 searchPattern tag, code coloring 96
file structure 217 searchPatterns tag 272, 273, 281
lightning bolt icon 344 select object 68
locked content, for 349 select() 68
overview 217 selection, exact versus within 217
sample code 220 selectionChanged() 228
translated attributes in 344 selectParticipant attribute 266
user experience 218 separator tag 117, 149, 177
property tag, code validation 108 server behavior
deleting 292
Q dwscripts functions 258
quickSearch tag 269, 286 example 249
extension 247
R finding 286
radio object 68 group files 248
radiobutton tag 178 instance 247
receiveArguments() 137, 159, 193 overview 247
regexp object 68 participant files 249
regexp tag, code coloring 95 participants 247
regular expressions in EDML files 260 runtime code 247
reinstalling 32 search pattern resolution 290
removeAttribute() 72 techniques 286
report extensions, definition 21 updating 290
reports Server Behavior API
site 198 analyzeServerBehavior() 253
stand-alone 198 applyServerBehavior() 254
Reports API canApplyServerBehavior() 254
beginReporting() 199 copyServerBehavior() 255
commandButtons() 200 deleteServerBehavior() 255
configureSettings() 201 displayHelp() 256
endReporting() 200 findServerBehaviors() 256
inspectServerBehavior() 257
pasteServerBehavior() 257
Index 391
server behavior extensions, definition 22 T
server format extensions, definition 22 tag attribute 119
Server Formats API Tag Chooser 208
applyFormat() 310 Tag Dialog extensions, definition 22
applyFormatDefinition() 310 Tag editor API
deleteFormat() 311 applyTag() 216
formatDynamicDataRef() 311 inspectTag() 214
inspectFormatDefinition() 312 validateTag() 215
Server Model API Tag editor, creating 214
about 327 tag libraries 204
canRecognizeDocument() 328 tag object 72
getFileExtensions() 328 tagGroup tag, code coloring 97
getLanguageSignatures() 329 tagName property 72
getServerExtension() 330 tagspec tag 35
getServerInfo() 330 target browser, code validation 107
getServerLanguages() 331 text (field) object 68
getServerModelDelimiters() 332 text node 73
getServerModelDisplayName() 332 text objects 73
getServerModelExtDataNameUD4() 331 textarea object 68
getServerModelFolderName() 333 third-party tags
getServerSupportsCharset() 333 avoiding rewriting 38
getVersionArray() 334 changing appearance of 29
server model extensions, definition 22 changing color highlighting 38
server models, definition 327 customizing interpretation of 34
service component, adding 315 tagspec 35
setAttribute() 72 title tag 265
setInterval() 68 toolbar command API
setMenuText() 159 canAcceptCommand() 187
setTimeout() 68, 229 getCurrentValue() 188
setupStepsCompleted() 320 getDynamicContent() 188
share-in-memory 292 getMenuID() 190
shortcut tag 150 getUpdateFrequency() 191
shortcutlist tag 150 isCommandChecked() 191
showIf attribute 118, 182 isDOMRequired() 192
showIf() 193 receiveArguments() 193
shutdown commands 25 showIf() 193
Shutdown folder 25 toolbar extensions, definition 21
site object, properties of 74 toolbar tag 174
site reports 198 toolbarControls() 323
stand-alone reports 198 toolbars
startup commands 25 button tag 177
Startup folder 25 checkbutton tag 178
string object 68 colorpicker tag 181
stringEnd tag, code coloring 96 combobox tag 180
stringEsc tag, code coloring 97 command API 187
stringStart tag, code coloring 96 controls 171
submit object 68 creating 171
subType attribute 264 docking 172
systemScript property 75 dropdown tag 180
editcontrol tag 181
392 Index
file definition 173 V
how commands work 172 validateTag() 215
how toolbars work 171 value attribute 185
include/ tag 175 value tag, code validation 109
item tags 177 variable grid controls 59
itemref/ tag 176 VBScript 235
itemtype/ tag 176 version attribute 268
menubutton tag 179 versioning 74
radiobutton tag 178 vline 217
separator tag 177
simple command file 194 W
tag attributes 182 W3C 68
toolbar tag 173, 174 whereToSearch attribute 282
toolbars.xml file 171 width attribute 184
toolbars.xml file 171, 173 window object 68
tooltip attribute 183 window.close() 68
translated attributes windowDimensions()
finding in tags 72 in behavior actions 242
individual 340 in Commands API 138
inspecting 344 in menu commands 160
multiple 340 in Objects API 125
translated tags, inspecting 349 in Reports API 201
translateMarkup() 338 workspace, Dreamweaver MX 172
translation tag 282
translations tag 282 X
translationType attribute 283 XML
translator tag 281 files 68
translators structure 261
attribute 340 tree view 68
block/ tag 345 XML files
debugging 352 CodeHints.xml 78
tree controls 57, 58, 60 insertbar.xml 121
tree controls, manipulating content 62 menus.xml 146
tree view, XML 68 MMDocumentTypes.xml 43
TREECOLUMN 61 toolbars.xml 171
TREENODE 61 XML tag
codehints 79
U toolbar 173, 174
unescape() 68
uninstalling 32
update attribute 185
updatePattern tag 278, 279
updatePatterns tag 277
URL property 71
Index 393
394 Index