Tom Link CTO, Universal Mind

Slides:



Advertisements
Similar presentations
Adding User Interactions actionscript 3.0. Common event-handling tasks Writing code to respond to events Stopping code from responding to events Working.
Advertisements

Quick Start Guide | Skill Assessments Using your Online Product Interfaces and Features Getting Started - My Account Creating/Logging into your Self Test.
The Web Warrior Guide to Web Design Technologies
June 28 th – July 1 st 2006 Implementing Usability: Insights to improve your chances  CFUnited 2007.
JavaScript, Third Edition
Object-Oriented Analysis and Design
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Cos 381 Day 10.
UNIT-V The MVC architecture and Struts Framework.
Java Beans.
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
KRAD makes it easy to handle HTML events in your webpage. Kuali University: Apply Now Lab 6: Fun with HTML Events Lab Objectives HTML Events – what are.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
© 2005 by IBM; made available under the EPL v1.0 | March 1, 2005 Tim deBoer Gorkem Ercan Extend WTP Server Tools for your.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Execution Environment for JavaScript " Java Script Window object represents the window in which the browser displays documents. " The Window object provides.
Using Intents to Broadcast Events Intents Can be used to broadcast messages anonymously Between components via the sendBroadcast method As a result Broadcast.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
JavaScript, Part 3 Instructor: Charles Moen CSCI/CINF 4230.
Lab 6: event & input intro User Interface Lab: GUI Lab Oct. 2 nd, 2013.
GEMVC. The Setup Folders Views Value Objects (VOs) Custom Events Service CFCs Controller Model Application Main MXML.
Web User Controls This presentation will cover the basics of defining, creating and using a web user control. Presented to Twin Cities.NET user group By.
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
Events DOM Event Model. HTML Events "on" + event name attribute value is javascript javascript runs 1st return false to STOP browser event (if any)
Cairngorm Microarchitecture. Pronunciation Cairngorm (kârn gôrm) n. yellowish-brown variety of quartz, especially found in Scottish Cairngorm mountain.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Developing Great Dashlets Will Abson About Me Project Lead, Share Extras Alfresco Developer and previously Solutions Engineer DevCon 2011 –
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
CFUNITED – The premier ColdFusion conference ColdFusion Components Ajay Sathuluri Based on presentation.
Thursday, August 6 th, 2015 Instructor: Craig Duckett Event Handling.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
Event Handling (the right way). A Simple Web Page Events - Summary The web page looks like this:
Understanding JavaScript and Coding Essentials Lesson 8.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
Introduction  “M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER”. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner.
Events Event Handling in JavaScript SoftUni Team Technical Trainers Software University
Mach-II Primer Ben Edwards An Introduction to Mach-II: An event-based, implicit invocation web-application framework.
The Chain of Responsibility Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
 ASP.NET provides an event based programming model that simplifies web programming  All GUI applications are incomplete without enabling actions  These.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Developing Great Dashlets Will Abson About Me Project Lead, Share Extras Alfresco Developer and previously Solutions Engineer DevCon 2011 –
1 Developing for Test Automation and Accessibility Using Programmatic Access to the UI Thomas Logan FUN307 Program Manager Microsoft Corporation.
CFUNITED – The premier ColdFusion conference Load and Functional Testing Flex 2 and ColdFusion Matthew Stevanus Universal Mind.
Developing Great Dashlets Will Abson About Me Project Lead, Share Extras Alfresco Developer and previously Solutions Engineer DevCon 2011 –
CFUNITED – The premier ColdFusion conference Using Event Gateways with CFMX7 By Jeff Tapper Tapper.net Consulting.
Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems.
Thomas Burleson. Using MVC with Flex & Coldfusion Projects June 27, 2007 See how Coldfusion MVC is similar to Flex MVC…
ArcGIS for Server Security: Advanced
Java Server Pages Can web pages be created specially for each user?
Joy Rathnayake Senior Architect – Virtusa Pvt. Ltd.
Geospatial Research & Solutions GIS.ASU.EDU
Web Software Model CS 4640 Programming Languages for Web Applications
Lecture 28 Concurrent, Responsive GUIs
JavaScript and Events.
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
Events.
1/10/2019 JavaFX Events COSC 330.
Event Driven Systems and Modeling
Web Development Using ASP .NET
Presentation transcript:

Tom Link CTO, Universal Mind Flex 2.0 Event Model – 202 Tom Link CTO, Universal Mind CFUNITED – The premier ColdFusion conference www.cfunited.com

About Me CTO, Universal Mind (UM) Lead UM’s Flex Consulting Practice Certifications Advanced CF Flex Trainer 5 years at Adobe/Macromedia Worldwide Professional Services Flex Support / Enablement Services June 28th – July 1st 2006

Objectives I. Why Events? II. Using Events in existing Flex components III. About the Event object IV. Using Events in your own custom Flex components June 28th – July 1st 2006

I. Why Events. II. Using Events in existing Flex. components III I. Why Events? II. Using Events in existing Flex components III. About the Event object IV. Using Events in your own custom Flex components June 28th – July 1st 2006

What are Events? Events are a mechanism or “hook” for letting a developer know that “something happened” in an application For example The user clicked the mouse Data was returned from a CF request The user added an item to their cart June 28th – July 1st 2006

Where are Events in CF? With “traditional” HTML applications, each page request equates to an event <a href=“/addItem.cfm?id=3”>Add Item</a> The app “responds to the event” by producing a new HTML page. June 28th – July 1st 2006

Why Events in Flex A Flex application “lives” on the client Many user interactions w/o server intervention Richer client-side communication is required. Since HTML based apps aren’t built in this fashion, the concept of Events are can be new (and conceptually a hurdle) for many CF developers. June 28th – July 1st 2006

Quick aside: CF has Events too CF has “grown up” to include events Application events handled via Application.cfc Application start/end, Session start/end Event Gateways receive events from non-web based apps/devices “I’ve received an SMS” June 28th – July 1st 2006

I. Why Events. II. Using Events in existing Flex. components III I. Why Events? II. Using Events in existing Flex components III. About the Event object IV. Using Events in your own custom Flex components June 28th – July 1st 2006

Event terminology Developers use event handlers to handle events that are dispatched by components. June 28th – July 1st 2006

Using Events Using events is a 2-step process Write a function (event handler) to respond to an Event Register that function as a recipient of a particular Event June 28th – July 1st 2006

Using Events – step 1 Write a function (event handler) to response to an Event function onClick(e:Event):void { Alert.show(“Button Clicked”); } June 28th – July 1st 2006

Using Events – step 2 Register that function as a recipient of a particular Event Option #1: MXML / inline <mx:Button id=“myButton” click=“onClick(event)” /> Option #2: AS / addEventListener myButton.addEventListener(MouseEvent.CLICK, onButtonClick); June 28th – July 1st 2006

Demo: Handling an event (inline syntax) <mx:Button id=“myButton” click=“onClick(event)” /> <mx:Script> function onClick(e:Event):void { Alert.show(“Button Clicked”); } </mx:Script> See code samples… June 28th – July 1st 2006

Demo: Handling an event (addEventListener syntax) <mx:Button id=“myButton”/> <mx:Script> public function onInitialize():void { myButton.addEventListener(MouseEvent.CLICK, onButtonClick); } function onClick(e:Event):void Alert.show(“Button Clicked”); </mx:Script> See code samples… June 28th – July 1st 2006

Why Use AddEventListener In some cases, just personal preference MVC: Separation of view from controller Provides more advanced control of event handling Event Propagation Event Priority June 28th – July 1st 2006

Event Propagation Who can listen for an Event? The dispatcher Any ancestor When an event is dispatched, Flex has a process to find listeners and their order… June 28th – July 1st 2006

Event Propagation Phases Capturing: root ancestor to direct ancestor Application -> VBox -> TitleWindow Targeting: dispatcher Button Bubbling: direct ancestor to root ancestor TitleWindow -> VBox -> Application June 28th – July 1st 2006

Event Propagation Capture phase is “off” by default Enabled as an arg to addEventListener Any listener can stop propagation To participate in capture and bubble phases, a component needs two separate event listeners We won’t use propagation in our demo June 28th – July 1st 2006

Events Documentation Each event available for a component is documented in the Flex MXML API June 28th – July 1st 2006

I. Why Events. II. Using Events in existing Flex. components III I. Why Events? II. Using Events in existing Flex components III. About the Event object IV. Using Events in your own custom Flex components June 28th – July 1st 2006

Events pass objects When an Event is dispatched, an Event object is created All Event objects contain properties: type: the name of the event target: a reference to the component that dispatched the event Some Events pass additional properties related to a specific Event type June 28th – July 1st 2006

Demo: Handling Event w/ Event Object <mx:Button label=“red” click=“onClick(event)”/> <mx:Button label=“green” click=“onClick(event)”/> <mx:Script> function onClick(e:Event):void { Alert.show(e.target.label); } </mx:Script> See code samples… June 28th – July 1st 2006

Event object datatype Every event is an instance of the flash.event.Events class Some events subclass the Events class to provide additional properties MouseEvent DragDropEvent June 28th – July 1st 2006

Demo: Subclassed Event import flash.events.MouseEvent; onClick(event:MouseEvent):void { Alert.show("localX: "+event.localX); } MouseEvent class is a subclass of Event localX is a property of the MouseEvent class See code samples… June 28th – July 1st 2006

DispatchEvent Developers can programmatically dispatch Events Existing Flex UI components/Events myButton.dispatchEvent (new Event(MouseEvent.CLICK)); Developer custom components/Events Well cover this shortly… June 28th – July 1st 2006

Demo: DispatchEvent <mx:Button id="myButton" click="onButtonClick(event)"/> <mx:Script> <![CDATA[ import mx.controls.Alert; import flash.events.MouseEvent; public function onInitialize():void { myButton.dispatchEvent(newMouseEvent(MouseEvent.CLICK)); } public function onButtonClick(event:MouseEvent):void mx.controls.Alert.show("Button Clicked"); ]]> </mx:Script> See code samples… June 28th – July 1st 2006

I. Why Events. II. Using Events in existing Flex. components III I. Why Events? II. Using Events in existing Flex components III. About the Event object IV. Using Events in your own custom Flex components June 28th – July 1st 2006

Why Custom Components Same reasons as CF Similar constructs to CF Improved Reusability Easier Maintenance Ability to “black box” complexities Similar constructs to CF customtags, CFCs June 28th – July 1st 2006

Demo: Custom Components Solution in monolithic app Solution broken into components See code samples… June 28th – July 1st 2006

Inter-component communication When we organize our application into components… How do we pass data between components or notify them that “something happened?” June 28th – July 1st 2006

Method 1 Reference custom component and it’s children myComponent.myDatagrid.selectedIndex comp.compChild.firstName.text June 28th – July 1st 2006

Method 1 (cont’d) What’s wrong with this? More tightly coupled Less reusable Too many inter-application dependencies What happens if one component changes it’s internal components? June 28th – July 1st 2006

Method 2 – Using Events Use Events All a developer needs to know: Provides a “loosely coupled” solution All a developer needs to know: Properties can be used to pass data in/out Events will exist to notify the outside world that “something has happened” This is a cleaner API that doesn’t depend on the existence of particular UI elements June 28th – July 1st 2006

Using Events for inter-component communication Same process as Flex core components 2 steps: Write event handler to handle Event We’ve done this already Add code for our custom component to dispatch an event Define Event Dispatch Event June 28th – July 1st 2006

Step 1 – Handle Event Same as handling event from a core Flex component <mx:Button click=“onButtonClick(event)”/> We use the same structure: <comp:PitcherSelector id="pitcherSelector" pitchers="{pitchers}" pitcherSelected="selectedPitcher=event.pitcher"/> June 28th – July 1st 2006

Step 2(a) – Define Event Object Define the type of Event that our component will dispatch Allows us to specify custom data that our Event will pass Must extend flash.events.Event class June 28th – July 1st 2006

Custom Event Object PitcherSelectedEvent.as: package events { import flash.events.Event; import model.PitcherVO; public class PitcherSelectedEvent extends flash.events.Event { public var pitcher:PitcherVO; public function PitcherSelectedEvent(vo:PitcherVO) { super("pitcherSelected"); this.pitcher = vo; } }} See code samples… June 28th – July 1st 2006

Step 2(b) – Dispatch Custom Event In custom component Declare the Event Let the component know that it needs to be capable of dispatching this event Dispatch the Event Usually based on some sort of user interaction, so usually “piggybacking” a UI component event June 28th – July 1st 2006

Declare Event Use mx:MetaData tag: <mx:Metadata> [Event(name="pitcherSelected", type="events.PitcherSelectedEvent")] </mx:Metadata> June 28th – July 1st 2006

Use dispatchEvent method import events.PitcherSelectedEvent; private function onPitcherSelect(event:Event):void { dispatchEvent(new PitcherSelectedEvent(event.target.selectedItem)); } June 28th – July 1st 2006

Demo – Dispatching Custom Events Let’s Review Our Custom Event (events/PitcherSelectedEvent.as) Defines the event our component will dispatch Our Main Application (main.mxml) Declares our component and handles the event Our Custom Component (PitcherSelector.mxml) Declares the custom PitcherSelectedEvent Dispatches the Event based on user interaction See code samples… June 28th – July 1st 2006

Let’s Recap… June 28th – July 1st 2006

Summary Events are hooks to for a developer to execute code based on “something happening” Flex UI components dispatch Events that developers can handle Developers can build custom components that use the same Event infrastructure for robust application communication June 28th – July 1st 2006

Tom Link tom@universalmind.com Thank You! Tom Link tom@universalmind.com CFUNITED – The premier ColdFusion conference www.cfunited.com