I am looking for the best way to have the UI handle enabling/disabling (or readonly/ not readonly) text boxes for ReadOnly properties in a BusinessBase class. For now I have created these rules in the AuthoriationRules section but it seems like there might be a better/cleaner way:
AuthorizationRules.AllowWrite(
"BillTo", "CANNOTEDIT")Where there is no "CANNOTEDIT" group.
Thank You,
Rob
Thanks to everyone for the suggestions. I think I will go with overriding the CanWriteProperty as I want to keep everything as simple as possible and easily move to newer versions of the framework.
Rob
Are we talking about properties that are always ReadOnly, or a case where its determined by the user's permissions or other circumstances?
If it's the former, then the property is readonly by not having a set accessor. That is discoverable via reflection. I modified the ReadWriteAuthorization to do so.
Not sure if this is cleaner but you could add an attribute to all your read-only properties. Make sure you extend from a custom base class or implement an interface that is smart enough to detect if the property exists and return a bool to your custom control, notifying it if it should be read only or not. That would make the code a bit more readable I guess...
how does this sound....
going into the readWriteAuthorization component and adding a new extended property to say to always return "ReadOnly" | false so this "feature and be applied at design time and outside the BO code...
so this would rely on UI, seems that's the approach culprit is looking for,
an side-effect of this would be accessing the BO by other means than your UI will not contain this authorization mechanism, so maybe this is NOT what you are expecting...
Copyright (c) Marimer LLC