}
public static void save(String id) throws Exception {
ObjectType type = ObjectType.get(getControllerClass());
notFoundIfNull(type);
SienaSupport object = type.findById(id);
object = object.edit("object", params);
// Look if we need to deserialize
for (ObjectField field : type.getFields()) {
if (field.type.equals("serializedText") && params.get("object." + field.name) != null) {
Field f = object.getClass().getDeclaredField(field.name);
f.set(object, CRUD.collectionDeserializer(params.get("object." + field.name),(Class)((ParameterizedType) f.getGenericType()).getActualTypeArguments()[0]));
}
}
validation.valid(object);
if (validation.hasErrors()) {
renderArgs.put("error", Messages.get("crud.hasErrors"));
try {
render(request.controller.replace(".", "/") + "/show.html", type, object);
} catch (TemplateNotFoundException e) {
render("CRUD/show.html", type, object);
}
}
object.update();
flash.success(Messages.get("crud.saved", type.modelName, object.getEntityId()));
if (params.get("_save") != null) {
redirect(request.controller + ".list");
}
redirect(request.controller + ".show", object.getEntityId());
}