Accessibility
 
Home > Products > UltraDev > Support > Extending Dreamweaver UltraDev
Dreamweaver UltraDev Icon Macromedia Dreamweaver UltraDev Support Center - Extending Dreamweaver UltraDev
2. Create the server behavior file and add a search string

Key Concepts

Keep the search string simple
Ensure you include all the common files that may be needed
Declare the basic server behavior functions

First, create your server behavior HTML file in the folder Configuration/ServerBehaviors/ASP . You may have noticed that all Dreamweaver extensions are split into two files such as Recordset.htm and Recordset.js . This is to aid in translating to different languages. For your example, just create one file and call it Redirect If Empty.htm .

Note: When testing your server behavior in Dreamweaver, you should edit the server behavior HTML file using a separate text editor, such as Notepad or SimpleText.

Your server behavior must be able to identify any UltraDev document that contains an instance of the server behavior. So, inside your test document you must provide an optimized way for the server behavior to search for an identifier it recognizes. This identifier is a simple comment at the top of your HTML file. It should match some string within your run-time code. The string cannot use regular expressions and it is not case-sensitive. Be careful not to include any code that could be accidentally altered by the user. Here's an example of a weak search string:

<!-- search=".EOF) Response.Redirect" -->

You don't really need the space character before " Response ...," and a user could accidently delete that space in the run-time code of their document, resulting in your server behavior never running. A more reliable search string is simply " Response.Redirect ".

Add the following search string to the top of your Redirect If Empty.htm file:

<!-- search="Response.Redirect" -->

This quick search string notifies your server behavior that it might be interested in the current document. (Later, you'll do a more detailed search as part of the implementation of the run-time code.)

Remember that this search string is just an optimization. It's better if the server behavior finds the search string in too many of the user's documents than not to find it at all. Sometimes server behavior developers change the run-time code but forget to change the search string, which can be very hard to discover because nothing works. While you are developing and changing your run-time code, you may want to set this string to an ubiquitous value such as a single space. []

You will be using many common functions and classes in the remaining steps. To access all that useful code you need to include some common files. Start with the basics here.

<SCRIPT SRC="../../Shared/MM/Scripts/CMN/UI.js"></SCRIPT>
<SCRIPT SRC="../../Shared/MM/Scripts/CMN/file.js"></SCRIPT>
<SCRIPT SRC="../../Shared/MM/Scripts/CMN/string.js"></SCRIPT>
<SCRIPT SRC="../../Shared/MM/Scripts/CMN/localText.js"></SCRIPT>
<SCRIPT SRC="../../Shared/MM/Scripts/CMN/docInfo.js"></SCRIPT>
<SCRIPT SRC="../../Shared/MM/Scripts/CMN/niceName.js"></SCRIPT>
<SCRIPT SRC="../../Shared/MM/Scripts/CMN/helper.js"></SCRIPT>
<SCRIPT SRC="../../Shared/MM/Scripts/CMN/displayHelp.js"></SCRIPT>
<SCRIPT SRC="../../Shared/MM/Scripts/Class/ListControlClass.js"></SCRIPT>
<SCRIPT SRC="../../Shared/UltraDev/Scripts/ssClasses.js"></SCRIPT>
<SCRIPT SRC="../../Shared/UltraDev/Scripts/ssDocManager.js"></SCRIPT>
<SCRIPT SRC="../../Shared/UltraDev/Scripts/ssCmnElements.js"></SCRIPT>

To display your server behavior in the plus (+) menu of the Server Behavior window, add the following function prototypes. You will implement each one later in this exercise.

<SCRIPT>
function findServerBehaviors() {
  return Array();
}
function canApplyServerBehavior() {
}
function applyServerBehaviors(ssRec) {
}
function deleteServerBehavior(ssRec) {
}
function inspectServerBehavior(ssRec) {
}
function analyzeServerBehavior(ssRec) {
}

function initializeUI() {
}
</SCRIPT>

To display any Dreamweaver extension user interface, your UI file must contain a form tag. For now, add a simple form tag in the body of Redirect If Empty.htm . Your server behavior file should now look like the sample file Step02_RedirectIfEmpty.htm.

Now you are ready for a quick test. Restart Dreamweaver and open the test file. Open the server behavior window. Click the plus (+) menu and choose Redirect If Empty. You should see a blank window. Click Cancel.

To Table of Contents Back to Previous document Forward to next document