package sample.org.itscool.tutorial2;
import java.util.LinkedList;


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

public class SaveAction extends Action {
    public String doExecute(ActionBucket bucket)
    throws Exception {
        AskData data = (AskData)bucket.getForm();            
        if (this.getParameter("save") != null) {
            LinkedList messages = 
            (LinkedList)bucket.getAttributeFromSession ("messages");
            if(messages == null){
                messages = new LinkedList();
                bucket.setAttributeFromSession( "messages", messages);
            }
            messages.addFirst(data); 
            return "save_success";
        }else{
            bucket.setAttribute("ask", data);
            return "edit_success";
        } 
    }
}
