Download presentation
Presentation is loading. Please wait.
Published byGideon Caywood Modified over 9 years ago
1
@mnriem#DV14 #MVC MVC 1.0 in JavaEE 8 A long time coming, or like some would say “finally!” Why are we doing it now? Survey input Customer input JavaEE is about standards What are we looking at? Tight CDI integration Build on top of existing APIs
2
@mnriem#DV14 #MVC MVC 1.0 Some common questions Can’t you do MVC with JAX-RS already? Indeed there is MVC support in Jersey and RESTeasy However it is not defined by a standard Will it replace JSF? Why do you ask? Can you do everything using one tool?
3
@mnriem#DV14 #MVC How to control? A Servlet that: Uses the CDI runtime to get a managed bean that matches the annotated method for a given URI Invokes the method and gets back the response Forwards the request to the view language engine as determined by the response Integrates with the rest of the CDI runtime so it plays well with other CDI artifacts like interceptors
4
@mnriem#DV14 #MVC How to model? As the controller already uses the CDI runtime, the model in your MVC application will be using the CDI to define its model Please understand that we are talking about the model for the view (not the models you would need to define for any other layer beyond your view layer)
5
@mnriem#DV14 #MVC How to render? How to render the view JSP Facelets Other view languages Deliver a SPI so a vendor can hook in their own view language
6
@mnriem#DV14 #MVC 2 rough examples A JSP based example A Facelets based example
7
@mnriem#DV14 #MVC A rough JSP example Initial JSP page CDI Managed Bean (also known as the the controller) Result JSP page
8
@mnriem#DV14 #MVC Initial JSP page Rough example
9
@mnriem#DV14 #MVC CDI Managed Bean @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 … }
10
@mnriem#DV14 #MVC Result JSP page Rough example result page We did a POST to an action based URL and the result is: #{roughExampleBean.value}
11
@mnriem#DV14 #MVC A rough Facelet example Initial Facelet page CDI Managed Bean (also known as the controller) Result Facelet page
12
@mnriem#DV14 #MVC Initial Facelet page Rough example
13
@mnriem#DV14 #MVC CDI Managed Bean @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 … }
14
@mnriem#DV14 #MVC Result Facelet page Rough example result page We did a POST to an action based URL and the result is: #{roughExampleBean.value}
15
@mnriem#DV14 #MVC MVC 1.0 If you want to know more about MVC 1.0 Attend my session When: Friday What time: 10:45 - 11:45 Where: Room 4 Follow the discussion on the users@mvc-spec.java.net mailing listusers@mvc-spec.java.net Try out SNAPSHOTs from http://ozark.java.net/ (once available)http://ozark.java.net/ Keep an eye on my twitter handle @mnriem
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.