Java Magazine, March/April 2017
ORACLE COM JAVAMAGAZINE MARCH APRIL 2017 31 ui tools because requests are handled completely by the implementation of controller methods Given that view options are abundant and the request response is completely open to custom development the MVC framework promises to deliver a very flexible web development option Where JSF is componentbased and handles much of the session management for the developer MVC leaves the developer to create applications using just about any view technology and it hands over full control of the session management Building a Project with MVC 10 The MVC framework reference implementation named Ozark was defined in JSR 371 This framework is layered on top of JAX RS If you are familiar with JAX RS you will find it easy to use If you are not familiar with JAX RS you can learn both MVC and JAX RS reading this article because they both function very much the same way In this article I walk through the development of the Duke Issue Tracker application illustrating the basics of the MVC framework along the way To follow along you need to have a solid understanding of how Java EE applications are built I use NetBeans 82 here which already provides support for MVC 10 but you can follow along with the IDE of your choice Duke Issue Tracker is used to create and view issues for Dukes application The initial view of the application lists all of the open issues in the upper half of the UI and displays an issue creation form on the lower half An Apache Derby database is used to store the data and this article demonstrates how to use JAX RS web services and Enterprise JavaBeans EJBs to read create and update data MVC is not quite a production ready framework Even though it is fairly developed at this point it has not yet been completed nor has it been released as part of any production application server This means you will need to obtain the Ozark reference implementation JAR file from the project site and deploy it along with your An MVC 10 application is simply a JAX RS application that consists of one or more resources annotated with @ Controller WAR file to a valid container such as GlassFish 41 For the purposes of this example I deploy to the GlassFish 5 nightly build and I include Ozark 100 m02 and MVC API 10 edr2 as dependencies in the POM file of the project Server and Project To get started create a new NetBeans Maven web application project and name it DukeIssueTracker Once the project has been generated add the required dependencies to the POM as shown in Listing 1 Configure the application to run on JDK 8 and the GlassFish or Payara server of your choice Listing 1 dependency groupId javax mvc groupId artifactId javax mvc api artifactId version 10 edr2 version scope provided scope dependency dependency groupId org glassfish ozark groupId artifactId ozark artifactId version 100 m02 version scope provided scope dependency Next I have created a small set of tables that needs to be installed into the local Apache Derby database or the database of your choice To do so run the create sql file that is packaged with the source code against the database
You must have JavaScript enabled to view digital editions.