Scope Controller Objects

Controllers are created by extending the Scope API's Basic Controller

Controllers have three responsibilities:

  1. Set the model and the view (usually in the constructor)
    public LoginController() {         
        setModel(new CheckoutModel());         
        setView(mainView);     
    }
  2. Handle controls in the doHandleControl method Controllers respond to Control objects from two sources:
    protected void doHandleControl(Control inControl) throws ControlException { 
        if (inControl.matchesID(VALIDATE_LOGIN)) { 
            doValidateLogin();         
        } 
    }
    • Issued from Views as a result of user interaction
    • Issued from child Sub-Controllers in the chain of responsibility
    • Issued locally using the handleControl command
  3. Startup
    public void startup() {         
        LoginView myView = (LoginView)getView();         
        myView.setViewBounds(myView.CENTRED);         
        showView(myView);     
    }