05 - MVC with Struts

05 - MVC with Struts - CSE 135 The MVC Design Pattern & The...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CSE 135 The MVC Design Pattern & The Struts Framework for every JSP page p for every type of request r to p insert in p code to implement the action requested by r Previous Attempts: Model 1 Design Pattern Messy JSP! students.jsp If request to insert student perform SQL INSERT If request to delete student perform SQL UPDATE If request to update student perform SQL DELETE 2 http://. ../students.jsp?action= insert &... HTML part of the JSP INSERT STUDENT UPDATE STUDENT DELETE STUDENT http://. ../students.jsp?action= update &... http://. ../students.jsp?action= delete &...
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 The MVC Design Pattern: Separating Model, View & Controller View Development “Best Practice” Control unit 2 Control unit 1 Controller Browsable Web/ multi-device applications Known well before web items – Smalltalk pioneered Model : Access to Underlying Databases and Info Sources 3 Databases Model Controller : Control Flow of Web App View : Look-and-Feel The MVC Design Pattern MVC originated as Model 2 in web developers community Model 1 : Application logic is attached to JSPs – Similar to previous attempts of students.jsp Model 2 : Data access and control flow decisions in Java Beans 4
Background image of page 2
3 Data Entry Example – MVC Attempt students.jsp HTML part of the JSP View INSERT STUDENT UPDATE STUDENT DELETE STUDENT Insert Student Update Student Delete Student Controller/Actions 5 DB Model Java classes export methods that encapsulate SQL access Model The Process and the Frictions Analysis/ Business Process Owner (Client) COMMUNICATION business process T get of Ph e 1 Specification Phase Development Phase Chief Architect/ Technical Project Leader business process and specification of Web application COMMUNICATION technical specification Target of Phase 1 Target of Phase 3 6 and development Developer Problem is even worse in evolution phase when application logic is hidden in thousands of lines of code
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Struts Black-Box Framework Implementing MVC – Framework: reusable “partial” application Struts ActionServlet provides high level control of workflow (i.e., “what happens next”) You provide Beans and files to customize framework according to your application needs 1. JSPs provide HTML presentation (View) 2. ActionForm Beans “collect” form data (Part of Controller) 7 3. Action Beans provide details of flow (Part of Controller) 4. struts-config.xml declares Beans and JSPs How To Develop Struts Applications From 10 Miles High: Pass high-level control to ActionServlet – By appropriate URL mapping in web.xml Design “workflow” in diagrams and then code it in struts-config.xml Develop ActionForm Beans responsible for collecting data Develop Action Beans responsible for changing 8 the state of the application and deciding next step Develop Model Beans (not part of Struts) responsible for encapsulating database access Develop HTML and JSP pages for user interface
Background image of page 4
5 View Struts application lifetime: How is a browser request processed?
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/31/2011 for the course CSE 135 taught by Professor Papakonstantinou during the Fall '10 term at UCSD.

Page1 / 21

05 - MVC with Struts - CSE 135 The MVC Design Pattern & The...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online