Sunday, September 13, 2015

Ozark Tutorial for Netbeans 8.0.2 and the Bundled Glassfish Server + Maven

Team. The work hours are mounting on other projects. Fortunately, the roll-out for Ozark (MVC 1.0) is the Q3 of 2016. From the reading in the early draft it seems that CABOOSE would fit best as a ViewEngine for MVC 1.0 with possible support for the reflective JSP/JSF tags. Ozark has been available for review with the associated test archives since March of 2015. These with a sample Maven project archive are available at the following Google Drive locations:

Googlge Doc Shareable Links for Ozark Archives
java-ee-8-mvc-master.zip
https://drive.google.com/file/d/0B101EUHMgepNTVpGTWNZY0JuTm8/view?usp=sharing
javax.mvc-api-1.0-edr1.jar
https://drive.google.com/file/d/0B101EUHMgepNSHlrU2xaVHR2MHc/view?usp=sharing
ozark-1.0.0-m01.jar
https://drive.google.com/file/d/0B101EUHMgepNVW03RFdVem5JcVU/view?usp=sharing


The following is the first draft of a simple tutorial which shows one how he can compile and run the sample project "getting-started" contained in java-ee-8-mvc-master.zip plus create his own project called the OzarkTemplate.

The tutorial should take about 45 minutes or less:

Compiling and Testing the GettingStarted Ozark MVC Project

A. Transfer the java-ee-8-mvc-master.zip archive from the Google Docs link or GitHub
B. File>Import Project>From ZIP...
C. Browse for the above archive and select Import. Complete any remaining importing steps.
D. Right-click the "getting-started" Maven web archive and select Build with Dependencies.
E. Select Green Run Triangle on Toolbar which will run the project.
F. Select the blue link on the index page which appears and the controller should return hello.jsp.

Preparing for Creating your Own Ozark MVC Project

X. Transfer javax.mvc-api-1.0-edr1.jar and ozark-1.0.0-m01.jar from their listed Google Docs links, java.net, or the web.
Y. These will be used as package denpendencies in our project.
Z. They might be needed if your IDE does not find them automatically.

Creating an Ozark MVC "Hey" Project (Maven-Netbeans 8.0.2 IDE)

1.File>New Project>Maven>Web Application on the the Choose Project Page
2.Select Next
3.Enter OzarkTemplate for Project Name: (Everything else can use the default values) on the Name and Location Page
4.Select Next
5. Ensure that the GlassFish Server 4.1 is the chosen Server: and the Java EE Version: is Java EE 7 Web on the Settings

Page of the New Web Applciation Widget
6. Select Finish

Adding Dependencies

7. In the Project Explorer, right-click the Dependencies Folder under the OzarkTempalte Maven Web Application>Add

Dependency.
8. Enter the following values:
    groupId:     com.oracle.ozark
    artifactId:    ozark
    version:    1.0.0-m01
9. Select a scope of compile.
10. The jar files, ozark-1.0.0-m01.jar and javax.mvc-api-1.0-edr1.jar, are added in the project dependencies.

Adding RESTful web-service

11. In the Project Explorer, right-click the OzarkTemplates Maven Web Application >New>RESTFul WebServices from Patterns
12. Select Simple Root Resource>Next
13. Enter the following value:
    path:         ozark
    Class Name:    OzarkController
14. Select Finish

Editing OzarkController.java

12. In the generated OzarkContoller.java source add the following imports:

import javax.mvc.Controller;
import javax.mvc.View;

13. The annotate the class as a Controller:

...

@Controller
@Path("ozark")
public class OzarkResource {

....

14. The add the following resource method:

...

    @GET
    @Controller
    public String ozarkString(){
        return("/WEB-INF/jsp/hey.jsp");
    }

...

Creating "hey.jsp"

15. In the Project Explorer, right-click the OzarkTemplates Maven Web Application >New>JSP
16. Enter the following value:
    FileName:     hey
17. Select Finish.
18. Place the following content in hey.jsp:
...
<title>Ozarkian HEY</title>
...
<h1>Hey! From the Ozarks</h1>
...

19. Right-click the WEB-INF folder>New>Folder
20. Enter the following value:
    FolderName:     jsp
21. Select Finish.
22. Drag hey.jsp and drop it on the newly created jsp folder.

Creating a link which activates the controller.

23. Place the following content in the body of the index.html file:
...
<a href="ozarkHey/ozark">Ozark</a>
...

Testing WebApp

19. In the Project Explorer, right-click the OzarkTemplates Maven Web Application >Set As Main Project
20. Select Green Run Triangle on Toolbar which will build and run the project.
21. Select the Ozark link on the index page which appears. The hey.jsp page content should appear.


Hope it was fun! The CABOOSE Team... Hunt...Peck...Think...!

No comments:

Post a Comment