Spring MVC. PA 165, Lecture 8. Martin Kuba

Similar documents
Fast Track to Spring 3 and Spring MVC / Web Flow

Call: JSP Spring Hibernate Webservice Course Content:35-40hours Course Outline

ADVANCED JAVA TRAINING IN BANGALORE

Introduction to Spring 5, Spring MVC and Spring REST

JVA-117A. Spring-MVC Web Applications

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module

Desarrollo de Aplicaciones Web Empresariales con Spring 4

Struts: Struts 1.x. Introduction. Enterprise Application

Introduction to Spring Framework: Hibernate, Spring MVC & REST

com Spring + Spring-MVC + Spring-Boot + Design Pattern + XML + JMS Hibernate + Struts + Web Services = 8000/-

All India Council For Research & Training

Index. Combined lifecycle strategy, annotation, 93 ContentNegotiatingViewResolver, 78

Introduction to Spring Framework: Hibernate, Web MVC & REST

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

Java J Course Outline

Java Training Center, Noida - Java Expert Program

Call: Core&Advanced Java Springframeworks Course Content:35-40hours Course Outline

COURSE DETAILS: CORE AND ADVANCE JAVA Core Java

Mastering Spring MVC 3

Session 25. Spring Controller. Reading & Reference

JVA-117E. Developing RESTful Services with Spring

Enterprise Java Development using JPA, Hibernate and Spring. Srini Penchikala Detroit JUG Developer Day Conference November 14, 2009

~$> whoami. Ioan Marius Curelariu SDE at Website Analytics Amazon Development Center Romania

Oracle Fusion Middleware 11g: Build Applications with ADF I

Spring MVC. Richard Paul Kiwiplan NZ Ltd 27 Mar 2009

Web Application Development Using Spring, Hibernate and JPA

Specialized - Mastering Spring 4.2

Full Stack Java Developer Course

Course Content for Java J2EE

Web Application Development Using Spring, Hibernate and JPA

ADVANCED JAVA COURSE CURRICULUM

Web Application Development Using Spring, Hibernate and JPA

Basics of Web Technologies

Oracle Fusion Middleware 11g: Build Applications with ADF I

Spring & Hibernate. Knowledge of database. And basic Knowledge of web application development. Module 1: Spring Basics

JAVA MICROSERVICES. Java Language Environment. Java Set Up. Java Fundamentals. Packages. Operations

Spring Persistence. with Hibernate PAUL TEPPER FISHER BRIAN D. MURPHY

Pro Spring MVC. Marten Deinum Koen Serneels. With Web Flow. Spring Web Flow project founder. Foreword by Erwin Vervaet,

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Spring Web Services Tutorial With Example In

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Developing Applications with Java EE 6 on WebLogic Server 12c

Creating RESTful web services with Spring Boot

LTBP INDUSTRIAL TRAINING INSTITUTE

Spring Interview Questions

Spring Professional v5.0 Exam

CORE JAVA 1. INTRODUCATION

Distributed Applications Spring MVC 2.5

JAVA. 1. Introduction to JAVA

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

/ / JAVA TRAINING

Java EE 6: Develop Web Applications with JSF

Oracle 10g: Build J2EE Applications

Standard Design Reference

Tools for Accessing REST APIs

Responsive Web Design (RWD)

LTBP INDUSTRIAL TRAINING INSTITUTE

> Dmitry Sklyut > Matt Swartley. Copyright 2005 Chariot Solutions

Spring boot multipart response

The World In. Advertising specs

Eclipse Scout. Release Notes. Scout Team. Version 7.0

Page 1

SPRING MOCK TEST SPRING MOCK TEST I

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1

Software Engineering a.a Unit Tests for SpringMVC Prof. Luca Mainetti University of Salento

Full Stack Web Developer

Complete Java Contents

JAVA SYLLABUS FOR 6 MONTHS

Improve and Expand JavaServer Faces Technology with JBoss Seam

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

THIS IS ONLY SAMPLE RESUME - DO NOT COPY AND PASTE INTO YOUR RESUME. WE ARE NOT RESPONSIBLE Name: xxxxxx

open source community experience distilled

Comprehensive AngularJS Programming (5 Days)

Overview of Web Application Development

ive JAVA EE C u r r i c u l u m

AGENDA. :: Add Meta Tag for Viewport (inside of head element): :: Add Script that renders HTML5 elements for older versions of Internet Explorer

Session 24. Spring Framework Introduction. Reading & Reference. dev.to/lechatthecat/how-to-use-spring-boot-java-web-framework-withintellij-idea-202p

Open Source Library Developer & IT Pro

Table of Contents. Introduction... xxi

JVA-563. Developing RESTful Services in Java

This course is intended for Java programmers who wish to write programs using many of the advanced Java features.

Implementing a Numerical Data Access Service

Selenium Testing Course Content

Java Advance Frameworks

AGENDA :: MULTIMEDIA TOOLS :: CLASS NOTES. INSTALLING FONTS :: Download, Install, & Embed Your Fonts. LECTURE :: Responsive Web Design [RWD]

Skyway Builder 6.3 Reference

Development Training. For Developer. 4 th May, AOT Intranet Web Portal

Specialized - Mastering JEE 7 Web Application Development

DVS WEB INFOTECH DEVELOPMENT TRAINING RESEARCH CENTER

Developing Spring based WebSphere Portal application using IBM Rational Application Developer

CMP 436/774. Introduction to Java Enterprise Edition. Java Enterprise Edition

MASTERS COURSE IN FULL STACK WEB APPLICATION DEVELOPMENT W W W. W E B S T A C K A C A D E M Y. C O M

Java EE 5 Development for WebSphere Application Server V7

Jquery Manually Set Checkbox Checked Or Not

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

AGENDA. DEX450: Programmatic Development Using Apex and Visualforce. Day One

Apple News Apple Advertising Platforms Specifications November 2017

EXAMGOOD QUESTION & ANSWER. Accurate study guides High passing rate! Exam Good provides update free of charge in one year!

1.9.7 Release Notes May 2014

Transcription:

Spring MVC PA 165, Lecture 8 Martin Kuba

Outline architecture of example eshop responsive web design Spring MVC initialization controllers redirects, flash attributes, messages forms and input data validation 2

Example eshop project Maven multiple module project project inheritance child projects inherit settings from specified parent groupid, project version, deps versions, props, plugins project aggregation project specifies its modules command in parent is done in all modules 3

eshop module dependencies 4

eshop modules eshop-spring-mvc eshop-sample-data facade interfaces, DTOs, enums, exceptions eshop-service some sample data (products, categories, users, orders) eshop-api web user interface implemented in SpringMVC, JSP, JSTL, Bootstrap facade implementations, service interfaces and implementations eshop-persistence entities, DAO interfaces and implementations custom JSR-303 annotations and validators 5

eshop layers 6

7

8

Business logic on service layer OrderService.shipOrder(Order o) OrderService.finishOrder(Order o) OrderService.cancelOrder(Order o) ProductService.changePrice(Product p, Price r) UserService.registerUser(User u, String psswd) UserService.authenticate(User u, String psswd) 9

eshop Architecture Summary separate layers for UI, API, services and persistence layers implemented in separate Maven modules Maven project using both project inheritance and aggregation kept in GitHub https://github.com/fi-muni/pa165 10

The problems of today's web design wide range of screen sizes from 3 phones to 30 desktop monitors wide range of pixel densities (80ppi 560ppi) touch screens do not have mouse over events devices change orientation (portrait / landscape ) 11

Responsive web design web design that adapts to screen size and pixel density CSS media queries @media screen and (min width: 400px){...} CSS pixels versus hardware pixels CSS pixels are 96ppi at 28 distance (1px=0.26mm) hardware pixels described in CSS by device-pixel-ratio device-pixel-ratio: 2 iphone4, ipad3 device-pixel-ratio: 3 - Galaxy S4, LG G3, HTC One device-pixel-ratio: 4 - Galaxy Note Edge, Xiaomi Mi3 images should be served in HW pixel resolutions 12

Bootstrap CSS framework for responsive web design navigation menu collapses on small screens 12-column grid for positioning 4 screen sizes: extra small, small, medium, large CSS classes for rows and columns 13

desktop 24 1920x1080 90ppi 14

tablet 10 1920x1200 224ppi 15

the same 10 in portrait mode 16

4.3 540x960 256ppi 17

Bootstrap additional features vector icons support for screen readers drop-down menus buttons and button groups badges alerts progress bars 18

Spring MVC one of many Spring libraries, optional model-view-controller architecture request-driven framework 19

SpringMVC initialization by hand: initialize a new DispatcherServlet instance with WebApplicationContext add the servlet instance to your web app automatically: extend AbstractAnnotationConfigDispatcherServletInitializer and implement its methods getrootconfigclasses() and getservletmappings() in both cases, provide a class annotated with @EnableWebMvc that configures SpringMVC a class annotated with @Configuration that configures Spring beans can be just a single class 20

SpringMVC configuration a class with @EnableWebMvc or XML based should provide: ViewResolver for resolving views, e.g. JSPs MessageSource for localized messages Validator for validating data in beans can enable default servlet for static files see MySpringMvcConfig in example eshop 21

Controllers 22

Controller any class annotated with @Controller mapping of methods to URLs is set by @RequestMapping, can have common prefix for the whole class dependencies are injected using @Autowired can return String, which is resolved by ViewResolver (provided by @EnableWebMvc) to view, usually a JSP page data are passed through instance of Model method parameters specify inputs automatic type conversion for request params and path 23

Controller method parameters 24

Redirect 25

Redirects triggered by return value starting with redir: RedirectAttributes attributes replace placeholders {attr} in URL @PathVariable parameters automatically added as attributes provide so called flash attributes, which exist only during the first next request more complex URL building possible using UriComponentsBuilder class redirect-after-post to avoid duplicate submissions 26

Product Controller 27

SpringMVC tag library for forms binds form fields to bean properties displays error messages when validation fails keeps values entered by user when validation fails 28

@Valid and BindingResult 29

Input data validation JSR-303 Bean validation provides annotations and validators for java bean properties Hibernate Validator is implementation of JSR-303 @NotNull, @Max, @Min, @Size, @Pattern,... a single definition of validation reused in various layers e.g. persistence and web forms you can define your own annotation and provide its validator and localized error messages example is @AllOrNothing and AllOrNothingValidator in eshop-persistence class with @EnableWebMvc has to provide Validator instance 30

Example of JSR-303 annotations 31

SpringMVC validation method marked with @InitBinder can add another validator implementing org.springframework.validation.validator instead of javax.validation.validator implements validate(object target, Errors errors) can do complex validation including checking relations among values of multiple properties ProductCreateDTOValidator class in example eshop 32

Summary controllers process HTTP requests send Model to views to display or send redirects (always after POST) flash attributes for passing data through redirects forms tag library helps in form handling request parameters may be bound to properties of a method parameter with @ModelAttribute JSR-303 Bean Validation and SpringMVC validation can be used together or separately 33

Thank you for you attention 34