Package app.action

Source Code of app.action.AddByThymeleafAction

package app.action;

import java.util.HashMap;
import java.util.Map;

import com.blogger.tcuri.appserver.Action;
import com.blogger.tcuri.appserver.ActionContext;
import com.blogger.tcuri.appserver.koi.HtmlResolution;
import com.blogger.tcuri.appserver.resolution.Resolution;
import com.blogger.tcuri.appserver.validator.Validators;
import com.blogger.tcuri.appserver.validator.annotation.IntegerType;
import com.blogger.tcuri.appserver.validator.annotation.Required;

public class AddByThymeleafAction extends Action {

    @Required
    @IntegerType
    public String arg1;

    @Required
    @IntegerType
    public String arg2;

    public Integer result;

    public Map<String, String> message = new HashMap<String, String>();

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

        if (context.param("sbmt") == null) {
            // 初期表示
            message = new HashMap<String, String>();
            return new HtmlResolution("add", this);
        }
       
        Validators v = new Validators(this);
        Resolution resolution = new HtmlResolution("add", this);
       
        if (v.isError()) {
            message = v.getErrorMap();
            return resolution;
        }

        result = Integer.parseInt(arg1) + Integer.parseInt(arg2);
        return resolution;
    }
}
TOP

Related Classes of app.action.AddByThymeleafAction

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.