package com.crackwillow.struts.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.crackwillow.log.StdOut;

public class LogonButtonForm
    extends ActionForm {
  protected InnerButton button;
  protected String methodCalled;
  protected String username;
  protected String password;

  public LogonButtonForm() {
  }

  public void reset(ActionMapping mapping,
                    HttpServletRequest request) {
    methodCalled = null;
    username     = null;
    password     = null;
  }

  public String getMethodCalled() { return methodCalled; }
  public String getUsername()     { return username; }
  public String getPassword()     { return password; }

  public void setMethodCalled(String methodCalled) { this.methodCalled = methodCalled; }
  public void setUsername(String username) { this.username = username; }
  public void setPassword(String password) { this.password = password; }

  public InnerButton getButton() {
    this.button = new InnerButton();
    return button;
  }

  public void reset() {
    button = null;
  }

  public class InnerButton {
    private Integer x, y;
    public InnerButton() { }
    public InnerButton getCreate()   { methodCalled = "create";    return button; }
    public InnerButton getRetrieve() { methodCalled = "retrieve";  return button; }
    public InnerButton getUpdate()   { methodCalled = "update";    return button; }
    public InnerButton getDelete()   { methodCalled = "delete";    return button; }

    public void setX(Integer x) {
      if(y == null) { reset(); }
      else          { this.x = x; }
    }

    public void setY(Integer y) {
      if(x == null) { reset(); }
      else          { this.y = y; }
    }
  }
} ///;-)