Package models.crudsiena

Examples of models.crudsiena.SienaSupport


    }

    public static void show(String id) {
        ObjectType type = ObjectType.get(getControllerClass());
        notFoundIfNull(type);
        SienaSupport object = type.findById(id);
        try {
            render(type, object);
        } catch (TemplateNotFoundException e) {
            render("CRUD/show.html", type, object);
        }
View Full Code Here


    }

    public static void addListElement(String id, String field) throws Exception {
        ObjectType type = ObjectType.get(getControllerClass());
        notFoundIfNull(type);
        SienaSupport object = type.findById(id);
               
        object.addListElement(field);
       
        validation.valid(object);
        if (validation.hasError(field)) {
            renderArgs.put("error", validation.error(field));
        }
View Full Code Here

    }

    public static void deleteListElement(String id, String field, Integer idx) throws Exception {
        ObjectType type = ObjectType.get(getControllerClass());
        notFoundIfNull(type);
        SienaSupport object = type.findById(id);
               
        object.deleteListElement(field, idx);

        validation.valid(object);
        if (validation.hasError(field)) {
            renderArgs.put("error", validation.error(field));
        }
View Full Code Here

    }
   
    public static void addMapElement(String id, String field, String mkey) throws Exception {
        ObjectType type = ObjectType.get(getControllerClass());
        notFoundIfNull(type);
        SienaSupport object = type.findById(id);
               
        object.addMapElement(field, mkey);

        validation.valid(object);
        if (validation.hasError(field)) {
            renderArgs.put("error", validation.error(field));
        }
View Full Code Here

    }
   
    public static void deleteMapElement(String id, String field, String mkey) throws Exception {
        ObjectType type = ObjectType.get(getControllerClass());
        notFoundIfNull(type);
        SienaSupport object = type.findById(id);
               
        object.deleteMapElement(field, mkey);

        validation.valid(object);
        if (validation.hasError(field)) {
            renderArgs.put("error", validation.error(field));
        }
View Full Code Here

    }
   
    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());
    }
View Full Code Here

    }

    public static void create() throws Exception {
        ObjectType type = ObjectType.get(getControllerClass());
        notFoundIfNull(type);
        SienaSupport object = type.entityClass.newInstance();
        validation.valid(object.edit("object", params));
        if (validation.hasErrors()) {
            renderArgs.put("error", Messages.get("crud.hasErrors"));
            try {
                render(request.controller.replace(".", "/") + "/blank.html", type);
            } catch (TemplateNotFoundException e) {
                render("CRUD/blank.html", type);
            }
        }
        object.insert();
        flash.success(Messages.get("crud.created", type.modelName, object.getEntityId()));
        if (params.get("_save") != null) {
            redirect(request.controller + ".list");
        }
        if (params.get("_saveAndAddAnother") != null) {
            redirect(request.controller + ".blank");
        }
        redirect(request.controller + ".show", object.getEntityId());
    }
View Full Code Here

    }

    public static void delete(String id) {
        ObjectType type = ObjectType.get(getControllerClass());
        notFoundIfNull(type);
        SienaSupport object = type.findById(id);
        try {
            object.delete();
        } catch (Exception e) {
            flash.error(Messages.get("crud.delete.error", type.modelName, object.getEntityId()));
            redirect(request.controller + ".show", object.getEntityId());
        }
        flash.success(Messages.get("crud.deleted", type.modelName, object.getEntityId()));
        redirect(request.controller + ".list");
    }
View Full Code Here

TOP

Related Classes of models.crudsiena.SienaSupport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.