Passing values in events or through the Items collection

Topics: CAB & Smart Client Software Factory
May 9, 2007 at 1:32 PM
Suppose I have 2 views and 1 work item controller - Search Criteria and Search Results.

When the user clicks on the Search button it uses a service to do the search. What would be the best way for it to get these results to the results view. The 3 best options I can think of are:

1 - Put the results in the Items collection then raise an event to let the controller know results have arrived. The results screen can then have a ComponentDependency on the result.

2 - Have the controller new up both views. The results view can then subscribe to an EventArgs<SearchResults>.

3 - Have the search criteria raise an event with the results. The controller can put the results in the Items collection and then new up the results view.

Apologies for these simple questions! I'm getting there.

Thanks,

Graeme
Coordinator
May 9, 2007 at 2:15 PM
I would use a service with two events OnSearch and OnSearchCompleted.
  • The OnSearch will be raised by the Search button of the SearchCriteria smart part presenter (you can pass a Criteria on the event args).
  • The service will subscribe to that event (ThreadOption.Background) and perform the search on background.
  • When it finishes raises another event OnSearchCompleted with the search results
  • The SearchResults smart part presenter will be subscribed to that event (ThreadOption.UserInterface) and will show the results

In short, use a service as the glue.

Matias
http://staff.southworks.net/blogs/matiaswoloski
May 9, 2007 at 4:33 PM
Thanks for your explanation Matias,
I have searching to solve a similar issue.
I have a TabedWorkspace in a view with a lot of Instance of a ResultsView smart part, and i use only one instance of a DateInterval view (showed in a decWorkspace) to Change de date interval of the data in the active ResultsView smart part.
When i create the ResultsViews in the TabedWorkspace , i iterate in a dataset to create as many ResultsView smart parts as i have of sets of data. To do this i use the coleccionItems of the workitem to pass the dataset that is need to be dispaly in each ResultsViews.
So if the ResultsView smart part presenter will be subscribed to the OndateIntervalChange event,
he doesn´t know how to retieve the good dataset filter by the new date interval.
How can i do this properly.

thanks for your response