Developing AJAX Web applications with Castle Monorail David De Florinier Gojko Adzic Skills Matter 12/06/08.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Introduction to Ajax.
Advertisements

9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
Script# - the.NET response to Google Web Toolkit Gojko Adzic
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
Cloud Computing Lecture #7 Introduction to Ajax Jimmy Lin The iSchool University of Maryland Wednesday, October 15, 2008 This work is licensed under a.
Microsoft ASP.NET AJAX - AJAX as it has to be Presented by : Rana Vijayasimha Nalla CSCE Grad Student.
Fundamentals, DOM, Events, AJAX, UI Doncho Minkov Telerik Corporation
Agenda What is AJAX? What is jQuery? Demonstration/Tutorial Resources Q&A.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Ori Calvo, 2010 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
JavaScript & jQuery the missing manual Chapter 11
ASP.NET 5 Visual Studio 2015 Templates Bill Wolff Rob Keiser June 10, 2015.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Ajax Runtime Toolkits IBM Emerging Technologies. What is an AJAX Toolkit/Framework? An AJAX Toolkit/Runtime is more than just XMLHTTPRequest Should includes:
AJAX in ASP.NET James Crowley Developer Fusion
 2008 Pearson Education, Inc. All rights reserved Ajax-Enabled Rich Internet Applications.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Agile Web Development with the Castle Project 15/05/2008, Skills Matter Gojko Adzic
Sofia, Bulgaria | 9-10 October Asynchronous Programming for ASP.NET 2.0 Developers Julie Lerman The Data Farm Julie Lerman The Data Farm.
Power ASP.NET AJAX Programming. Agenda Partial-page rendering –With UpdatePanel –Without UpdatePanel PageRequestManager Drag-and-drop user interfaces.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
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:
Copyright 2007 Adobe Systems Incorporated. 1 ColdFusion 8 : Advanced AJAX Development Rakshith N Computer Scientist Jan 02, 2008.
Lecture 19 Web Application Frameworks Boriana Koleva Room: C54
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Introduction to Ajax.
Cross Site Integration “mashups” cross site scripting.
Effective Test Driven Database Development Gojko Adzic
Castle Manoj Waikar Pune, India.. Introduction Castle aspires to simplify the development of enterprise and web applications. It offers a set of tools.
Ventsislav Popov Crossroad Ltd.. 1. What is AJAX?  AJAX Concept  ASP.NET AJAX Framework 2. ASP.NET AJAX Server Controls  ScriptManager, UpdatePanel.
Telerik Software Academy ASP.NET Web Forms Telerik Software Academy ASP.NET Web Forms.
.  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.
Fundamentals, Ajax, Templates, UI Doncho Minkov Telerik Corporation
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
Dimiter Kunchev.  JavaScript library written by Sam Stephenson   Adds object oriented techniques  Provides.
Canopy walk through Single-Page Apps (SPAs) Benjamin Howarth Freelancer, Code Gecko Umbraco UK Festival, Fri 30 th Oct 2015 CODE GECKO.
Events & Callbacks (ESaaS §6.5) © 2013 Armando Fox & David Patterson, all rights reserved.
Ajax VS Flex A comparison based on shopping cart implementation PoHsu Yeh py2157.
Web Technologies Lecture 7 Synchronous vs. asynchronous.
Ajax and the GWT. Ajax  Asynchronous JavaScript And XML  Technology behind interactive web sites  Provide smoother experience than conventional web.
Presentation.
AJAX. Overview of Ajax Ajax is not an API or a programming language Ajax aims to provide more responsive web applications In normal request/response HTTP.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
AJAX in Ruby-on-Rails. Ruby on Rails and AJAX AJAX can be done with just Javascript Easier if you use libraries –Prototype –SAJAX –jQuery Libraries only.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
ASP.Net ICallback Vijayalakshmi G M Senior Trainer Binary Spectrum.
JQUERY AND AJAX
Section led by Ivan Lee Reachable at ivan period lee at cs period stanford period edu 1.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
JQuery, JSON, AJAX. AJAX: Async JavaScript & XML In traditional Web coding, to get information from a database or a file on the server –make an HTML form.
INNOV-16: Rich User Interface for the Web???? AJAX to the Rescue Ken Wilner VP of Technology Progress Software.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
Jim Fawcett CSE686 – Internet Programming Spring 2014
Jim Fawcett CSE686 – Internet Programming Spring 2012
Prototype.
Google Web Toolkit Tutorial
Play Framework: Introduction
AJAX and REST.
Fundamentals, DOM, Events, AJAX, UI
AJAX.
Angularjs Interview Questions and Answers By Hope Tutors.
AJAX Robin Burke ECT 360.
Web-Applications & AJAX
Chengyu Sun California State University, Los Angeles
Telerik Testing Framework
Presentation transcript:

Developing AJAX Web applications with Castle Monorail David De Florinier Gojko Adzic Skills Matter 12/06/08

Why Monorail for Ajax Apps? Plumbing handled by the framework Lots of helpers Integrated with Prototype and Scriptaculous Benefits from Castle Project integrations

Write AJAX apps without much more code than if you were writing a non-ajax one!

Options for AJAX with Monorail Preparing the application Proxying calls Monorail helpers and effects How it all comes together Some best practices and pitfalls

Option #1: Rails-style JS Generator Ajax actions send commands to the page Use NJS views instead of VM for Ajax Actions Mix and match Ajax and Non-Ajax calls Reuse partial templates

Option #2: Use Prototype and build parts of the page with actions Ajax actions build only parts of the page Use AjaxHelper to coordinate calls Coordinate page updates from the browser side Cleaner code on the server, more focused Option to use JSONHelper to render results Option to use controller proxies

Option #3: “Transparent” JSON controller binding Actions exported to the web page Coordinate rendering on the client Clean code, all plumbing done by MR Use JSonReturnBinder and JSonBinder... but not yet complete

Preparing the application for AJAX Add prototype.js library $AjaxHelper.GetJavascriptFunctions()‏... will render... <script type="text/javascript" src="/MonoRail/Files/AjaxScripts.rails"> Use Ajax.Request and Ajax.Updater

Use AjaxHelper to create elements $AjaxHelper.ButtonToRemote("Delete", "DeleteHero.rails", "%{ Complete='heroActionCallback(request)', with='\'id=${item.Id}\'' }")‏... will render... Methods provided for links, buttons, observers, autocompletion, forms

Use AjaxHelper to Build Forms $AjaxHelper.BuildFormRemoteTag("/Heroes/CreateHero.rails", "%{update='heroList',formid='heroForm', Complete='document.pageHelper.heroes.listRefreshe d();'}")‏... will render...

AjaxHelper parameters with form update success/failure evalScripts complete onSuccess/onFailure before/after/condition

Preparing controllers for AJAX Implemented as a method on the controller Tightly focused  Promotes reusability  Reduces risk due to change  Simplifies unit tests

Generating controller proxies Decorate methods with AjaxAction attribute [AjaxAction] public void DeleteHero(int id) {} Use AjaxHelper.GenerateJSProxy $AjaxHelper.GenerateJSProxy("controllerProxy")‏.. then the following is rendered var controllerProxy = { deleteHero: function(id, callback) { var r=new Ajax.Request('/Heroes/DeleteHero.rails', {method: 'get', asynchronous: !!callback, onComplete: callback, parameters: '_=\x26id='+id+''}); if(!callback) return r.transport.responseText; } };

Synchronous / asynchronous calls Proxies allow both synchronous and asynchronous calls to be made Supply a callback function to make asynchronous call function heroActionCallback(result) { var response = result.responseText.evalJSON(); alert(response.message); } function deleteHero(id) { controllerProxy.deleteHero( id, heroActionCallback); }

Synchronous / asynchronous calls Use synchronous calls ONLY if you don't want anything else to happen Prefer async calls for better performance Async replies can come in different order Number of simultaneous calls to the same domain is very limited

Monorail layout strategies Monorail has a concept of layouts AJAX actions would not have a layout ... but index method would There is more than one way to achieve this Two methods illustrated NJS templates don't use layouts (JS Generation)‏

AJAX layout strategy #1 No layout on the class Index method has a layout [Layout("default")] public void Index()‏ Simple, quick, no additional code ... but ties the action to blank layout for all calls

AJAX layout strategy #2 Use filter to kill layout on AJAX calls public class AjaxLayoutFilter : IFilter { public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if(IsAjaxRequest(context)) controller.CancelLayout(); return true; } //from public static bool IsAjaxRequest(IRailsEngineContext context) { string requestedWith = context.Request.Headers["X-Requested-With"]; if (string.IsNullOrEmpty(requestedWith)) return false; return requestedWith.Equals("XMLHttpRequest",StringComparison.InvariantCultureIgnoreCase); }

Script.aculo.us integration A JavaScript framework which is for UI sugar. Install scripts using $ScriptaculousHelper.InstallScripts()‏ Add effects using the ScriptaculousHelper VisualEffect method $ScriptaculousHelper.VisualEffect('ToggleBlind', 'colOne')‏ $ScriptaculousHelper.VisualEffect('ToggleAppear', 'colThree')‏ $ScriptaculousHelper.VisualEffect('ToggleBlind', 'colTwo')‏

Script.aculo.us Drag & Drop Make elements draggable new Draggable(element, {revert:true}); Make elements Drop zones Droppables.add( element, {hoverclass: 'dropHover', accept: 'dropelementclassname', onDrop: dropPower} ); Drop delegate accepts both elements as parameters function dropPower(draggable,droparea)

Stuff to remember JSON binding will probably be complete soon Use $context for generic shared templates Use $AjaxHelper for Prototype integration Use $ScriptaculousHelper for effects You can use Prototype and Scriptaculous in JS code directly Use async calls for better performance

... a few links

What next? Beers – straight away ALT.NET meeting next week TDD with Databases in two weeks ALT.NET talk at Skills Matter on July 31 st