Universal event handling for components in Kentico CMS

Slides:



Advertisements
Similar presentations
2/25/2013 Miro Remias, Solution Architect
Advertisements

Design Validation CSCI 5801: Software Engineering.
Built-in Kentico CMS UI Controls
Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Msepm.hsquared.be. Eventing Architecture Server-side events and the Queue Creating an Event Handler A statusing example Deploying an Event Handler Event.
Caching and caching dependencies explained in Kentico CMS
1 XML Web Services Practical Implementations Bob Steemson Product Architect iSOFT plc.
Built-in Kentico CMS UI Controls
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
How to Swing a Service Bus Like You Mean It SOA with NServiceBus Jim
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
C# Event Processing Model Solving The Mystery. Agenda Introduction C# Event Processing Macro View Required Components Role of Each Component How To Create.
Label production Solution with Label Gallery programs Label Gallery is used for general label design and print GalleryData is used to create small database.
Label production Solution with Label Gallery programs Label Gallery is used for general label design and print GalleryForm is used to create data entry.
Web Form Fundamentals MacDonald Ch. 5 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
Miro Remias Solution architect Kentico software
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
JavaScript & jQuery the missing manual Chapter 11
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Telerik Software Academy ASP.NET Web Forms Data Validation, Data Validators, Validation Groups Telerik Software Academy
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Partners’ Webinar 10/25/2012 Karol Jarkovsky Solution Architect E-commerce Scenarios.
ASP.NET and Model View Control Jesper Tørresø ITNET2 F08.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Data File Access API : Under the Hood Simon Horwith CTO Etrilogy Ltd.
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,
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 6 1 Microsoft Office FrontPage 2003 Tutorial 6 – Publishing a Web Site.
Effective Gathering of Requirements for Kentico CMS Project Karol Jarkovsky Consultant Kentico Software
1 4/97 Object-Oriented Design Workshop Week 6: Some Patterns for Implementing Associations, Part 1 David Van Camp Object Technology Consultant Software.
File I/O 11_file_processing.ppt
G RAPHICAL U SER I NTERFACE C ONCEPTS : P ART 1 1 Outline Introduction Windows Forms Event-Handling Model - Basic Event Handling.
CCA Event Specification Proposal
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Unit 3: Adding Code to a Microsoft ASP.NET Web Form.
Global.asax file. Agenda What is Global.asax file How to add the Global.asax file What are the default events available Explanation to Application_Level.
MD – Object Model Domain eSales Checker Presentation Régis Elling 26 th October 2005.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
EBZ 321 Extending CMS 2002 Publishing Processes Scott Fynn Microsoft Consulting Services National Practices.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Enterprise Integration Patterns CS3300 Fall 2015.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC PROGRAMMING FUNDAMENTALS Bilal Munir Mughal 1 Chapter-8.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
Module 4: Creating a Web Application with Web Forms
Portals: Architecture & Best Practices Greg Hinkle February 2005.
Mach II at Macromedia Sean Corfield Director, Architecture An introduction to Mach II and its use on macromedia.com.
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.
Web Application Design. Data –What data is available? –How do we store it or how is it stored in the DB? Schema Data types Etc. –Where is the data?
Michigan.gov Portal II Design Changes Thursday, March 4, 2004.
 ASP.NET provides an event based programming model that simplifies web programming  All GUI applications are incomplete without enabling actions  These.
APLIKACIJE KOJE SU IZVAN SEBE Domagoj Pavlešić, dizzy.hr.
Using the Kentico CMS API Thom Robbins Bryan Soltis
© 2004 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Programming the Web Using ASP.Net Chapter 6: The User Interface (UI) Dave.
Computing with C# and the .NET Framework
Getting Started with... Business Partner Express
Delegates and Events 14: Delegates and Events
Chapter Eleven Handling Events.
Using Procedures and Exception Handling
C# Event Processing Model
Hi and welcome to the Order Centre – Ordering training.
Part A – Doing Your Own Input Validation with Simple VB Tools
Module 10: Creating a Web Application with Web Forms
CIS16 Application Development and Programming using Visual Basic.net
Caching.
ASP.NET and Model View Control
Presentation transcript:

Universal event handling for components in Kentico CMS Boris Pocatko Solution Architect Kentico Software borisp@kentico.com

Agenda Problem Solution API How does it work

Problem A quite common need is to implement components which influence each other. Examples Hiding a control or web part when the user selects a specific value in a dropdown box. Dependent form fields Recalculating price according to selected currency in separate web parts

Problem I. schema Component 1 ? Component 2

Problem I. solution schema Component 1 Component 2 RegisterToE... E E HandleE(…) { … } Solution: Usage of events, where Component 2 registers to an Event implemented in the Component 1. Component 1 then raises the Event on some action and the Component 2 handles it with a handler registered to the Event of Component 1.

Problem I. solution Component 1 Component 2 public event EventHandler E; private void FunctionThatRaisesEventE() { // Raise event this.StatusUpdated(new object(), new EventArgs()); } Component 2 public void SetupControl() { // Register event handling method component1.E += new EventHandler(HandleE); } public void HandleE(object sender, EventArgs e) // Handle event

Problem I. summary The good Acceptable difficulty Not much coding involved Simplest solution Two components, which can be used independently in the portal engine, thus resulting in bigger flexibility when designing a page The bad Control reference needed Component are depending on each other Explicit event declaration

Problem II. schema Component 3 Component 1 Component 2 Component 6 4 Component 5

Problem II. solution schema 1 Component 3 RegisterToE... HandleE(…) { … } Component 1 Component 2 E E RegisterToE... HandleE(…) { … } E2 E2 RegisterToE3... Component 6 Component 4 Component 5 RegisterToE2... RegisterToE3... HandleE3(…) { … } HandleE2(…) { … } HandleE3(…) { … } E3 E3

Problem II. solution I summary The good Flexibility The bad Control reference needed Component are depending on each other Explicit event declaration Increased difficulty Poor maintainability

Problem II. solution schema 2 Component 1 Method 3 Method 1 Method 2 Method 6 Method 4 Method 5

Problem II. solution II summary The good Medium implementation difficulty The bad Difficult maintainability Flexibility loss Components re-use is difficult

Problem I. solution with Kentico component events private void FunctionThatRaisesEventE(object sender, EventArgs e) { // Raise Event ComponentEvents.RequestEvents.RaiseEvent(sender, e, "E"); } Component 2 public void SetupControl() { // Register for Event ComponentEvents.RequestEvents.RegisterForEvent("E", HandleE); } public void HandleE(object sender, EventArgs e) // Handle event

Problem II. solution schema 1 compared Component 3 RegisterToE... Getting rid of component dependencies (references aren’t necessary) and of event declarations HandleE(…) { … } Component 1 Component 2 E E RegisterToE... HandleE(…) { … } E2 E2 Component 6 Component 4 Component 5 RegisterToE3... RegisterToE2... RegisterToE3... HandleE3(…) { … } HandleE2(…) { … } HandleE3(…) { … } E3 E3

Problem II. solution with Kentico component events RegisterToE... HandleE(…) { … } Component 1 Component 2 E RegisterToE... HandleE(…) { … } E2 RegisterToE3... Component 6 Component 4 Component 5 RegisterToE2... RegisterToE3... HandleE3(…) { … } HandleE2(…) { … } HandleE3(…) { … } E3

Problem II. solution with Kentico component events summary Increased flexibility Easier development Re-use of components No control references necessary No controls dependencies Easier maintainability No explicit event declaration necessary

Component Events API I. Namespaces/classes Registering of events CMS.SettingsProvider.ComponentEvents.RequestEvents Events that are fired and survive within current request CMS.SettingsProvider.ComponentEvents.GlobalEvents - Global events that are fired and survive across requests during the whole application lifetime Registering of events RegisterForEvent(string eventName, EventHandler<EventArgs> handler) RegisterForEvent(string eventName, string actionName, EventHandler<EventArgs> handler) RegisterForEvent<ArgsType>(string eventName, string actionName, EventHandler<ArgsType> handler) where ArgsType : EventArgs eventName: name of the event (e.g. Update) actionName: action name, adds granularity, (e.g. Before, After) handler: handler method for the event

Component Events API II. Registering of events RegisterForComponentEvent(string componentName, string eventName, EventHandler<EventArgs> handler) RegisterForComponentEvent(string componentName, string eventName, string actionName, EventHandler<EventArgs> handler) componentName: name of the component, another level of granularity (e.g. web part id) actionName: action name, adds granularity (e.g. Before, After) eventName: name of the event (e.g. Update) handler: handler method for the event

Component Events API III. Raising of events RaiseComponentEvent(object sender, EventArgs e, string componentName, string eventName) RaiseComponentEvent(object sender, EventArgs e, string componentName, string eventName, string actionName) RaiseEvent(object sender, EventArgs e, string eventName) sender: object raising the event (e.g. web part) e: event arguments componentName: name of the component raising the event actionName: action name, adds granularity (e.g. Before, After) eventName: name of the event (e.g. Update) Registration & raise parameters need to match

How does it work Events and handlers stored in a hashtable - case insensitive During event registration a new entry is created in the hashtable When an event is raised, the system calls all event handler methods registered (saved) for a given key combination of component name, event and action The hashtable looks the following way: componentName:eventName | sub-hashtable eventName | sub-hashtable sub-hashtable: key: actionName or ##global## value: handler

How does it work Simple debug screenshot of an event with a sub-hashtable with only one value:

How does it work Calling: ComponentEvents.RequestEvents.RegisterForComponentEvent("testComponent", "testEvent", "testAction", SomeMethod) ComponentEvents.RequestEvents.RegisterForComponentEvent("testComponent", "testEvent", "testAction2", SomeMethod) Creates a hashtable within the events hashtable, with the event key “testComponent:testEvent”. The sub-hashtable contains two values, with keys “testAction” and “testAction2”:

Example of use: Wizard layout web part Components developed for the Wizard layout web part can subscribe to a number of Events: LOAD_STEP VALIDATE_STEP FINISH_STEP CANCEL_STEP FINISH These Events are registered as component events

Kentico component events DEMO – Component events

Additional resources Wizard layout web part http://devnet.kentico.com/docs/webparts/Wizard_overview.htm Link / Button web part http://devnet.kentico.com/docs/webparts/Link_overview.htm (supports events) Kentico CMS API reference http://devnet.kentico.com/docs/kenticocms_api.zip

Questions & Answers ?

Thank you!