當前位置: 首頁>>代碼示例>>Java>>正文


Java Form類代碼示例

本文整理匯總了Java中play.data.Form的典型用法代碼示例。如果您正苦於以下問題:Java Form類的具體用法?Java Form怎麽用?Java Form使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Form類屬於play.data包,在下文中一共展示了Form類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import play.data.Form; //導入依賴的package包/類
public static Result create() {
    // Get the form from the request
    Form<Instructor> form = Form.form(Instructor.class,Instructor.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Instructor object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Instructor.create(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return created(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error creating object"), e);
        return internalServerError("Error creating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Instructors.java

示例2: update

import play.data.Form; //導入依賴的package包/類
public static Result update(Long id) {
    // Get the form from the request
    Form<Person> form = Form.form(Person.class,Person.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Person object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Person.update(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return ok(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error updating object"), e);
        return internalServerError("Error updating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Persons.java

示例3: create

import play.data.Form; //導入依賴的package包/類
public static Result create() {
    // Get the form from the request
    Form<Administrator> form = Form.form(Administrator.class,Administrator.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Administrator object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Administrator.create(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return created(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error creating object"), e);
        return internalServerError("Error creating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Administrators.java

示例4: update

import play.data.Form; //導入依賴的package包/類
public static Result update(Long id) {
    // Get the form from the request
    Form<Administrator> form = Form.form(Administrator.class,Administrator.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Administrator object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Administrator.update(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return ok(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error updating object"), e);
        return internalServerError("Error updating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Administrators.java

示例5: update

import play.data.Form; //導入依賴的package包/類
public static Result update(Long id) {
    // Get the form from the request
    Form<Program> form = Form.form(Program.class,Program.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Program object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Program.update(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return ok(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error updating object"), e);
        return internalServerError("Error updating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Programs.java

示例6: create

import play.data.Form; //導入依賴的package包/類
public static Result create() {
    // Get the form from the request
    Form<Allocation> form = Form.form(Allocation.class,Allocation.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Allocation object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Allocation.create(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return created(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error creating object"), e);
        return internalServerError("Error creating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Allocations.java

示例7: update

import play.data.Form; //導入依賴的package包/類
public static Result update(Long id) {
    // Get the form from the request
    Form<Allocation> form = Form.form(Allocation.class,Allocation.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Allocation object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Allocation.update(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return ok(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error updating object"), e);
        return internalServerError("Error updating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Allocations.java

示例8: create

import play.data.Form; //導入依賴的package包/類
public static Result create() {
    // Get the form from the request
    Form<CourseSession> form = Form.form(CourseSession.class,CourseSession.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    CourseSession object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        CourseSession.create(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return created(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error creating object"), e);
        return internalServerError("Error creating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:CourseSessions.java

示例9: update

import play.data.Form; //導入依賴的package包/類
public static Result update(Long id) {
    // Get the form from the request
    Form<CourseSession> form = Form.form(CourseSession.class,CourseSession.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    CourseSession object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        CourseSession.update(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return ok(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error updating object"), e);
        return internalServerError("Error updating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:CourseSessions.java

示例10: create

import play.data.Form; //導入依賴的package包/類
public static Result create() {
    // Get the form from the request
    Form<Record> form = Form.form(Record.class,Record.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Record object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Record.create(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return created(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error creating object"), e);
        return internalServerError("Error creating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Records.java

示例11: update

import play.data.Form; //導入依賴的package包/類
public static Result update(Long id) {
    // Get the form from the request
    Form<Record> form = Form.form(Record.class,Record.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Record object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Record.update(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return ok(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error updating object"), e);
        return internalServerError("Error updating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Records.java

示例12: create

import play.data.Form; //導入依賴的package包/類
public static Result create() {
    // Get the form from the request
    Form<Student> form = Form.form(Student.class,Student.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Student object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Student.create(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return created(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error creating object"), e);
        return internalServerError("Error creating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Students.java

示例13: update

import play.data.Form; //導入依賴的package包/類
public static Result update(Long id) {
    // Get the form from the request
    Form<Student> form = Form.form(Student.class,Student.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Student object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Student.update(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return ok(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error updating object"), e);
        return internalServerError("Error updating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Students.java

示例14: create

import play.data.Form; //導入依賴的package包/類
public static Result create() {
    // Get the form from the request
    Form<Course> form = Form.form(Course.class,Course.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Course object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Course.create(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return created(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error creating object"), e);
        return internalServerError("Error creating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Courses.java

示例15: update

import play.data.Form; //導入依賴的package包/類
public static Result update(Long id) {
    // Get the form from the request
    Form<Course> form = Form.form(Course.class,Course.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Course object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Course.update(object);
        JsonNode jsonObject = object.jsonSerialization();
        Ebean.commitTransaction();
        return ok(jsonObject);
    } catch (Exception e) {
        appLogger.error(Messages.get("Error updating object"), e);
        return internalServerError("Error updating object");
    } finally {
        Ebean.endTransaction();
    }
}
 
開發者ID:ejesposito,項目名稱:CS6310O01,代碼行數:24,代碼來源:Courses.java


注:本文中的play.data.Form類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。