// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package demo;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.RedirectResolution;
import net.sourceforge.stripes.action.Resolution;

public class AddActionBean implements ActionBean {
    // boilerplate (best practice is to move to BaseActionBean class)
    private ActionBeanContext ctx;
    public void setContext(ActionBeanContext ctx){
        this.ctx = ctx;
    }
    public ActionBeanContext getContext(){
        return ctx;
    }
    // form data
    private String f1;
    private String f2;
    private String f3;
    public String getF1() {
        return f1;
    }
    public void setF1(String f1) {
        this.f1 = f1;
    }
    public String getF2() {
        return f2;
    }
    public void setF2(String f2) {
        this.f2 = f2;
    }
    public String getF3() {
        return f3;
    }
    public void setF3(String f3) {
        this.f3 = f3;
    }
    // actual action
    public RedirectResolution add() {
        // save
        DB.saveOne(new T1(Integer.parseInt(f1), f2, f3));
        // redirect to list action
        return new RedirectResolution(ListActionBean.class);
    }
}
