MODEL VIEW CONTROLLER PATTERN. Model View Controller MVC is a time tested method of separating the user interface of an application from its Domain Logic.

Slides:



Advertisements
Similar presentations
3 Copyright © 2005, Oracle. All rights reserved. Designing J2EE Applications.
Advertisements

Apache Struts Technology
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
14-May-15 An Example Servlet Putting it all together.
9.5 Software Architecture
Introduction to Java 2 Enterprise Edition About myself –Neutrinos, Cancer Research, IT Applications Today’s topic: J2EE –Context –Advantages –Components.
Model-View-Controller ("MVC") This is a architectural design pattern for interactive applications. This design pattern organizes an interactive application.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Layers & Tiers Umair Javed Lec - 41.
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
Introduction to Servlet & JSP
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
14-Jul-15 Tomcat. 2 The Apache Jakarta Project The Apache Jakarta Project “creates and maintains open source solutions on the Java platform for distribution.
Apache Struts Technology A MVC Framework for Java Web Applications.
Overview of Design Patterns & The MVC Design Pattern Sapana Mehta.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
UNIT-V The MVC architecture and Struts Framework.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
MVC pattern and implementation in java
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Model View Controller (MVC) Rick Mercer with a wide variety of others 1.
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
Introduction to J2EE Architecture Portions by Kunal Mehta.
JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
J2EE Structure & Definitions Catie Welsh CSE 432
® IBM Software Group © 2007 IBM Corporation J2EE Web Component Introduction
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
Copyright, 1996 © Dale Carnegie & Associates, Inc. Presented by Hsiuling Hsieh Christine Liu.
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Java Servlets & Java Server Pages Lecture July 2013.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
CSC 2720 Building Web Applications Frameworks for Building Web Applications.
Model View Controller Architecture of Java Web Applications Dr. M V S Peri Sastry, Ph.D.[BITS-Pilani]
Model View Controller MVC Web Software Architecture.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
MVC WITH CODEIGNITER Presented By Bhanu Priya.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
1 Distributed System using J2EE. 2 What is J2EE?  J2EE (Java2 Enterprise Edition) offers a suite of software specification to design, develop, assemble.
Java Servlets and Java Server Pages
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Apache Struts Technology A MVC Framework for Java Web Applications.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
J2EE Platform Overview (Application Architecture)
CS122B: Projects in Databases and Web Applications Spring 2017
Introduction to Servlets
CS122B: Projects in Databases and Web Applications Winter 2017
Design Patterns Source: “Design Patterns”, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides And Created.
Web Development Web Servers.
Java Servlets By: Tejashri Udavant..
MVC and other n-tier Architectures
Web Software Model CS 4640 Programming Languages for Web Applications
Introduction to J2EE Architecture
Design and Maintenance of Web Applications in J2EE
Model-View-Controller Patterns and Frameworks
CS122B: Projects in Databases and Web Applications Winter 2018
Distributed System Using Java 2 Enterprise Edition (J2EE)
Lecture 1: Multi-tier Architecture Overview
CS122B: Projects in Databases and Web Applications Spring 2018
Objectives In this lesson you will learn about: Need for servlets
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
J2EE Lecture 1:Servlet and JSP
CS122B: Projects in Databases and Web Applications Winter 2019
Web Servers (IIS and Apache)
Presentation transcript:

MODEL VIEW CONTROLLER PATTERN

Model View Controller MVC is a time tested method of separating the user interface of an application from its Domain Logic. Domain Logic The primary goal of MVC is to isolate UI changes and prevent them from requiring changes to the Domain Logic of the application.Domain Logic MVC divides an application into three concerns: Model - Encapsulates core application data and functionality Domain Logic. Domain Logic View - obtains data from the model and presents it to the user. Controller - receives and translates input to requests on the model or the view.

MVC A model: An object that stores data that often pertains to real world responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). A view: Some form of visualization of the state of the model. A controller: Offers facilities using which the user can change the state of the model. clicking on buttons, sliding a slider, typing in a text box, etc.

MVC – What Is the problem? The same enterprise data needs to be accessed when presented in different views: e.g. HTML, JFC/swing, XML The same enterprise data needs to be updated through different interactions Supporting multiple types of views and interactions should not impact the components that provide the core functionality of the enterprise application

MVC – Solution Separate core business model functionality from the presentation and control logic that uses this functionality Allows multiple views to share the same enterprise data model Makes supporting multiple clients easier to implement, test, and maintain

Example MVC a b c a b c Views Controller Model abc a = 50% b = 30% c = 20% See Interact

A spinner

Architecture Diagram View model representation Model business logic Controller user interaction UpdateEvent User Actions Change View SetState Get State

MVC – Responsibilities Model - the model represents enterprise data and the business rules that govern access to and updates of this data View -the view renders the contents of a model. It accesses enterprise data through the model and specifies how that data should be presented Controller - the controller translates interactions with the view into actions to be performed by the model

Design Patterns MVC – Class Diagram

Design Patterns MVC – Class Diagram controller view model

Behavior of the passive model

Behavior of the active model

A simple example

Another example

HTML form page Coffee Advisor> Coffee Advisor Select coffee Type: Milky Froffy Icey Spaced Out

Web.xml Coffee com.example.web.CoffeeSelect Coffee /SelectCoffee.do

Model class package com.example.model; import java.util.*; public class CoffeeExpert { public List getTypes(String type) { List types = new ArrayList(); if (type.equals("milky")) { types.add("latte"); types.add("cappuccino"); } else if (type.equals("froffy")) { types.add("latte"); types.add("cappuccino"); types.add("frappuccino"); }

else if (type.equals("icey")) { types.add("frappuccino"); } else if (type.equals("strong")) { types.add("espresso"); types.add("double espresso"); } else { types.add("Vending Machine"); } return(types); } }

Servlet controller public class CoffeeSelect extends HttpServlet { public void doPost( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String c = request.getParameter("type"); // Now use our Coffee Model above CoffeeExpert ce = new CoffeeExpert(); List result = ce.getTypes(c); request.setAttribute("styles", result); RequestDispatcher view = request.getRequestDispatcher("result.jsp"); view.forward(request, response); } }

JSP view # Create the result.jsp file below Coffee Recommandation JSP View try: " + it.next()); } %>

J2EE Architechture Web tierEJB tierEIS tierClient tier

Client Tier The Client tier is the part the application that the user sees and interacts. The Client tier is responsible for: Presenting data to the user, interacting with the user Communicating with other tiers of the application using well-defined interfaces. A separate Client tier in the design provides flexibility and extensibility. Future new clients can be written using technologies or languages that do not yet even exist, since they must conform only to the interface for communicating with other tiers

Web Tier The Web tier is responsible for performing all Web-related processing, such as: serving HTML, formatting JSP pages for display by browsers. managing database connections.

EJB Tier Enterprise JavaBeans are components: Extend servers to perform application-specific functionality. hosts application-specific business logic and provides system-level services such as transaction management, concurrency control, and security. The interface between these components and their containers: Defined in the EJBs specification. Essentially, the EJBs tier provides a component model for access to distributed system services and persistent data.

Enterprise Information System (EIS) Tier The EIS tier is the enterprise information infrastructure. To ensure that data are consistent across application boundaries. Access to the EIS tier is usually transactional. Enterprise information systems provide the information infrastructure critical to the business processes of an enterprise. Examples of EISs include relational databases, enterprise resource planning (ERP) systems, mainframe transaction processing systems The EIS tier enforces security.

J2EE MVC Pattern Http request or post Response Forward Dispatch Update Extract Client browser Controller (action servlet) Business logic Model (server side JavaBean/EJB) View (JSP page)

MVC Structure for J2EE

Advantages of MVC pattern Separates Model from View: Implies separating internal data representation from presentation Easy to add multiple presentations of the same data Facilitates adding new types of presentation of data as per requirement. Model and View components can vary independently enhancing maintainability, extensibility, and testability.

Sapana Mehta (CS-6V81) Advantages of MVC design Pattern Separating Controller from View Permits run-time selection of an appropriate View based on user preference, or model state. Separating Controller from Model Allows configurable mapping of user actions on the Controller to application functions on the Model.

Drawbacks of the model Increased complexity Close coupling of views and controller to model Potential for excessive updates Close coupling between view and controller

THANK YOU..