当前位置: 首页>>代码示例>>Java>>正文


Java Form.hasErrors方法代码示例

本文整理汇总了Java中play.data.Form.hasErrors方法的典型用法代码示例。如果您正苦于以下问题:Java Form.hasErrors方法的具体用法?Java Form.hasErrors怎么用?Java Form.hasErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在play.data.Form的用法示例。


在下文中一共展示了Form.hasErrors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authenticate

import play.data.Form; //导入方法依赖的package包/类
/**
 * Handle login form submission.
 *
 * @return Dashboard if auth OK or login form if auth KO
 */
public Result authenticate() {
    Form<Login> loginForm = form(Login.class).bindFromRequest();

    Form<Register> registerForm = form(Register.class);

    if (loginForm.hasErrors()) {
        return badRequest(index.render(registerForm, loginForm));
    } else {
        session("email", loginForm.get().email);
        User user = User.findByEmail(loginForm.get().email);
        session("id", user.id.toString());
        session("name", user.fullname);
        return GO_DASHBOARD;
    }
}
 
开发者ID:vn09,项目名称:rental-helper,代码行数:21,代码来源:Application.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例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: submit

import play.data.Form; //导入方法依赖的package包/类
public Result submit() {
    User user = User.findByEmail(session().get("email"));
    Form<UserPreferences> filledForm = preferencesForm.bindFromRequest();
    if (filledForm.hasErrors()) {
        return badRequest(editpreferences.render(user, preferencesForm));
    }
    Long userId;
    if (user == null) {
        userId = filledForm.get().userId;
    } else {
        userId = user.id;
    }
    UserPreferences preferences = UserPreferences.findByUserId(userId);
    if (preferences != null) {
        preferences.set(filledForm.get());
        preferences.save();
    } else {
        UserPreferences newPreferences = new UserPreferences();
        newPreferences.set(filledForm.get());
        newPreferences.userId = userId;
        newPreferences.save();
    }

    return redirect(controllers.routes.EditPreferences.index());
}
 
开发者ID:vn09,项目名称:rental-helper,代码行数:26,代码来源:EditPreferences.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: 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

示例11: 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

示例12: 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

示例13: submit

import play.data.Form; //导入方法依赖的package包/类
public Result submit() {
    User user = User.findByEmail(session().get("email"));
    Form<UserProfile> filledForm = profileForm.bindFromRequest();

    if (filledForm.hasErrors()) {
        return badRequest(createprofile.render(filledForm));
    } else {
        MultipartFormData body = request().body().asMultipartFormData();
        FilePart picture = body.getFile("image");
        UserProfile newProfile = filledForm.get();
        newProfile.image = picture.getFile();
        String filePath = "public/user_pictures/"+ user.email + ".png";
        newProfile.saveImage(picture.getFile(), filePath);
        newProfile.userId = user.id;
        newProfile.save();
        return ok(viewprofile.render(user, newProfile));
    }
}
 
开发者ID:vn09,项目名称:rental-helper,代码行数:19,代码来源:CreateProfile.java

示例14: 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

示例15: update

import play.data.Form; //导入方法依赖的package包/类
public static Result update(Long id) {
    // Get the form from the request
    Form<Role> form = Form.form(Role.class,Role.creation.class).bindFromRequest();
    // Validate errors
    if(form.hasErrors()) {
        return badRequest(form.errorsAsJson());
    }
    // Get the object from the form
    Role object = form.get();
    // Create the object in db
    Ebean.beginTransaction();
    try {
        Role.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,代码来源:Roles.java


注:本文中的play.data.Form.hasErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。