Writing the truly "dumb" UI

Writing the truly "dumb" UI

Old forum URL: forums.lhotka.net/forums/t/1380.aspx


thomasc@magenic.com posted on Tuesday, October 03, 2006

I am following the philosophy of writing a "dumb UI".  What do I mean by that?  I mean that I'm using the CSLADataSource, and doing using DataBinding all over the place.  I am using my Business Objects to validate my data.  I am taking the "hit" validating ONLY at the business object level, to reduce the maintenance/cost of ownership of the UI.  My UI will be used by a power-user.

Given that, I am attempting to write a FormView control to edit a CSLA Business Object.  My formview has nothing but the binding expressions, textboxes, labels and minimalist HTML.  I am binding my BrokenRules collection to a DataList Control and handling validation in that way.  I am not doing any ASP.NET Validation controls, and would be happy to avoid "double duty" validation, in favor of reducing maintenance/code.

Ran into a problem because I am using the DataMapper to map my form to the CSLA Object.  The DataMapper chokes on a field defined as an Int32, because it should be a required field in the UI.  I'd like to get the data into Business Object to be validated.  If I could, I could at a minimum, write a custom rule.

I was thinking that the datamapper should see string.empty coming in for an property defined as Int32, and default it to 0.  Right now, I am thinking I need to run all my e.Values that map to "Int32" fields, and filter them, shoving zero in, before I hand it off to the DataMapper.

-Tom

thomasc@magenic.com replied on Tuesday, October 03, 2006

Discussed this with another developer, who made a good point.  The DataMapper is targeted mostly for the web service proxy stuff.  I had seen it used in the webform sample.

My options are to simply wrap it, as suggested by my peer.  Alternately, I could just not use the DataMapper.  Its targeted for mapping A to B, not validating data, etc.

 

vivus replied on Tuesday, October 03, 2006

actually i find the data mapper pretty handy, you can easily map to other objects besides csla, like a custom configuration section.  .... you could create a custom property in your csla object to bind to,  and let the property filter the incoming values that is being fed to it by the mapper.  

as for the ui....    nothing worse than premature refactoring for preformance reasons or over architeching your solution.  besides... from a user's usability perspective... it sucks to have to wait for the page to refresh before validation occurs. 

besides... with csla 2.1 is pressing out rule descriptions  (GetRuleDescriptions()) and you can allow for public access to this through your object, you could parse those rules and extend your two way binding controls  (GridView, FormView, etc) to create validation on the fly.

then inside those controls you could check the datasource to see if it has an IDataError and act accordingly

Copyright (c) Marimer LLC