Visible Properties

Visible Properties

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


stanc posted on Thursday, August 02, 2007

I have cases where depending on security settings, certain users cannot see certain fields. Unfortunately the fields that need to be hidden can be any non-required field. Each location has their own business rules concerning this and there is no way to capture all of them because they change.

So, I want to try and control this as much as possible in my BO. And whatever I can't completly control in the BO, I at least want to provide the need methods to the UI developer to help implement this. One thought I have is to add new read only properties to the BO that need this functionality. The properties would return a boolean for the visibilty of each property, and they would be set based on the user and the security settings in the system. This seems a little messy to me, but is all I can think of at the moment.

Has anyone done anything like this before? Any ideas on an approach I should take?

Thanks

Stan

mtagliaf replied on Thursday, August 02, 2007

Are the rules regarding visibility data-driven? (are they stored in the DB). If so, I would recommend a new CLSA collection object that loads the visibility data, and the UI developer would load this collection up and make use of it to show/hide the UI controls.

matt tag

stanc replied on Thursday, August 02, 2007

It will be data-driven. I thought about using just a collection, but then the UI developer will have to write more logic to handle it. By using the additional properties, the UI developer can just bind the property to the visible property of the control.

But I may be missing something, so if you could elaborate more on the use of the collection it may help. Again, I am trying to make the UI developer's job as easy as possible.

Thanks for the input.

RockfordLhotka replied on Thursday, August 02, 2007

It seems like you could use the authorization capabiliies of CSLA to do this. If the control should be hidden, then presumably it is because the user isn't authorized to read the value? That's the purpose of the CanReadProperty() functionality.

Your UI must drive off CanReadProperty() to hide appropriate controls. In Windows Forms and WPF CSLA includes controls to help you do this. For grids and for the web you must do it yourself.

But at least the logic for the rules themselves can be encapsulated in the business objects.

Copyright (c) Marimer LLC