Menu Chiudi

JOR

Java Object Representation

JOR is used to represent objects on the web, then to format them in html, and therefore to associate a given URL to an object. To do this, write down the desired class with this super annotation:

@JOR(field_id = "title", url_Pattern = "books/")

In this case, if the book is called makado, to trace this object, once the jor web server has been activated, go to the url http: // localhost / books / makado.


Let’s see the first example JOR, we want to represent books on the web, let’s see how to do :
  1. I create the Book class: Book.java
    package cloud.jgo.test;

    import cloud.jgo.net.tcp.http.jor.annotations.JOR;

    /**
     * 
    @author Martire91  <https://github.com/wasp91>
     */

    @JOR
    (field_id = "title", url_Pattern = "books/")
    public class Book {

        
    private String title, author;
        
    private double price;

        
    public Book() {
            
    this.title = null;
            
    this.author = null;
            
    this.price = 1;
        
    }

        
    public Book(String title, String author, double price) {
            
    super();
            
    this.title = title;
            
    this.author = author;
            
    this.price = price;
        
    }

        
    public String getTitle() {
            
    return title;
        
    }

        
    public void setTitle(String title) {
            
    this.title = title;
        
    }

        
    public String getAuthor() {
            
    return author;
        
    }

        
    public void setAuthor(String author) {
            
    this.author = author;
        
    }

        
    public double getPrice() {
            
    return price;
        
    }

        
    public void setPrice(double price) {
            
    this.price = price;
        
    }

    }
  2. I create the jor request handler

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *