ViewController

Coordinator
Apr 30, 2008 at 5:55 AM
I'm almost done with a new class called ViewController which simplifies the usage of views in controllers.
It introduces a couple of new methods which can be used to render different templates.

The first method is called Render and gives you some magic. It automatically detects the name of the controller and the action name (this is done during startup and doesnt take any processing during normal usage). This means that you can focusing on passing variables to the views.

The variables are passed using key/values. You can either pass them directly like this:
public class MyController : ViewController
{
  public string MyMethod()
  {
    Render("firstName", "Jonas", "lastName", "Gauffin");
  }
}

or by using the Arguments property:
public class MyController : ViewController
{
  public string MyMethod()
  {
    Arguments.Add("firstName", "lastName");
    Arguments.Add("lastName", "Gauffin");
    Render();
  }
}

You can use both methods too. The Arguments property is cleared after each time Render have been invoked.

More info will come when the View doc is added to the wiki.