package weber_4_0_sample.org.itscool.hello;
import java.util.ArrayList;

import org.itscool.weber.action.Action;
import org.itscool.weber.action.ActionBucket;

public class HelloShowAction extends Action{
    //入力チェック
    public String doValidate(ActionBucket bucket){
        if (!isNotNull("name")) {
            putMessage("E0001","名前を入力してね");
            return "input";
        }else{
            return "success";
        }
    }
    
    public String doExecute(ActionBucket bucket){
        Hello hello = (Hello)bucket.getForm();
        String newName = hello.getName().toUpperCase();
        hello.setName(newName);
        
        bucket.setAttribute("hello", hello);
        
        ArrayList personList = (ArrayList)bucket.getAttributeFromSession("personList");
        if( personList == null){
        	personList = new ArrayList();
        	bucket.setAttributeFromSession("personList", personList);
        }
        personList.add(hello);
        return "show";
    }
}

