Package app.action.crud

Source Code of app.action.crud.UpdateAction

package app.action.crud;

import app.logic.CrudLogic;

import com.blogger.tcuri.appserver.Action;
import com.blogger.tcuri.appserver.ActionContext;
import com.blogger.tcuri.appserver.Utils;
import com.blogger.tcuri.appserver.db.DbUtils;
import com.blogger.tcuri.appserver.db.SqlBuilder;
import com.blogger.tcuri.appserver.db.Transactional;
import com.blogger.tcuri.appserver.resolution.Resolution;

@Transactional
public class UpdateAction extends Action {

    @Override
    public Resolution execute(ActionContext context) throws Exception {

        String id = context.param("id");
        String content = context.param("content");

        if (Utils.isNotBlank(id) && Utils.isNotBlank(content)) {
            SqlBuilder sql = new SqlBuilder(
                    "update messages set content=? where id=?", content, id);
            DbUtils.execute(sql);
        }

        return CrudLogic.read();
    }
}
TOP

Related Classes of app.action.crud.UpdateAction

TOP
Copyright © 2018 www.massapi.com. 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.