Basic Q: Howto fill dropdownlist with items from service in View

Topics: CAB & Smart Client Software Factory
Oct 1, 2007 at 6:17 PM
Given a customer detail-view, one field is a dropdownlist.
This list needs to be filled with items that are available through a webservice-call: ReasonService.GetReasonCodes();

Suppose this dropdownlist is also needed on another screen. (for example a screen where users can search for customers with specific reasoncode.)

How would you do it?
Add a combobox to the customerdetailview, and let the presenter bind a list of reasoncodes to it?
So, this means adding a dependency to the ReasonService in the customerdetailPresenter, and duplicating this logic in every view/presenter that needs this dropdownlist.

Or should i create a new view-with-presenter with only a dropdownlist on it?
So i can reuse the logic of binding the reason-codes to the view?
How do i put this smarpart on the customerdetail-view then? Through a smartpartplaceholder?
And how would the selected-reasoncode get linked to the detail-field of the current customer-detail?

An example of this situation would be in the Global Bank Branch-example, when the reason-code dropdownlist in the AddVisitorToQueueView wouldn't be hardcoded.

Thanks in advance...
Oct 5, 2007 at 9:43 PM

What you could do is to encapsulate the dropdownlist in a specific SmartPart and then use it in other views through a SmarPartPlaceHolder.

For this, you will find handy this thread:

For more information about SmartPartPlaceHolder, see the topic Creating and Showing SmartParts in the Smart Client Software Factory help.
The logic needed is already bound to the Presenter of that SmartPart.

Please let me know if this helps.

Ignacio Baumann Fonay
Oct 7, 2007 at 11:42 PM

I'm not sure how your logic is done, but taking the drop down out of the equation, when calling your webservice, it returns data in a specific manner which even if not supported by your drop down could be handled through a service which then could be injected, so this should take care of your "duplicating logic" problem. I've haven't tried this with a pull-down, but this works well when using a service to modify our toolbar and all we're doing is referrecing an interface mapping the same functionality as the actual service.

The method described above should work perfectly as this would save you having to do both and you wouldn't even need to reference a thing, but I guess it may require a bit more work or does it really???