The Server Model API functions

 < Day Day Up > 

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

Dreamweaver UltraDev 1, deprecated in Dreamweaver MX.

Description

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 35.)


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.

getServerExtension()

Availability

Dreamweaver UltraDev 4, deprecated in Dreamweaver MX.

Description

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

Dreamweaver expects a string that represents the supported file extensions.

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; 

getServerLanguages()

Availability

Dreamweaver UltraDev 1, deprecated in Dreamweaver MX.

Description

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 expects a string, such as "ASP/JavaScript".

getServerModelDelimiters()

Availability

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 expects a string, such as "ASP JavaScript".

getServerModelFolderName()

Availability

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

Dreamweaver expects a string, such as "ASP_JS".

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

Dreamweaver expects a Boolean value.

getVersionArray()

Availability

Dreamweaver UltraDev 1, deprecated in Dreamweaver MX.

Description

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

     < Day Day Up > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net