Avrom Roy-Faderman Senior Instructor and Programmer February 19, 2008 Whither Business Logic?

Slides:



Advertisements
Similar presentations
Apache Struts Technology
Advertisements

The Web Warrior Guide to Web Design Technologies
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Advantage Data Dictionary. agenda Creating and Managing Data Dictionaries –Tables, Indexes, Fields, and Triggers –Defining Referential Integrity –Defining.
Integrating SOA and the Application Development Framework Shaun O’Brien Principal Product Manager – Oracle JDeveloper / ADF.
Avrom Roy-Faderman Senior Instructor and Programmer May 15, 2008 The Evolving Web UI.
JavaScript Forms Form Validation Cookies CGI Programs.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
Web Servers How do our requests for resources on the Internet get handled? Can they be located anywhere? Global?
Introduction to Web Application Architectures Web Application Architectures 18 th March 2005 Bogdan L. Vrusias
Performed by:Gidi Getter Svetlana Klinovsky Supervised by:Viktor Kulikov 08/03/2009.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Course Textbook: Build Your Own ASP.Net Website: Chapter 2
UNIT-V The MVC architecture and Struts Framework.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
INTRODUCTION TO WEB DATABASE PROGRAMMING
1 INTRO TO BUSINESS COMPONENTS FOR JAVA (BC4J) Matt Fierst Computer Resource Team OracleWorld Session
JavaScript Form Validation
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
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
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Copyright  Oracle Corporation, All rights reserved. 5 CMIS Powell Oracle Designer: Design Editor and Building the Database and Table API CMIS.
Lecture 7 Interaction. Topics Implementing data flows An internet solution Transactions in MySQL 4-tier systems – business rule/presentation separation.
Advanced Web Forms with Databases Programming Right from the Start with Visual Basic.NET 1/e 13.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Design Patterns Phil Smith 28 th November Design Patterns There are many ways to produce content via Servlets and JSPs Understanding the good, the.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
® IBM Software Group © 2007 IBM Corporation J2EE Web Component Introduction
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
The Web Architecture and ASP.NET. Slide 2 Review of the Web (1) It began with HTTP and HTML, which delivers static Web pages to browsers which would render.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Chapter 4: Working with ASP.NET Server Controls OUTLINE  What ASP.NET Server Controls are  How the ASP.NET run time processes the server controls on.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
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.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
PostBack  When an initial request for a page (a Web Form) is received by ASP.NET, it locates and loads the requested Web Form (and if necessary compiles.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
 Project Team: Suzana Vaserman David Fleish Moran Zafir Tzvika Stein  Academic adviser: Dr. Mayer Goldberg  Technical adviser: Mr. Guy Wiener.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
Presented by Alexey Vedishchev Developing Web-applications with Grails framework American University of Nigeria, 2016 Intro To MVC Architecture.
Intro to JavaServer Faces Mimi Opkins CECS 493 Fall 2016.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Running a Forms Developer Application
Recipes for Use With Thin Clients
Web Technologies IT230 Dr Mohamed Habib.
MVC and other n-tier Architectures
Haritha Dasari Josue Balandrano Coronel -
Design and Maintenance of Web Applications in J2EE
Lecture 1: Multi-tier Architecture Overview
JavaServer Faces: The Fundamentals
Presentation transcript:

Avrom Roy-Faderman Senior Instructor and Programmer February 19, 2008 Whither Business Logic?

About Me Former member of Oracle JDeveloper/ADF teams Eight years’ experience with JDeveloper and ADF Co-author of JDeveloper Handbooks –9 i –10 g –11 g (coming soon)

Agenda The Options Business Logic in the Database Business Logic in the Middle Tier Business Logic on the Client Business Logic in Multiple Places Summary and Q&A

The Problem Implementing business logic for J2EE applications –Validation logic and calculation logic Business logic can be put multiple places Many people don’t know where to start –Often go by biases based on comfort level –Comfort level important but not everything

The Options The Database The Middle Tier –Model layer –Controller layer The Client

The Tradeoffs Comfort level Robustness and Security Responsiveness Server Load vs. Client Load Maintenance Effort

Agenda The Options Business Logic in the Database Business Logic in the Middle Tier Business Logic on the Client Business Logic in Multiple Places Summary and Q&A

Business Logic in the Database Intro PPR Integration with the Application To JDBC or not to JDBC?

The Database Implemented in constraints or triggers Runs in the database Language: PL/SQL –Or procedural language supported by other DB

The Database: Advantages Language: PL/SQL (?) Most robust and secure option Good for business logic relying on large amounts of data Easy maintenance and reuse

The Database: Problems Language: PL/SQL (?) Requires Internet round-trip –PPR may mitigate Requires posting of data Integrating with J2EE applications not trivial

Business Logic in the Database Intro PPR Integration with the Application To JDBC or not to JDBC?

PPR Short for “Partial Page Refresh” AJAX technology Reduces the time and interruption required by internet round-trips

Ordinary Form Cycle User clicks Submit button Form data sent to server Server validates/ calculates Server re- creates page Server sends page to browser Browser re-renders page User responds

PPR Cycle User uses a control Form data sent to server Server validates/ calculates Server re- creates some controls Server sends controls to browser Browser replaces controls in page User responds

PPR Limitations Still requires a round trip –Latency –Processing time on server Shouldn’t invoke PPR constantly

Business Logic in the Database Intro PPR Integration with the Application To JDBC or not to JDBC?

Integrating with Calculation Logic “Refresh on Insert” and “Refresh on Update” DBSequence Domain –Temporary sequence number –Always refreshes on insert –Watch out for foreign key relationships!

Integrating with Validation Logic ADF has no automatic way to integrate DB error messages in a user-friendly fashion Default way –Ugly –Possibly not secure Requires some changes to DB-side error messages for best results Requires Java Framework Code

Error Desiderata Cleanly displayed global error messages Linked and flagged field-specific error messages

DB-Side Error Message Changes Required for linking/flagging field-specific messages Need a machine-readable way to identify relevant columns [COMMISSION_PCT][JOB_ID]Commission must be zero for non-sales employees

Java Framework Custom entity object class –Override doDML() to catch SQLExceptions Custom code create exceptions –Parse error messages –Create exceptions based on them Custom exception class for column-level errors –Store error message –Store column information

Java Framework Custom exception class –Marshal the individual exceptions Custom error handler –Unmarshal the exceptions –Find controls corresponding to column information –Create appropriate FacesMessage objects

Business Logic in the Database Intro PPR Integration with the Application To JDBC or not to JDBC?

Does the Extra DB Hit Slow you Down? Yes, in general –DB connectivity is pretty fast, but in a large- scale application, any network hit hurts No, in some cases –Auto-commit requires DB hit after every request anyway –Consider delaying DB validation/recalculation to times when you already need to post

Agenda The Options Business Logic in the Database Business Logic in the Middle Tier Business Logic on the Client Business Logic in Multiple Places Summary and Q&A

Business Logic in the Middle Tier Intro Business Logic in the Model Business Logic in the Controller

The Middle Tier Implemented in the web application –Business components (model) –JSF Controller Runs on the application server Language: Java, with some declarative XML support

The Middle Tier: Advantages Language: Java (?) –Get to use JDeveloper’s great toolset Integration with ADF very easy Reasonably robust and secure Maintenance and reuse within an application easy No JDBC hits

The Middle Tier: Problems Language: Java (?) Not quite as robust as DB Questionable for business logic relying on large amounts of data Requires Internet round-trip –PPR may mitigate –Some special PPR problems Currently, maintaining across applications a bit of a pain –JDeveloper 11 g should mitigate this issue

Business Logic in the Middle Tier Intro Business Logic in the Model Business Logic in the Controller

Business Logic in the Model Traditional location for business logic in MVC architecture Most commonly ADF Business Components Some logic can be implemented declaratively More complex logic requires Java coding –JDeveloper 11 g will allow complex logic via “Groovy” expression language

PPR and the Model WARNING: By default, all application business logic will be executed on any form submission This includes PPR This may not be desired behavior Should be fixed in Jdeveloper 11 g

Stopping PPR Validation Custom page lifecycle Block validateModelUpdates() for PPR public void validateModelUpdates( LifecycleContext lctx) { FacesContext fctx = FacesContext.getCurrentInstance(); if (! PartialPageUtils.isPartialRequest(fctx)) { super.validateModelUpdates(lctx); } } Non-public API

Business Logic in the Middle Tier Intro Business Logic in the Model Business Logic in the Controller

Not traditional location in MVC architecture –But validators are part of JavaServer Faces standard Jdeveloper supplies default “ADF Faces Validators” –Ranges –Date/Time –Regular Expression Can write and register your own

PPR and the Controller All business logic will be executed on any form submission, including PPR This is not part of validateModelUpdates() and so cannot be blocked easily Can be useful –If you need some, but not all, validation to fire on PPR –Combine with (blocked on PPR) model validation

Agenda The Options Business Logic in the Database Business Logic in the Middle Tier Business Logic on the Client Business Logic in Multiple Places Summary and Q&A

Business Logic in the Client Tier Intro Client-Side Calculation Client-Side Validation Javascript and Data

The Client Tier Implemented in the web application Runs in the browser Language: Javascript

The Client Tier: Advantages Language: Javascript (?) Very high interactivity and responsiveness No network round trips of any kind Offloads processing to the client machine

The Client Tier: Problems Language: Javascript (?) –Poor development tools –At best so-so debugging tools Any moderately competent hacker can circumvent Bad for business rules relying on large amounts of data No easy way to share across applications

Business Logic in the Client Tier Intro Client-Side Calculation Client-Side Validation Javascript and Data

Javascript Handlers ADF Faces components include standard Javascript handlers, which show up in the generated HTML –onchange –onclick –onkeypress –etc. These can contain inline code or call Javascript functions

Know Your DOM “Domain Object Model” Allows you to easily work with any HTML element –Change element attributes or contained HTML –Find elements by ID, as opposed to “find a form and get its controls by name” method –This includes, e.g., links and tags generated by

Business Logic in the Client Tier Intro Client-Side Calculation Client-Side Validation Javascript and Data

Javascript Handlers and ADF Traditional validation with Javascript Handlers –Return “false” on failed validation –This blocks the normal operation of the component This is unreliable in ADF

Client-Side Validators ADF Faces validators come with “client side” version –This is a Java class that returns Javascript code from a method, getClientScript() –The Javascript is downloaded with the page You can create a client-side version of a custom validator These fire on submit, but instantly

Client-Side Validators and PPR Client-side validators will fire on PPR No way to turn this off without disabling client-side validation altogether Put completeness checks in the Javascript returned by getClientScript()

Business Logic in the Client Tier Intro Client-Side Calculation Client-Side Validation Javascript and Data

Javascript and Data: Static Assemble data on the server –Create Javascript arrays and tables –Or use objects to create hidden fields in the HTML Refer to it from your Javascript code Not appropriate for large amounts of data –May be mitigated for midsize amounts in 11 g

Javascript and Data: Dynamic Create a web service exposing your data Access the web service from the page using, e.g., SOAP A little faster than PPR –No reconstruction of components on server –Less data to transfer –Can be made asynchronous –Still has latency issues, though

Agenda The Options Business Logic in the Database Business Logic in the Middle Tier Business Logic on the Client Business Logic in Multiple Places Summary and Q&A

Dividing Business Logic “Break-your-business” logic must run server-side –Database for most security –In the application if security vs. saving Database access worthwhile Convenience-only logic can go in Javascript For highest interactivity, all logic should run in Javascript unless impractical

Maintenance: ADF Faces Validators For validation only Still need to be maintained in separate files –Files closely related –Usually one developer can be in charge of both You may not need PPR

Maintenance: Single-Sourcing Store Javascript in the DB Generate from declaratively expressed business rules –Triggers –Javascript A lot of trouble up front –Not easy to find engines that generate Javascript –Not worth it for a few mid-sized web applications

Agenda The Options Business Logic in the Database Business Logic in the Middle Tier Business Logic on the Client Business Logic in Multiple Places Summary and Q&A

Summary Using the DB is most secure –Integration not automatic –Lots of network trips; PPR may mitigate Using the middle tier almost as secure –May (or may not) save DB hits Using the client tier is most interactive –Not a secure method of enforcement Consider doubling up if you can solve the maintenance issues

Q&A

About Quovera Books co-authored with Peter Koletzke and Dr. Paul Dorsey ORACLE9i Jdeveloper Handbook Also co-authored with Duncan Mills Oracle Jdeveloper 10 g Handbook Oracle Jdeveloper 11 g Handbook Coming soon Founded in 1995 as Millennia Vision Corp. Strong High-Tech industry background 200+ clients/300+ projects Oracle Partner More technical white papers and presentations on the web site