ajaxifying legacy web applicationsdemo & code walk-thru > display results using ajax grid...

22
Ajaxifying Legacy Web Applications Anas Mughal Bluenog http://www.bluenog.com

Upload: others

Post on 27-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Ajaxifying Legacy Web Applications

Anas Mughal Bluenog http://www.bluenog.com

Page 2: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Topics

>  Overview: Legacy vs. RIA >  Design Approach >  Data Formats >  Tools >  Demo >  Ajaxifying Portal >  Portal Demo >  QA

Page 3: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Web 1.0 Applications

>  Pages are rendered server-side >  Client-side is stateless >  Server-side MVC >  Full-page refresh

Browser

Render Pages Existing View Rendering Framework

Server

HTML/Images/CSS

Get/Post Request

Page 4: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Ajax Applications

>  State-full client >  Server-side provides data services >  Client-side MVC framework >  No full-page refresh

Browser

Ajax Data Services

Server

XML/JSON

Page 5: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Suggested Approach (for Ajaxifying legacy Applications) >  Pages rendered server-side >  Keep Server-side MVC >  Add Ajax controls/grids/forms on client-side >  Add Ajax Data Services on server-side

Browser

Render Pages Existing View Rendering Framework

Server

HTML/Images/CSS

Get/Post Request

Data Exchange Ajax Data Services

Page 6: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Suggested Model

Client

Dynamic Page Render

Ajax Data Services

time

Page 7: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Design Approach

>  Incorporate Ajax data services layer >  Integrate Ajax layer with business delegates

Business Delegate DAO

View Render Services

Ajax Data Services

XML/JSON Over HTTP

HTTP/HTML

Page 8: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Data Formats >  JSON (JavaScript Object Notation)

  Native JavaScript structure.   Lightweight / compact   Retains type information

>  XML   Suited for data transformation needs.   Parsing is CPU intensive.   DOM may require large memory

on client-side.   Does not retain type information.

{"names": ["Anna Maria", "Maurice"], "count": 3 , "price", 4.75}

<xmldata> <names> <name>Anna Maria</name> <name>Fitzwilliam</name> <name>Maurice</name> </names> <count>3</count> <xmldata>

Page 9: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

JSON >  A collection of name/value pairs.

>  An ordered list of values.

Page 10: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

JSON Support on the Server-Side

>  Spring MVC Framework   Spring-json View (http://spring-json.sourceforge.net)

  Supports: SOJO and JSON-lib >  Struts Framework

  Struts JSON Plugin (http://tinyurl.com/b87ndu)   Serializes entire action class variables   Provides incoming request interceptor

>  Build your own   Convert data structures using a JSON library   Set content-type to “application/json”

Page 11: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Spring-JSON View

>  Include spring-json library >  Add view to Spring assembly

>  Assign json view in Controller:

11

public ModelAndView handleRequest(HttpServletRequest, HttpServletResponse) {

Map model = new HashMap(); model.put("claims", claimDelegate.findClaims()); return new ModelAndView("jsonView", model);

}

<bean name="jsonView“ class="org.springframework.w.servlet.view.json.JsonView"> <property name="jsonWriter"><ref bean="sojoJsonWriter"/></property>

… </bean>

Page 12: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Tools >  Server-side Serializers: (http://json.org)

  SOJO   json-lib

>  Formatter: jsonformatter.curiousconcept.com >  Visualizer: chris.photobooks.com/json/default.htm >  Validator: www.jsonlint.com , www.jslint.com >  Editor: jsoneditor.net >  Editor, Minifier, Tree View: jsoneditor.appspot.com >  Javascript Editor: SPKet Eclipse Plugin

Page 13: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

JS Loader

>  Consistent loading >  Easy patching of bugs >  Avoid duplicate loading of libraries

13

<script src="http://myserver/jsloader/jsloader.js"></script>

<script> JSLoader.load("extjs", "ext", "2.2.1-g"); JSLoader.load(“myLibs", "validation", "1.0");

<script>

Page 14: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Prerequisites

>  Clean your HTML -- HTML Validator >  Select appropriate JSON library: (http://json.org)

  SOJO, or   JSON-LIB

>  Select appropriate Ajax framework:   ExtJS   Yahoo UI   GWT

Page 15: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Demo & Code Walk-thru >  Display Results using Ajax Grid

(Data is embedded in HTML)

>  Grid Fetching Results Async (Results not embedded in HTML)

>  Ext Form and Fetching Grid Data Async (Async Results)

>  Grid Supporting Pagination and Sorting (Subset of data is fetched based on pagination and sorting)

>  Editable Grid

http://localhost:9090/ajax-demo1/

h"p://localhost:9090/ajax‐demo1/

Page 16: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Ajaxifying Portals

>  Layouts   Render using panels and layout managers

>  Portlets   Securing Ajax Communication   Inter-portlet Communication   JSLoader

16

Page 17: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Securing Portlet Ajax Communication

>  JSR 168 vs JSR 286

>  Jetspeed2 -- resourceURL

17

<portlet:renderURL var="resourceURL"> <portlet:param name="org.apache.jetspeed.portlet.resource.url" value="av"/> </portlet:renderURL>

Page 18: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Inter-portlet Communication

>  JavaScript framework-based eventing system >  Tibco PageBus

18

Page 19: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Portlet View Manager

>  Persist resourceURL for portlet >  Load and manage views >  Fetch views using Ajax >  History support

19

Page 20: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

View Manager Sequence Diagram

20

Page 21: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

Ajaxifying Portlets Demo

http://localhost:8480/bluenog

21

Page 22: Ajaxifying Legacy Web ApplicationsDemo & Code Walk-thru > Display Results using Ajax Grid (Data is embedded in HTML) > Grid Fetching Results Async (Results not embedded in HTML) >

22

Anas Mughal [email protected]

Bluenog