MVC 1.0 Manfred Riem Oracle Geertjan Wielenga Oracle Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. M
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda MVC MVC 1.0 JSR Some examples MVC tooling Questions and Answers E
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | What is MVC? MVC is a pattern used to implement a user interface (UI). It consists of 3 major components – Model (M) – View (V) – Controller (C) Each of the components has a distinct responsibility which is covered in the next slides
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The M(odel) in MVC The model is the interim state you want to keep when you are building an application that shows a user interface Examples – Who is logged in – What are they trying to buy – What page are they on in a multi page flow
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The V(iew) in MVC The view is what your user interacts with – In a web application that would be the web page or web pages your JSP page your CSS styles your JavaScript – In a thick client scenario it would be the entire UI – In an embedded scenario it could be the touch screen, hardware buttons etc.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The C(ontroller) in MVC The controller is the work horse of the pattern, as it: – Executes the business logic Run a credit card transaction – Updates the model Mark the transaction as successful in the model object – Ask the view to render itself Shows the transaction was successful
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Different styles of MVC Component-based MVC Action-based MVC Other styles
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Component-based MVC A specific style of MVC made popular by component frameworks Controller provided by the framework Some examples – Java Server Faces (in the JavaEE platform) – Seam (discontinued) – Wicket – Tapestry – Apache Click (retired)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Action-based MVC Controller(s) defined by the application Currently no JavaEE implementation – Good news we are creating one! Some examples – Struts 1 (end of life) – Struts 2 – Spring MVC
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Action-based MVC – Manual request parameter processing – No view kept around – Limited support for re-usable behavior – Developer responsible for all HTML / JavaScript – No automatic input conversion – No automatic input validation – Request centric Component-based MVC – Automatic request parameter procession – View kept around – Component libraries that implement re-usable behavior – Components render HTML / JavaScript – Automatic input conversion – Automatic input validation – Page centric Compare and contrast
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda MVC MVC 1.0 JSR Some examples MVC tooling Questions and Answers E
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The MVC 1.0 JSR It really is the “Action-based” MVC 1.0 JSR Where it this coming from? – JavaEE 8 survey – Talking to our customers – UI landscape is not one size fits all Who is supporting it?
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | List of supporters Joshua Wilson (Red Hat) Woong-ki Lee (TmaxSoft) Josh Juneau Fabio Velloso (SouJava) Yara Senger (SouJava) Bruno Souza (SouJava) Markus Karg Antonio Goncalves Rajmahendra (JUGChennai) Francisco Sokol Werner Keil Martijn Verburg (London Java Community) And of course Oracle (see JCP page)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Where and how? Where are we at? – The JSR has been approved – We have the EG up and running How can I help? – Join the mailinglist and – Participate in the Adopt-a-JSR program (JUGs) – Test out snapshots (once available) from the RI website ( and file issues if something is not workinghttp://ozark.java.net – Tweet, blog, socialize to raise awareness about MVC 1.0
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | An example about the EG process We are currently in the middle of a discussion about the following question: “Do we build on top of JAX-RS or not?” Since the mailing list gets every mail the EG sends you can follow this discussion as What do you think? – Tell us on the mailing list – Tweet about it – Talk to me after the session Why do I ask?
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Another couple of things being discussed Programmatic API so you can change the runtime behavior Type conversion of form inputs An SPI to plug in a different view technology – Velocity – Freemarker – Thymeleaf – … Your view technology …
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda MVC MVC 1.0 JSR Some examples MVC tooling Questions and Answers E
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. M
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | A rough JSP example Initial JSP page CDI Managed Bean (also known as the the controller) Result JSP page
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Initial JSP page Rough example
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | CDI Managed Bean public class RoughExampleBean implements Serializable { private String = "/form1a.jsp”) public String HttpServletRequest request) { String input1 = request.getParameter("inputText1"); setValue("We set input1 manually to - " + input1); return "/form1b.jsp”; } … omitted getter/setter methods … }
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Result JSP page Rough example result page We did a POST to an action based URL and the result is: #{roughExampleBean.value}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | A rough Facelet example Initial Facelet page CDI Managed Bean (also known as the controller) Result Facelet page
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Initial Facelet page Rough example
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | CDI Managed Bean (aka public class RoughExampleBean implements Serializable { private String = "/form1a.xhtml”) public String HttpServletRequest request) { String input1 = request.getParameter("inputText1"); setValue("We set input1 manually to - " + input1); return "/form1b.xhtml”; } … omitted getter/setter methods … }
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Result Facelet Page Rough example result page We did a POST to an action based URL and the result is: #{roughExampleBean.value}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Another Facelets example Template page Initial Facelet page CDI Managed Bean (also known as the controller) Result Facelet page
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Template Page Main Content
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Initial Page (using template)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | CDI Managed Bean (aka public class RoughExampleBean implements Serializable { private String = "/form1a.xhtml”) public String HttpServletRequest request) { String input1 = request.getParameter("inputText1"); setValue("We set input1 manually to - " + input1); return "/form1b.xhtml”; } … omitted getter/setter methods … }
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Result page (using template) We did a POST to an action based URL and the result is: #{roughExampleBean.value}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Some public public String public mypath)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Some brief @RolesAllowed(“spec_lead”) public “my.js”}) public String egMember()
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Recap Doing MVC now is not a bad idea, because we can: – Leverage CDI – Leverage Servlet 4.0 (ServerPush) – Leverage Facelets – Deliver an easy migration path if you are using JSPs Can you get involved? Yes, how: – Join our users mailing list – Tweet about MVC – Blog about MVC – Test out SNAPSHOT and milestone builds from (once available)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda MVC MVC 1.0 JSR Some examples MVC tooling Questions and Answers E
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MVC Tooling While it is not really part of the specification cycle perse we think to have tooling that allows you to work with MVC 1.0 is integral to a good developer experience So I have invited Geertjan to be my co-speaker to cover ideas he has with respect to tooling and he will take it from here
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Links MVC specification – Website – Users Mailing List MVC implementation – Website – Users Mailing List Spec leads – Santiago – Manfred Tooling – Geertjan
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Questions? Ask them now Talk to us afterwards