Coder Social home page Coder Social logo

play2-crud's Introduction

play2-crud

Powerful CRUD & DAO implementation with REST interface for play framework 2.x

For the Typesafe Activator check play2-crud-activator.

Samples

Quick Start

Follow these steps to use play2-crud. You can also use it partially just for DAO or CRUD controllers. If you think any part needs further explanation, please report a new issue.

Add play2-crud dependency

You can begin with adding play2-crud dependency inside conf/Build.scala file.

  • Add app dependency:
    val appDependencies = Seq(
        javaCore, javaJdbc, javaEbean,
        "play2-crud" % "play2-crud_2.10" % "0.7.0"
    )

  • Here in the sample, it is defined for version 0.7.0, but you can use the latest version accordingly.

  • Add custom maven repositories:

    val main = play.Project(appName, appVersion, appDependencies).settings(
        //maven repository
        resolvers += "release repository" at  "http://hakandilek.github.com/maven-repo/releases/",
        resolvers += "snapshot repository" at "http://hakandilek.github.com/maven-repo/snapshots/"
    )

Associate Global settings

  • Change the application.global configuration key in the conf/application.conf file, and use play.utils.crud.GlobalCRUDSettings:
...
application.global=play.utils.crud.GlobalCRUDSettings
...

  • If the above key is commented, you can just uncomment the configuration line, and change it.
  • You can also use a class which is extending play.utils.crud.GlobalCRUDSettings.

Define routes

# CRUD Controllers
->     /app             play.crud.Routes

# REST API
->     /api             play.rest.Routes

Define model

  • Model class has to implement play.utils.dao.BasicModel with the type parameter indicating the type of the @Id field.
@Entity
public class Sample extends Model implements BasicModel<Long> {

   @Id
   private Long key;

   @Basic
   @Required
   private String name;

   public Long getKey() {
      return key;
   }

   public void setKey(Long key) {
      this.key = key;
   }

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }
}
  • Here the Sample model class implements BasicModel<Long> where key field indicated with @Id is Long.

... call http://localhost:9000/app and voila!

Some screenshots

  • index page crud-index page

  • create page create page

  • list page list page

HOW-TO

Here you can find some HOW-TO documents introducing some powerful functionality:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.