public static void create() throws Exception {
ObjectType type = ObjectType.get(getControllerClass());
notFoundIfNull(type);
Constructor<?> constructor = type.entityClass.getDeclaredConstructor();
constructor.setAccessible(true);
Model object = (Model) constructor.newInstance();
Binder.bind(object, "object", params.all());
validation.valid(object);
if (validation.hasErrors()) {
renderArgs.put("error", Messages.get("crud.hasErrors"));
try {
render(request.controller.replace(".", "/") + "/blank.html", type, object);
} catch (TemplateNotFoundException e) {
render("CRUD/blank.html", type, object);
}
}
object._save();
flash.success(Messages.get("crud.created", type.modelName));
if (params.get("_save") != null) {
redirect(request.controller + ".list");
}
if (params.get("_saveAndAddAnother") != null) {
redirect(request.controller + ".blank");
}
redirect(request.controller + ".show", object._key());
}