Our UI designer has a view interface that has a write only property defined for the business object being exposed. The presenter is responsible for calling code on the controller to actually load the business object and set the property on the view. We were able to propagate the events to the controller and get things working but this solution was described as ‘funky’ and the action item that arose from this 'funky' solution was to modify the CslaDatasource to allow directly setting the DataSource for the CslaDatasource vice using events.
I have read the discussions in this thread and while very helpful in explaining the differences between using an objectdatasource and the csladatasource I’m still a bit confused. Is there any reason why I can’t directly set the data source for the CslaDatasource? This would make my UI designer happy and allow me to continue using Csla normally with this one exception.
The more I work with web applications the more I like winforms! Things that are easy and straight forward in a winform seem twice as hard to implement and only provide a fraction of the functionality of a winform. Ajax is all the rage and it only simulates the functionality we have had in winforms for years. With WCF we have the access from anywhere previously provided only from the web PLUS all the responsiveness and ease of use of a web form.
I don't believe that ObjectDataSource has a Datasource property - not according to this MSDN documentation (unless my tired-at-the-end-of-the-day eyes are missing something).
The ASP.NET Web Forms data binding infrastructure is designed to use an eventing scheme like the one in CslaDataSource.
The ObjectDataSource invokes methods on one object to get at the data object. CslaDataSource does a similar thing, but raises events rather than calling an external object.
Either way you have to write the same kind of code - with ObjectDataSource in a method, and with CslaDataSource in an event handler (which is a method) - so I guess I don't understand the issue?
In all cases this is UI layer code - the UI is ultimately responsible for calling the right factory method to get back a business object.
I'll need to
apologize for a typo in my earlier thread. I meant to refer to the ObjectContainerDataSource
not the ObjectDataSource. Apparently the ObjectContainerDataSource is
an object included in the Microsoft Enterprise Library Web Client Software
Factory (WCSF) which provides a Model View Presenter (MVP) implementation.
The main difference between it and the 'vanilla' ObjectDataSource seems to be
the .DataSource property that can be directly set on the view by the presenter after
a call to the controller in their MVP implementation.
One item that jumped out at me in the ObjectContainerDataSource documentation is
the requirement of a parameterless constructor, which means the object is
allowed to bypass the factory methods of the CSLA business object. So I
am assuming many (all?) the shortcomings you pointed out here will exist in
this implementation also.
I haven’t looked at the WCSF, so I can’t comment.
I have looked at the ASP.NET MVC implementation, which is a real
product that is shipping in a few months. It doesn’t use data binding at
all, and so doesn’t use DataSource controls. It works very nicely with
CSLA – I really like it a lot. My guess is that having a real MVC product
will cause the quasi-open-source variants like WCSF to fade away, because they
are unsupported and don’t have the budget, while ASP.NET MVC will be
supported and has a budget :)
If you stick with WCSF, you might have to create a “CslaContainerDataSource”
control that is WCSF friendly, and works with CSLA objects.
Every time there’s a new UI framework, I do have to figure
out what plumbing is required to make that framework and CSLA play nicely. But
I only do this for the .NET framework itself – which is plenty to keep me
busy. There are dozens of other UI frameworks out there, some from Microsoft,
some not, but none are part of .NET itself, and so are outside of my scope.
Rocky
So you want to have CslaDataSource maintain a reference to the
business object?
Today it has no reference, and it is up to you to manage the
business object in your event handlers – with the exception of data
retrieval, where the object does flow through the datasource to data binding.
If the datasource had a reference to the business object, how
would you want it to be expressed? Obviously none of the current eventargs
objects have it, for example, because it isn’t part of the Web Forms
model.
Rocky
Copyright (c) Marimer LLC