Download presentation
Presentation is loading. Please wait.
Published byFerdinand Brooks Modified over 9 years ago
1
MVC 1.0 Manfred Riem (@mnriem) Oracle Geertjan Wielenga (@geertjanw) Oracle Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
2
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
3
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda MVC MVC 1.0 JSR Some examples MVC tooling Questions and Answers 1 2 3 4 5 E
4
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
5
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
6
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.
7
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
8
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Different styles of MVC Component-based MVC Action-based MVC Other styles
9
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)
10
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
11
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
12
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
13
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
14
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda MVC MVC 1.0 JSR Some examples MVC tooling Questions and Answers 1 2 3 4 5 E
15
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?
16
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)
17
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 users@mvc-spec.java.net mailinglist and commentusers@mvc-spec.java.net – Participate in the Adopt-a-JSR program (JUGs) – Test out snapshots (once available) from the RI website (http://ozark.java.net) and file issues if something is not workinghttp://ozark.java.net – Tweet, blog, socialize to raise awareness about MVC 1.0
18
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 users@mvc-spec.java.net mailing list gets every mail the EG sends you can follow this discussion as wellusers@mvc-spec.java.net What do you think? – Tell us on the mailing list – Tweet about it – Talk to me after the session Why do I ask?
19
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 …
20
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda MVC MVC 1.0 JSR Some examples MVC tooling Questions and Answers 1 2 3 4 5 E
21
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
22
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
23
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Initial JSP page Rough example
24
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | CDI Managed Bean (the controller) @Named("roughExampleBean”) @RequestScoped public class RoughExampleBean implements Serializable { private String value; @Path(value = "/form1a.jsp”) public String form1(@Inject HttpServletRequest request) { String input1 = request.getParameter("inputText1"); setValue("We set input1 manually to - " + input1); return "/form1b.jsp”; } … omitted getter/setter methods … }
25
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}
26
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
27
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Initial Facelet page Rough example
28
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | CDI Managed Bean (aka the controller) @Named("roughExampleBean”) @RequestScoped public class RoughExampleBean implements Serializable { private String value; @Path(value = "/form1a.xhtml”) public String form1(@Inject HttpServletRequest request) { String input1 = request.getParameter("inputText1"); setValue("We set input1 manually to - " + input1); return "/form1b.xhtml”; } … omitted getter/setter methods … }
29
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}
30
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
31
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Template Page Main Content
32
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Initial Page (using template)
33
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | CDI Managed Bean (aka the controller) @Named("roughExampleBean”) @RequestScoped public class RoughExampleBean implements Serializable { private String value; @Path(value = "/form1a.xhtml”) public String form1(@Inject HttpServletRequest request) { String input1 = request.getParameter("inputText1"); setValue("We set input1 manually to - " + input1); return "/form1b.xhtml”; } … omitted getter/setter methods … }
34
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}
35
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Some brief examples @GET @Path(“mypath”) public String mypath(@Inject @HeaderParam(“myheader”) String header) @POST @Path(“mypath2”) public String otherName(@Inject HttpSession session) @PUT @Path(“mypath3/{mypath}”) public String myName(@Inject @PathParam mypath)
36
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Some brief examples (continued) @GET @Path(“spec_lead”) @RolesAllowed(“spec_lead”) public String specLead() @GET @Path(“eg_member”) @RolesAllowed(“eg_member”) @ServerPush({“my.css”, “my.js”}) public String egMember()
37
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 https://ozark.java.net (once available)https://ozark.java.net
38
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda MVC MVC 1.0 JSR Some examples MVC tooling Questions and Answers 1 2 3 4 5 E
39
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
40
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Links MVC specification – Website http://mvc-spec.java.nethttp://mvc-spec.java.net – Users Mailing List users@mvc-spec.java.netusers@mvc-spec.java.net MVC implementation – Website http://ozark.java.nethttp://ozark.java.net – Users Mailing List users@ozark.java.netusers@ozark.java.net Spec leads – Santiago (@spericas) – Manfred (@mnriem, https://www.java.net/blogs/mriem)https://www.java.net/blogs/mriem Tooling – Geertjan (@GeertjanW, https://blogs.oracle.com/geertjan)https://blogs.oracle.com/geertjan
41
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Questions? Ask them now Talk to us afterwards
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.