Building Server Behaviors Tom Muck co-author Building Dreamweaver 4 and

23
Building Server Building Server Behaviors Behaviors Tom Muck Tom Muck co-author co-author Building Dreamweaver 4 Building Dreamweaver 4 and and Dreamweaver UltraDev 4 Dreamweaver UltraDev 4 Extensions Extensions

description

Building Server Behaviors Tom Muck co-author Building Dreamweaver 4 and Dreamweaver UltraDev 4 Extensions. The Dreamweaver Extensibility Model. Objects Behaviors Commands Server Behaviors Data Sources Toolbars. Server Behaviors. - PowerPoint PPT Presentation

Transcript of Building Server Behaviors Tom Muck co-author Building Dreamweaver 4 and

Page 1: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Building Server BehaviorsBuilding Server Behaviors

Tom MuckTom Muck

co-author co-author

Building Dreamweaver 4 Building Dreamweaver 4

and and

Dreamweaver UltraDev 4 ExtensionsDreamweaver UltraDev 4 Extensions

Page 2: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

The Dreamweaver The Dreamweaver Extensibility ModelExtensibility Model

• ObjectsObjects• BehaviorsBehaviors• CommandsCommands• Server BehaviorsServer Behaviors• Data SourcesData Sources• ToolbarsToolbars

Page 3: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Server BehaviorsServer Behaviors

• Used to insert code that needs to be processed at the Used to insert code that needs to be processed at the ServerServer

• Important to the integration of custom code into the Important to the integration of custom code into the Dreamweaver environmentDreamweaver environment

• Supported for all of the Dreamweaver Server ModelsSupported for all of the Dreamweaver Server Models

• ASP, PHP, CF, JSP, ASP.NETASP, PHP, CF, JSP, ASP.NET

• Can include one or more modelsCan include one or more models

Page 4: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Constructing Server BehaviorsConstructing Server Behaviors

• Assemble working codeAssemble working code• Build the Server BehaviorBuild the Server Behavior

• Hand CodingHand Coding• The Server Behavior BuilderThe Server Behavior Builder

• Test the Server BehaviorTest the Server Behavior• Package and Distribute the Server BehaviorPackage and Distribute the Server Behavior

Page 5: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

The Server Behavior BuilderThe Server Behavior Builder

• Designed to simplify the addition of custom Server Designed to simplify the addition of custom Server BehaviorsBehaviors

• Requires that you know two thingsRequires that you know two things• The final code needed to do the jobThe final code needed to do the job• Where the code needs to goWhere the code needs to go

• Handles the construction of the various functions within Handles the construction of the various functions within a Server Behaviora Server Behavior

• Has significantly increased the number of available Has significantly increased the number of available behaviorsbehaviors

Page 6: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Response.Redirect Server Response.Redirect Server BehaviorBehavior

• Assemble the working codeAssemble the working code• Construct the Server BehaviorConstruct the Server Behavior

• Touring the Server Behavior BuilderTouring the Server Behavior Builder• Testing the Server BehaviorTesting the Server Behavior

• Packaging and Distributing the Server BehaviorPackaging and Distributing the Server Behavior• MXI filesMXI files• MXP filesMXP files• The Dreamweaver ExchangeThe Dreamweaver Exchange

Page 7: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

A Conditional Region Server A Conditional Region Server BehaviorBehavior

• More complex codeMore complex code• Requires multiple code blocksRequires multiple code blocks• Can be applied to a variety of objectsCan be applied to a variety of objects• Can be built to check for a number of conditionsCan be built to check for a number of conditions

Page 8: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Part 2Part 2

Going Beyond the Server Behavior Going Beyond the Server Behavior BuilderBuilder

Page 9: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Limitations of the SBBLimitations of the SBB

• Doesn’t provide input validationDoesn’t provide input validation• Creates regular expressions that match the code Creates regular expressions that match the code

exactly -- no fuzzy matches possibleexactly -- no fuzzy matches possible• Doesn’t manipulate the selectionDoesn’t manipulate the selection

Page 10: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

SBB-generated Server Behaviors SBB-generated Server Behaviors Can Be ExtendedCan Be Extended

SBB builds HTML, JS, and XML extensionsSBB builds HTML, JS, and XML extensions -- no mystery here. They can be extended.-- no mystery here. They can be extended.

SBB files located in three places:SBB files located in three places: HTML files located in HTML files located in ServerBehaviorsServerBehaviors folder folder XML files located in XML files located in ServerBehaviorsServerBehaviors folder folder Controls located in Controls located in SharedShared > > ControlsControls > >

ScriptsScripts folder folder

Page 11: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Structure of a Server BehaviorStructure of a Server Behavior

initializeIU()initializeIU() -- initializes all controls -- initializes all controls canApplyServerBehavior()canApplyServerBehavior() -- can the SB be -- can the SB be

applied?applied? findServerBehaviors()findServerBehaviors() -- finds instances of the SB -- finds instances of the SB

on the pageon the page applyServerBehavior()applyServerBehavior() -- applies the SB to the -- applies the SB to the

pagepage

A Server Behavior is an HTML document with JavaScript functions, API calls, and XML participants

Page 12: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Structure of a Server Behavior - Structure of a Server Behavior - pt 2pt 2

More API functionsMore API functions

•inspectServerBehavior() -- take the SB apart and populate the interface•deleteServerBehavior() -- delete the SB•analyzeServerBehavior() -- is the SB whole?

Page 13: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

API Functions Not ImplementedAPI Functions Not Implemented

copyServerBehavior()copyServerBehavior() pasteServerBehavior()pasteServerBehavior() With these two functions defined in your With these two functions defined in your

SB, you can copy and paste Server SB, you can copy and paste Server Behaviors between pages. Behaviors between pages.

Not implemented, but fully documented in Not implemented, but fully documented in the the Extending DW and DreamweaverExtending DW and Dreamweaver documents.documents.

Page 14: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Input ValidationInput Validation

Generic JavaScript routines can be written to Generic JavaScript routines can be written to use in your extensionsuse in your extensions

Best place to put the validation -- Best place to put the validation -- applyServerBehavior()applyServerBehavior()

Use the Use the errStrerrStr to create an error message -- this to create an error message -- this will stop the SB from being appliedwill stop the SB from being applied

Benefits of validationBenefits of validation Pitfalls of validationPitfalls of validation

Page 15: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Pitfalls of ValidationPitfalls of Validation

ExampleExample: Adding a color to a Server Behavior: Adding a color to a Server Behavior Can your color look like this? Can your color look like this? #00FF00#00FF00

Can your color look like this?Can your color look like this? #00ff00#00ff00

How about this?How about this? RedRed

Page 16: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Pitfalls of ValidationPitfalls of Validation

Or this?Or this? <cfoutput>#Recordset1.UserColorPref#</cfoutput><cfoutput>#Recordset1.UserColorPref#</cfoutput>

Or this? Or this? <%=(rsGetUserPrefs.Fields.Item("bgcolor").Value)%><%=(rsGetUserPrefs.Fields.Item("bgcolor").Value)%>

Answer:Answer: There is no way to validate for every user and every There is no way to validate for every user and every

situation. You can’t predict how someone else will use situation. You can’t predict how someone else will use your extension or how you will use it in the future.your extension or how you will use it in the future.

Page 17: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

canApplyServerBehavior() -- canApplyServerBehavior() -- How to Take Advantage of ItHow to Take Advantage of It

What does your SB need as a prerequisite?What does your SB need as a prerequisite? How do you find out if the page has what it How do you find out if the page has what it

needs?needs? Thinking ahead. Can this function come back Thinking ahead. Can this function come back

to haunt you?to haunt you?

Page 18: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Other Dreamweaver Extensions:Other Dreamweaver Extensions:

Server FormatsServer Formats Server ModelsServer Models TranslatorsTranslators ConnectionsConnections Server Behavior Builder ControlsServer Behavior Builder Controls Data SourcesData Sources

Page 19: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Server Formats -- Located in the Server Formats -- Located in the ServerFormats folderServerFormats folder

Adds a format or function to a server expressionAdds a format or function to a server expression Examples:Examples:• Money formattingMoney formatting• Time formattingTime formatting• Removing or replacing charactersRemoving or replacing characters These require that a regular expression to be These require that a regular expression to be

written inside of the written inside of the Formats.xmlFormats.xml file file

Page 20: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

TranslatorsTranslators

New format for Dreamweaver MXNew format for Dreamweaver MX Different than Dreamweaver Translators Different than Dreamweaver Translators -- XML architecture-- XML architecture Located in the ExtensionData > MM > Located in the ExtensionData > MM >

Translations folderTranslations folder

Page 21: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

ConnectionsConnections

Connections are extensible alsoConnections are extensible also JDBC Drivers can be easily addedJDBC Drivers can be easily added

Page 22: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Server Behavior Builder ControlsServer Behavior Builder Controls

SBB is extensibleSBB is extensible Controls available on the WebControls available on the Web Files located in Files located in

Configuration > Shared > Controls > String Configuration > Shared > Controls > String MenuMenu

Configuration > Shared > Controls > ScriptsConfiguration > Shared > Controls > Scripts

Remember to include the JS file in your Remember to include the JS file in your extensionextension

Page 23: Building Server Behaviors Tom Muck co-author  Building Dreamweaver 4  and

Data SourcesData Sources

Many possibilities for new extensionsMany possibilities for new extensions• COM objectsCOM objects• CF TagsCF Tags• ASP ObjectsASP Objects• Shopping CartsShopping Carts These are complex extensions tied in with These are complex extensions tied in with

Server Behaviors and CommandsServer Behaviors and Commands