As we rewrite the UI, we have a one-time opportunity to pick a new web framework All options are on the table Criteria  Plug in our existing Java API.

Slides:



Advertisements
Similar presentations
Apache Struts Technology
Advertisements

A Blackboard Building Block™ Crash Course for Web Developers
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Ruby on Rails Model of MVC. Model-View-Controller Paradigm A way of organizing a software system Benefits: Isolation of business logic from the user interface.
1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
June 28 th – July 1 st 2006 Implementing Usability: Insights to improve your chances  CFUnited 2007.
Web Applications Development Using Coldbox Platform Eddie Johnston.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Introduction to Model-View-Controller (MVC) Web Programming with TurboGears Leif Oppermann,
1 GWT Google Web Toolkit Build AJAX apps in the Java language
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
Groovy & Grails Jean Barmash CTO, EnergyScoreCards.com
UNIT4 BUSINESS ANALYTICS. page WHAT IS THE PRODUCT? 2 A business intelligence tool kit, specializing in Coporate Performance Management An application.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
Spring Roo CS476 Aleksey Bukin Peter Lew. What is Roo? Productivity tool Allows for easy creation of Enterprise Java applications Runs alongside existing.
Ruby on Rails. What is Ruby on Rails? Ruby on Rails is an open source full-stack web framework. It is an alternative to PHP/MySQL. It can render templates,
JavaServer Faces: The Fundamentals Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator; IBM RAD)
11. Java-Based Web: JSP, JSF. 2 Motto: Rule 1: Our client is always right Rule 2: If you think our client is wrong, see Rule 1. - Anonymous.
Groovy WHAT IS IT? HOW DOES IT WORK? IS IT USEFUL?
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
AJAX Chat Analysis and Design Rui Zhao CS SPG UCCS.
1 Web GIS: from Javascript to GWT Pieter De Graef – Community Manager & Lead Developer Geomajas.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
JSP Java Server Pages Softsmith Infotech.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Lecture 19 Web Application Frameworks Boriana Koleva Room: C54
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
JavaScript Framework for Rich Apps in Every Browser Maura Wilder Joan Wortman
Presentation. Recap A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate. Taken advantage of Spring’s multi layer.
Peter Laird. | 1 Building Dynamic Google Gadgets in Java Peter Laird Managing Architect WebLogic Portal BEA Systems.
Introduction to Web Dimitar Nenchev Ivan Nakov
© 2006 IBM Corporation Agile Planning Web UI. © 2006 IBM Corporation Agenda  Overview of APT Web UI  Current Issues  Required Infrastructure  API.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
.  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.
JavaScript Framework for Rich Apps in Every Browser Maura Wilder Joan Wortman
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Katari Globant 2008 (update to 2010). Katari  Katari is a framework to use as a starting point to develop new web applications.  Incorporates architecture,
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Presentation.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
Presentation Title Subtitle DSpace UI Prototype 7 Spring, Angular.js, and the DSpace REST API.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Prof. James A. Landay University of Washington Spring 2008 Web Interface Design, Prototyping, and Implementation Rich Internet Applications: AJAX, Server.
This material is based upon work supported by the U.S. Department of Energy Office of Science under Cooperative Agreement DE-SC Michigan State.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
Google Web Toolkit for Mobile Applications Development INGENUITY AT ITS BEST……………….
1 Rails for the Ruby-Impaired John Paul Ashenfelter CTO/Transitionpoint.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Comparative Display Technologies.
Technologies For Creating Rich Internet Applications Presenter's name
CodeBeamer Bootcamp 2007 Customizing CodeBeamer features through scripting Aron Gombas Architect, Intland.
J2EE vs Python for web development David
The CareWeb Framework Douglas K. Martin, MD
Google Web Toolkit Tutorial
Ruby Tooling in NetBeans
Haritha Dasari Josue Balandrano Coronel -
Pentaho and Yahoo User Interface (YUI)
Sakai WebApp Structure
Top Reasons to Choose Angular. Angular is well known for developing robust and adaptable Single Page Applications (SPA). The Application structure is.
Modern web applications
Lecture 1: Multi-tier Architecture Overview
JavaServer Faces: The Fundamentals
Presentation transcript:

As we rewrite the UI, we have a one-time opportunity to pick a new web framework All options are on the table Criteria  Plug in our existing Java API  Support extensions via modules  Allow us to build reusable components  Easy! Fun! Beautiful!  Accessible to entry-level coders  Well-supported

Spring 3 Spring MVC + JQuery + roll-our-own widgets Spring MVC + JQuery + StringTemplate JSF + ICEFaces Ruby on Rails (via JRuby) JQuery Grails YUI JQuery GXT

 “the leading platform to build and run enterprise Java applications. Led and sustained by SpringSource, Spring delivers significant benefits for many projects, increasing development productivity and runtime performance while improving test coverage and application quality”  Why? ◦ We use it, we like it ◦ Extremely flexible ◦ Heavily used, and getting better all the time

 frameworks/spring3mvc+jquery frameworks/spring3mvc+jquery ◦ Thanks Harsha!  The modern version of what we're doing now  Maven! Jetty!  Spring 3 MVC has lots of timesaving features we haven’t taken advantage of  Jquery is powerful and we haven't taken advantage  Consciously build reusable UI widgets

@Controller public class PatientController method=RequestMethod.GET) public String Patient patient, Model model) { model.addAttribute(patient); if (patient != null) model.addAttribute("encounters", Context.getEncounterService().getEncountersByPatient(patient)); } $(function() { $('#tabs').tabs(); });... Patient Encounters... Patient Encounters <openmrs:encounters encounterList="${encounters}"/>... $(document).ready(function() { $('#encounters').dataTable(); }); Encounter Id Encounter Date Encounter Patient ${encounter.encounterId} ${encounter.encounterDatetime} ${encounter.patientId}

 Pros: ◦ Flexibility (never “not be able to do” something) ◦ Strong community ◦ Configured right, it allows RAD ◦ No learning curve for existing devs  Cons: ◦ Significant learning curve for newbies (lots of technologies, and they are not simplified)  Open questions: ◦ Can we leverage Hibernate annotations?

 ◦ -Thanks Thoughtworks!  “[StringTemplate's] distinguishing characteristic is that it strictly enforces model-view separation unlike other engines. Strict separation makes websites and code generators more flexible and maintainable.”  Controllers like you're used  StringTemplate instead of JSP  Recommended by Thoughtworks developers  Templates allow for page layouts and reusable components

layout/layout.st Patient Dashboard $partials/header()$ $body$ $partials/footer()$ patientdashboard.st Patient Encounters $menuext:{item| $item$ }$... $widgets/encounters(encounters=patient.encounters)$... widgets/encounters.st $if(encounters)$ jQuery(function() { jQuery('#encounters').dataTable(); }); Date Location Type Provider $encounters:{ encounter | $encounter.encounterDatetime$ $encounter.location.name$ $encounter.encounterType.name$ $encounter.provider.givenName$ }$ $else$ There are currently no encounters $endif$

 Pros: ◦ Strict Model-View separation will make us program better  Cons: ◦ Unclear whether this approach has significant advantages over more-commonly-used technologies  Open Questions: ◦ When a module attaches to an extension point, that now becomes view-only, and can’t add any data to the model. Right?

 ◦ Thanks Shazin! (ICEFaces 1.8, JSF 1.2, no Spring) ◦ JSF 2 with Spring in progress  JSF: Developed through the Java Community Process under JSR - 314, JavaServer Faces technology establishes the standard for building server-side user interfaces. With the contributions of the expert group, the JavaServer Faces APIs are being designed so that they can be leveraged by tools that will make web application development even easier  ICEFaces: J2EE Ajax framework for developing and deploying rich enterprise applications (REAs). With ICEfaces, enterprise Java developers can easily develop rich enterprise applications in Java, not JavaScript  JSF instead of Spring MVC ◦ Component-based ◦ Server-side state, stored in the session  Facelets instead of JSP  No Javascript required! JSF automatically reloads page fragments as required

// JSF 1.2 with XML-defined beans public class TableBean implements PageBean { private List headers; private List body; public List getBody() { return body; } public void setBody(List body) { this.body = body; } public List getHeaders() { return headers; } public void setHeaders(List headers) { this.headers = headers; } // JSF 2.0 with public class HelloWorldBean { public String getMessage() { return "Hello World!"; } public User getAuthenticatedUser() { return Context.getAuthenticatedUser(); }

 Pros: ◦ JSF is the J2EE 6 Standard ◦ ICEFaces looks good  Cons: ◦ Steep learning curve ◦ Poor RAD (editing a single server-side component requires restarting Jetty)  Open Questions: ◦ How will module extensions work in a component- based framework?

 frameworks/jruby+rails+jquery/  “Ruby on Rails is an open-source web framework that’s optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration”  “A domain-specific-language for database- backed web applications”  Thoughtworks CTO recommends Java backends with RoR-via-JRuby front-ends

class PatientController < ApplicationController def = Context.patientService.getPatient(params[:id].to_i) puts "No patient found!" raise "No patient found!" = # record that this user viewed this patient end def find ret = []; $omrs.patient_service.getPatients(params[:query]).each do |patient| ret << helpers.convert_to_dto(patient) end render :json => ret end end Conventions for project layout app controllers helpers models views layouts (controller) (action) config environments initializers locales public images javascripts stylesheets $(document).ready(function() { $("#tabs").tabs(); }); - … "widgets/encounter_list", :locals => { :encounters } %>

 ActiveRecord and Migrations make it very easy to create (application-level) database-backed functionality  jruby script/generate model PatientViewed user_id:int patient_id:int This migration is automatically created class CreatePatientVieweds < ActiveRecord::Migration def self.up create_table :patient_vieweds do |t| t.integer :user_id t.integer :patient_id t.timestamps end def self.down drop_table :patient_vieweds end The “domain object” doesn’t declare any properties, because those are implied by the database table class PatientViewed < ActiveRecord::Base # get recent PatientVieweds for the given user def self.recently_viewed(user_id, n=5) all(:conditions => ["user_id = ?", user_id], :order => "created_at DESC", :limit => n ) end # get ids of patients recently viewed by the current user def self.recently_viewed_ids(user_id, n=5) recently_viewed(user_id, n).collect { |pv| pv.patient_id } end # record that a User viewed a Patient def self.record_view(openmrsuser, openmrspatient) destroy_all({ :user_id => openmrsuser.user_id, :patient_id => openmrspatient.patient_id }) create({ :user_id => openmrsuser.user_id, :patient_id => openmrspatient.patient_id }) end end

 Pros: ◦ It’s Fun! ◦ Excellent RAD  Mongrel + Rails seems to be better than Jetty +Spring for this  ActiveRecord and migrations  Cons: ◦ Rails session != Java session => need to write our own session management ◦ No idea of Services  Domain objects are supposed to be intelligent  Wouldn’t be able to use the full power of the framework, because of our dumb domain objects. ◦ Potential for some annoying incompatibility to hit us out of the blue  Open Questions: ◦ How would module extensions work? Would an omod contain Java code *and* Ruby code? (Yuck.) ◦ How would Ruby migrations work with Liquibase? ◦ How good is Eclipse integration?

From views/widgets/_patient_search.html.erb... var options = { clickUrl: function(rowNum, item) { return "/patient/view/" + item.patient_id; }, icon: function(rowNum, item) { return ' '; }, … }; $(document).ready(function() { $('# _form').submit(function() { $.getJSON(" ", { query: $('# _query').val() }, _results_results_callback(options) ); return false; }) }); _form"> ID or Name: _query" type="text"/> _button"/> "widgets/vertical_panel", :locals => { :id => "#{id}_results", :options => patient_search_opts } %>

 “GRAILS: the search is over… Have your next Web 2.0 project done in weeks instead of months. Grails delivers a new age of Java web application productivity.”  Attempts to replicate the magic of RoR in the Java world (used to be called “Groovy on Rails” until RoR asked them to stop) ◦ Uses Spring, Hibernate, SiteMesh, Jetty, …  Groovy ◦ Java + dynamic typing + closures + compiler magic ◦ 99.9% of legal Java is legal Groovy def results = Context.patientService.getPatients(“darius”).collect { [ ptId: it.patientId, name: it.personName.toString() ] }

 class PatientController { def view = { def p = Context.patientService.getPatient(params.int['patientId']); [ patient: p, encounters: Context.encounterService.getEncountersByPatient(p) ] } def searchJson = { List pats = Context.getPatientService().getPatients(params['query']); def output = pats.collect { [ patientId: it.patientId, age: it.age, gender: it.gender, name: it.personName.toString() ] } render output as JSON } class OpenmrsTagLib { static namespace = 'openmrs' def format = { attrs -> def obj = attrs['object'] f (obj != null) { if (obj instanceof User) { out << "${obj.username} (${formatName(obj.person)})“ } else { out << "${obj} (don't know how to handle ${obj.class})" } String ajaxSearchHelper(Map attrs) { … return """ ${createDecoratorIfNecessary} \$(document).ready(function() { \$("#${id}_form").submit(function() { … """ }

 ◦ Thanks Harsha! … Patient Encounters <gui:dataTable draggableColumns="true“ columnDefs="[ [date:'Date', sortable:true, resizeable: true], [location:'Location', sortable:true, resizeable: true], [type:'Type', sortable:true, resizeable: true], [provider:'Provider', sortable:true, resizeable: true]]“ sortedBy='date‘ controller="patient” action="patientEncounters“ params="[id:'${model.id}']" caption="click on a row, and it will expand" paginate="true" rowExpansion="false" rowsPerPage="20" totalRecordsKey="meTotalRecs" /> <openmrs:extensionPoint pointId="org.openmrs.patientDashboardTab" type="html"> … … Find a patient ID or Name: … It’s unlikely that we’d choose YUI over Jquery, even if it does come in the Grails-UI plugin…

 Pros: ◦ It’s Fun! ◦ Almost no learning curve for current developers ◦ RAD almost as good as in Rails  GORM (analog of ActiveRecord)  Jetty (needs to restart more often than Mongrel) ◦ Sitemesh handles page templates ◦ Auto-recompiling groovy taglibs are great for pulling repeated code out of pages  Cons: ◦ Small community, possible lack of future support ◦ IDE integration is surprisingly mediocre ◦ A couple times I’ve read: “we lost almost all the productivity gains Grails gave us because of undocumented bugs in Grails”. (Personally Google searching has found me answers for all errors I’ve searched for.)  Open Questions: ◦ Can we use the embedded database to allow you to develop without even having a MySQL database? ◦ Is Spring Roo worth looking into as an alternative?

 -Thanks Sy!  GWT is a development toolkit for building and optimizing complex browser-based applications  Ext JS is a cross-browser JavaScript library for building rich internet applications. Ext JS features high performance, customizable UI widgets and a well-designed and extensible component model.  => Ext GWT is a Java library for building rich internet applications with Google Web Toolkit (GWT)  You only write Java! GWT produces HTML, Javascript, AJAX, …  “Rich Internet Application” instead of “a webapp”

DTOs, for sending data between client and server package web.openmrs.common; … public class EncounterDTO implements Serializable { private Integer id; private Date date; private String location; private String type; private String provider; private List obs; … } Client UI code looks like a Swing app public class MainContent extends LayoutContainer { … public void openPatientDashboard(PatientDTO patient) { removeAll(); add(new PatientDashboard(patient)); layout(); } public class PatientDashboard extends LayoutContainer { protected void onRender(Element parent, int pos) { super.onRender(parent, pos); setLayout(new RowLayout(Orientation.VERTICAL)); … TabItem demographics = new TabItem("Demographics"); demographics.add(createDemographicsForm()); TabItem encounters = new TabItem("Encounters"); encounters.add(new PatientEncounterPanel2(patient)); tabs = new TabPanel(); tabs.add(demographics); tabs.add(encounters); … } You need lots of (formulaic) classes: (client) interface PatientService interface PatientServiceAsync (common) class PatientDTO (server) class PatientServiceImpl

 This would be a completely different sort of application

 Pros: ◦ No HTML or Javascript! ◦ “Since this is Java, the API and JavaDocs are available in the IDE as context sensitive help and the source code is available to look at instead of referring to (outdated) webpages, also has a large library of examples and showcase”  Cons: ◦ Have to build a set of DTOs and services specifically for GWT ◦ Steep(?) learning curve for existing and newbie devs ◦ “the initial load to the client's browser is fairly large but a good framework for loading is in place. the plus side to this is once it is loaded, the page never has to be loaded again so page loads do not exist, only data calls (reducing input/output over the wire as well as server load)”  Open Questions: ◦ Could modules plug in, given the client-server architecture?

Spring3-JSPSpring3- StringTemplate Spring3-JSF- ICEFaces JRuby-RailsGrailsGXT Learning curve (new dev) Medium HighLow High? Learning curve (existing dev) NoneLowHighLowTrivialHigh? OpenMRS Modules Easy??? Easy??? Embedded webserver Good (Jetty) OK (Jetty)Excellent (Mongrel) Good (Jetty)Good Embedded DB in dev mode ??? RAD domain objects ??? (Hibernate annotations?) ???Yes (ActiveRecord) Yes (GORM)No? LayoutsNeed to integrate something YesN/A?YesYes (Sitemesh)N/A Built-in Widgets None ICEFacesWon’t use EXT Tech for widgets Roll our ownStringTemplateJSFPartials, helpers Taglibs, templates “tight and extensible” Eclipse integration Good ?????? (RadRails)Mediocre (Spring plugin) Excellent (Google plugin) CommunityLargeLarge*LargeLarge*Small ConcernsNo ServicesModules may be impossible

 More review of JSF 2 + ICEFaces 2  Is GXT even an option? ◦ Can it support modules?  Can we use an embedded DB in development mode with any of these technologies?  Can Hibernate Annotations provide some of the functionality of ActiveRecord/GORM in Spring-3-based technologies?  JSR-286 Portlets