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;
}
}