Try using Java framework Nablarch [Web application]

Use Java's OSS framework Nablarch to check communication + α. Nablarch is a framework that can be used for various purposes such as web applications, web services, batch messaging. This time we will create a web application project. (It is undecided whether to create an article on other execution control infrastructure.)

environment

OS: OS X Yosemite 10.10.5 Maven: Apache Maven 3.3.3 IDE: IntelliJ IDEA 2016.2.3 Nablarch: 5u8

things to do

Create a blank project and just touch it. Acquires and displays the information registered in the DB.

procedure

Create it by referring to How to create a blank project. For the time being, it seems that you can hit the following command to create it, so hit it. The version has been changed to 5u8.

mvn archetype:generate -DarchetypeGroupId=com.nablarch.archetype -DarchetypeArtifactId=nablarch-web-archetype -DarchetypeVersion=5u8

Then, you will be asked for the project information, so enter it. This time, enter the same one as described in the procedure.

With that, you have a blank project! Let's open it in the IDE right away! blank-project.png

You can do it! Next, let's check the communication. If you execute clean, compile, waitt: run with the maven command, the web application will start and be displayed in the browser. test-browse.png

It's working fine! Then, I will customize it a little. It's a lot of work because you just touch it and check the operation. .. ..

First, prepare a DB table for data acquisition. Create a PERSON table with ID / NAME / AGE columns and insert one data. This time, I ran it with IntelliJ's database access function. Connection information can be found in src / env / dev / resources / env.config.

Next, prepare Entity class to hold what is obtained from DB.

Person.java


@Entity
public class Person {
    @Id
    private String id;
    private String name;
    private Integer age;

    // getter,setter omitted
}

Next, create an action class (logic part). Get the data from the PERSON table, set it in request scope and pass it to jsp.

PersonAction.java


public class PersonAction {

    public HttpResponse search(HttpRequest request, ExecutionContext context) {
        List<Person> data = UniversalDao.findAll(Person.class);
        context.setRequestScopedVar("data", data);
        return new HttpResponse("/person/list.jsp");
    }
}

Finally, create jsp.

list.jsp


    <!--html Standard part omitted-->
    <table border="1">
        <tr>
            <th>name</th>
            <th>age</th>
        </tr>
        <c:forEach items="${data}" var="d">
        <tr>
            <td><n:write name="d.name" /></td>
            <td><n:write name="d.age" /></td>
        </tr>
        </c:forEach>
    </table>

That's all there is to it.

mvn clean compile waitt:run

Go to http: // localhost: 9080 / action / person / search in your browser. test-browse2.png

It is displayed! By the way, this URL can be mapped to src / main / resources / routes.xml <match path="/action/:controller/:action"/> Since there is, it is mapped to the search method of the PersonAction class.

Summary / Impressions

For details, I left it to Nablarch's Explanation and omitted the explanation, but as mentioned above I was able to create a web application quickly. When it comes to actual development, it works (blank project and [Example] as an implementation example (https://github.com/nablarch/nablarch-example-web)) even if it is not crisp because there are many contents to customize. I felt that it was easy to touch that) could be prepared immediately. I really wish I could compare it with other frameworks, but I gave it up because of my shallow learning. The one created this time is posted on github.

Recommended Posts

Try using Java framework Nablarch [Web application]
Try using Axon Framework
Try using RocksDB in Java
Try scraping using java [Notes]
Create a JAVA WEB application and try OMC APM
Try developing a containerized Java web application with Eclipse + Codewind
Try using Redis with Java (jar)
[Java] Try to implement using generics
Try using IBM Java method tracing
Try using Hyperledger Iroha's Java SDK
[Java] Where did you try using java?
java framework
Automatically deploy a Web application developed in Java using Jenkins [Preparation]
Automatically deploy Web applications developed in Java using Jenkins [Tomcat application]
Try using the Stream API in Java
Study Java Try using Scanner or Map
ERRORCODE = -4471 occurs in Java application using Db2.
Try using JSON format API in Java
Status monitoring of java application using Elasticsearch
Try using JobScheduler's REST-API --Java RestClient implementation--
Role of JSP in Web application [Java]
Try using the Wii remote with Java
Build Web Application Server (Java) on VPS
Java beginner tried to make a simple web application using Spring Boot
Automatically deploy a web application developed in Java using Jenkins [Spring Boot application]
Try using Firebase Cloud Functions on Android (Java)
Try using JobScheduler's REST-API --Java RestClient Test class-
Try using libGDX
Try using Maven
Try using powermock-mockito2-2.0.2
Try using GraalVM
Try Java 8 Stream
Try using jmockit 1.48
Java 9+ application status
Try using sql-migrate
Try using Sourcetrail (win version) in Java code
Try using GCP's Cloud Vision API in Java
Let's create a super-simple web framework in Java
Try using Sourcetrail (macOS version) in Java code
Try similar search of Image Search using Java SDK [Search]
Try accessing the dataset from Java using JZOS
Try using SwiftLint
Try using Log4j 2.0
Java framework comparison
[Java / PostgreSQL] Connect the WEB application to the database
Try communication using gRPC on Android + Java server
Try using the COTOHA API parsing in Java
Roughly try Java 9
[Java] Collection framework
[For beginners] Until building a Web application development environment using Java on Mac OS
Try implementing the Eratosthenes sieve using the Java standard library
Try using OpenID Connect with Keycloak (Spring Boot application)
Try Image Search's similar search using Java SDK [Registration]
[Tutorial] Download Eclipse → Run Web application with Java (Pleiades)
Try image classification using TensorFlow Lite on Android (JAVA)
Try global hooking in Java using the JNativeHook library
Try to build a Java development environment using Docker
Sorting using java comparator
Play Framework2.5 (Java) Tips
Try using JobScheduler's REST-API
Try using java.lang.Math methods