Button postbacks happening after OnViewReady

Topics: Web Client Software Factory
Nov 20, 2006 at 3:55 AM
Any suggestions on how to handle the situation for a button postback? Specifically, what happens if we have 2 buttons on a page. Each button causes the Presenter to run a different query, thus returning different results to display. The problem is that the button handlers don't get called until AFTER Page_Load (OnViewReady). Our answer was to move OnViewReady to OnLoadComplete and it solves everything. Thoughts?

Adam
Developer
Nov 20, 2006 at 8:12 PM
Moreover, we have split the OnViewReady method in two: OnViewInitialized and OnViewLoaded. OnViewInitialized should be called the first time the view loads, and OnViewLoaded should be called everytime the view loads:

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
_presenter.OnViewInitialized();
}
_presenter.OnViewLoaded();
}

Please have a look at today's drop to see this approach in action in the RI. You can also find this approach implemented in the Module Quickstart of previous drops.
Cheers,

Mariano
http://staff.southworks.net/mariano
Developer
Nov 20, 2006 at 8:17 PM
I'm sorry, I cut the first part of the post by mistake

In last iteration we have updated views and presenters in the RI. The main idea is that presenter sets the state in the view through properties, and the view decides when to display it (because the view is the one that knows about its life cycle). Our guidance is that you should use the Page.LoadComplete event to show data or bind controls, because it's fired after postback events.

Moreover, we have split the OnViewReady method in two: OnViewInitialized and OnViewLoaded. OnViewInitialized should be called the first time the view loads, and OnViewLoaded should be called everytime the view loads:

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
_presenter.OnViewInitialized();
}
_presenter.OnViewLoaded();
}

Please have a look at today's drop to see this approach in action in the RI. You can also find this approach implemented in the Module Quickstart of previous drops.
Cheers,

Mariano
http://staff.southworks.net/mariano