This project is read-only.

Show customer info

Oct 1, 2007 at 7:35 PM
I have an app with three buttons : Denver, Chicago, Detroit
When I press a button - I want a modaless form to be shown with two text boxes: City name, and population. There is a globaly available service ICityInfoService that providel population.

Is it possible to implement this with CAB?

Specifically, what code on the button's (let's say Denver) command handler will look like?

ICityView view = workItem.SmartParts.AddNew<CityView>();
workItem.Workspaces["WindowWorkspace"].Show(view);

will not work, since view does not know what city to show.

Using either:
new View("Denver")
or
view.CurrentCity = "Denver";
or
view.Presenter.CurrentCity = "Denver";
is a smell, since it would be a violation of MVP, where view shoul be accessed through presenter.

Ideas?
Oct 3, 2007 at 3:29 PM
Edited Oct 3, 2007 at 3:34 PM
How would you do this in another platform such as ASP.NET? Chances are that in ASP.NET you will redirect to another page. The target page, "CityView" in this case would then do something like this....
  • OnPageLoad, check for values in the query string -OR-
  • OnPageLoad, check for values in the request header -OR-
  • OnPageLoad, check for values in the session -OR-
  • OnPageLoad, check for values in the items collection of the Context, etc etc

In the scenarious above "CityView" is either given the data via query string or request header OR "CityView" gets the data when it wants it.

I can think of 2 ways to do this in CAB -