Walk on the Client Side take a… Nick Airdo Software Engineer

Slides:



Advertisements
Similar presentations
Introduction to jQuery (for Drupal) Amit Asaravala “aasarava” on drupal.org.
Advertisements

John Culviner johnculviner.com DEMO CODE:
The Web is perhaps the single largest data source in the world. Due to the heterogeneity and lack of structure, mining and integration are challenging.
1 JavaScript & AJAX CS , Spring JavaScript.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
#RefreshCache CI - Daily Builds w/Jenkins – an Open Source Continuous Integration Server Nick Airdo Community Developer Advocate Central Christian Church.
UNIT-V The MVC architecture and Struts Framework.
Agenda What is AJAX? What is jQuery? Demonstration/Tutorial Resources Q&A.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
JavaScript, jQuery & AJAX. What is JavaScript? An interpreted programming language with object oriented capabilities. Not Java! –Originally called LiveScript,
JavaScript & jQuery the missing manual Chapter 11
Intro to Ajax Fred Stluka Jan 25, /25/2006Intro to AjaxFred Stluka2 What is Ajax? "Asynchronous JavaScript and XML" New name for an old technique:
JQuery Adding behaviour…. Lecture Plan Review of last lesson Adding behaviour –click, mouseover Animation –fade, slideDown Navigation –parent, find, next.
Spicing Up Web Parts Randy Williams SharePoint Hawaii User Group May 11, 2011.
Tom Castiglia Hershey Technologies
Presentation. Recap A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate. Taken advantage of Spring’s multi layer.
MVC Advanced & Reflection Reflection, Parsing Dynamic Data, Asynchronous Requests SoftUni Team Technical Trainers Software University
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
.  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.
School of Computing and Information Systems CS 371 Web Application Programming AJAX.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
XSLT & Arena Promotions A flexible approach to web promotions Nick Airdo Software Engineer Central Christian Church
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
ICM – API Server & Forms Gary Ratcliffe.
Johannes Brodwall Chief Scientist Smidig arkitektur.
Presentation.
CMS 2: Advanced Web Editing - Content Presented By: Katie Pagano, Special Projects Manager Steve Pont, Product Architect.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
The New Face of ASP.NET ASP.NET MVC, Razor, and jQuery Ido Flatow | Senior Architect | Sela | This session is.
SOAP, Web Service, WSDL Week 14 Web site:
11 jQuery Web Service Client. 22 Objectives You will be able to Use JSON (JavaScript Object Notation) for communcations between browser and server methods.
Ur/Web: A Simple Model for Programming the Web
Visual Web & AJAX with Netbeans 6.0 Your Name Sun Campus Ambassador Your Address.
Web Technology Solutions
Web Technologies Computing Science Thompson Rivers University
Not a Language but a series of techniques
CS 371 Web Application Programming
Data Virtualization Tutorial… CORS and CIS
AJAX and REST.
Week 10: Object Modeling (1)Use Case Model
Web Software Model CS 4640 Programming Languages for Web Applications
AJAX.
KnockoutJs online Training at GoLogica in Pune
AJAX.
SharePoint-Hosted Apps and JavaScript
WEB API.
Learn about PnP initiative and the new SharePoint Framework
AJAX Robin Burke ECT 360.
Asynchronous Javascript And XML
Model-View-Controller (MVC) Pattern
JavaScript & jQuery AJAX.
Sending a text message (and more)
JavaScript CS 4640 Programming Languages for Web Applications
An introduction to jQuery
Intro to Ajax Fred Stluka Jan 25, 2006.
Accessing Web Services in Silverlight 4
Web Technologies Computing Science Thompson Rivers University
An introduction to jQuery
Introduction to AJAX and JSON
Chengyu Sun California State University, Los Angeles
Sending a text message (and more)
PHP and JSON Topics Review JSON.
Community Keys key features you should know about Nick Airdo
WCF Data Services and Silverlight
Message Passing Systems Version 2
JavaScript CS 4640 Programming Languages for Web Applications
Message Passing Systems
Presentation transcript:

Walk on the Client Side take a… Nick Airdo Software Engineer Central Christian Church Email: nick.airdo@cccev.com Twitter: @airdo #RefreshCache

Why?

(you’re not questioning that, right?) It’s SOA (you’re not questioning that, right?) You’ll be using or making reusable WebServices Forces you to abstract away your UI stuff You can reuse all these WebServices in your Android app, Silverlight app, iPhone apps, etc.

It’s true Client-Server Finally take advantage of all those wasted cycles on the client’s computer

It’s JavaScript The most prevalent language on the web Crosses the “domain” and “language” barrier – non-devs and devs (PHP, .NET, Java, etc.)

…AJAX with JSON… So, it’s going to be fast and lightweight JSON - the fat free alternative to XML

…and it’s simple

Ok, it looks more complicated than it is.

Web Service from – WebServices/Custom/Cccev/Web2/PromotionService.asmx [WebService(Namespace = "http://www.cccev.com/Arena")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class PromotionService : WebService { // your web methods go here. } Flip over to WebServices/Custom/Cccev/Web2/PromotionService.asmx where the real magic is

ASMX vs. SVC/WCF “The difference in WCF is we program to a specific contract.  Here’s the same example above done in WCF.” “Exposing a WCF service requires a little more training from this point forward …because we have to understand how to configure the service.  It is this little bit of extra effort required to understand WCF configuration that stops a lot of developers from using WCF.  This is a shame because when the developer using ASMX wants to guarantee message delivery, participate in transactions, or use binary serialization instead of XML, they’ve got a lot of work ahead of them as compared to WCF. ”

Web Service’s Web Methods from – WebServices/Custom/Cccev/Web2/PromotionService.asmx [ScriptMethod( ResponseFormat = ResponseFormat.Json )] public object[] GetTopicList() { LookupCollection topics = new LookupCollection(SystemLookupType.TopicArea);  return (from topic in topics.OfType<Lookup>()                 where topic.Active && topic.Qualifier2 == "true"                 orderby topic.Order                 select GetTopicJson(topic)                ).ToArray();     } … Flip over to WebServices/Custom/Cccev/Web2/PromotionService.asmx where the real magic is

Session? No Problem If you’re client usage is coming from an Arena module you can rely on this: [WebMethod(EnableSession = true)] Then you can check the Arena Context as normal: var ctx = ArenaContext.Current; if (ctx.Person != null && ctx.Person.PersonID != -1)

postAsyncJson from - Templates/Cccev/Hasselhoff/js/campus-scripts.js function postAsyncJson(servicePath, postData, onSuccess, onError) { $.ajax({ type: "POST“, url: servicePath, contentType: "application/json; charset=utf-8", data: postData, dataType: "json", success: onSuccess, error: onError }); return false; } See UserControls/Custom/Cccev/Web2/js/jquery-arena-promotions.js We wrapped the standard jQuery ajax call to make it a bit easier So now we just call postAsyncJson with those four params

Example Usage from – UserControls/Custom/Cccev/Web2/js/jquery-arena-promotions.js function loadPromotions(topicIDs, areaFilter, campusID, maxItems, documentTypeID, promotionDetailPageID, eventDetailPageID, success, error) { postAsyncJson("webservices/custom/cccev/web2/promotionservice.asmx/GetByAreaFilter", '{ "topicIDs": "' + topicIDs + '", "areaFilter": "' + areaFilter + '", "campusID":' + campusID + ', "maxItems":' + maxItems + ', "documentTypeID":' + documentTypeID + ', "promotionDetailPageID": ' + promotionDetailPageID + ', "eventDetailPageID": ' + eventDetailPageID + ' }', success, error); return false; } See UserControls/Custom/Cccev/Web2/js/jquery-arena-promotions.js

Example Usage (cont.) from – UserControls/Custom/Cccev/Web2/js/jquery-arena-promotions.js function onLoadPromotionSuccess(result) { promotions = getPriorityFilteredPromotions(result.d); obj.empty(); $("#" + options.promotionTemplateID).render(promotions).appendTo(obj); obj.fadeIn('fast'); } See UserControls/Custom/Cccev/Web2/js/jquery-arena-promotions.js More about that “render” call later

Season To Taste Use a healthy amount of effects to: Let the user know something is happening Keep it looking fresh and light Use pinch of fadeOut() and a dash of fadeIn()

Demo

One more thing…

Event Pooling A cool and under utilized technique

Event Pooling A variation of the Observer pattern with jQuery acting as the middle man Allows you to create some interaction (loose dependency) between modules Subjects need not know Observers Uses jQuery “Trigger” and “Bind” Use your own custom event names We use $(document) because it’s a good global bucket that everything can access.

Trigger() For example, when someone updates their campus we trigger: $(document).trigger("CAMPUS_UPDATING");

Our Proposed Custom Events http://community. arenachms. com/Wiki/view CALENDAR_INFO_CHANGED : Triggered when calendar needs to be refreshed/rebuilt. CALENDAR_VIEW_CHANGED : Triggered when a calendar view has changed. CAMPUS_UPDATED :  Indicates that a person's selected campus has changed. CAMPUS_UPDATING : Indicates that a person's selected campus is being changed. CONTENT_RENDERED : Indicates that page content has changed and is ready for post processing.  For example, this event would typically be bound to a cufon type module that needs to update the font canvas. TOPICS_UPDATED : Indicates that a person's selected Topic Areas have changed. TOPICS_UPDATING : Indicates that a person's selected Topic Areas are being changed. USER_LOGGED_IN : Indicates that a person's has completed logging into the site.

Bind() If some module wants to do something when someone updates their campus, it can bind to that event: Here our customized news module fades its contents out it is also bound to the CAMPUS_UPDATED event // fade out the content area while the campus is updating. $(document).bind("CAMPUS_UPDATING", function () { obj.fadeTo( "fast" ); return false; });

Bind(multiple) Or respond to several events // show the news when any of this happens… $(document).bind("USER_LOGGED_IN CAMPUS_UPDATED TOPICS_UPDATED", function () { showNews(); });

Passing Data & Inspecting Trigger notice $(document).trigger(“CAMPUS_UPDATED", [data]); $(document).bind(“CALENDAR_INFO_CHANGED", function (e, data) { updateEventListView( e, data); }); $(document).bind(“USER_INFO_CHANGED", function (e, data) { function updateEventListView( e, params) { if ( e.type == “CALENDAR_INFO_CHANGED") postAsyncJson("webservices/custom/cccev/web2/eventsservice.asmx/GetEventList“, '{ "start":"' + params.start.toDateString() + '", "end":"' + params.end.toDateString() + …

References http://bit.ly/jQEventPooling (Event Pooling) http://api.jquery.com/trigger/ http://api.jquery.com/bind/ On the Community Wiki http://community.arenachms.com/Wiki/view.as px/Proposed_Core_Additions/JQuery_Event_Po oling