Search This Blog

Thursday, October 25, 2012

How to disable certain actions for a new record in XAF



You may find this post helpful: as it describes a quite common business requirement:

"1. Check whether the key property is assigned or not (you can check this either in the TargetObjectsCriteria property for your Action or in an Appearance rule).
It will suffice your needs if you do not use the BaseObject.OidInitializationMode.AfterConstruction.
2. Use the IsNewObject method provided by the Session/ObjectSpace types. For instance:
public bool IsSavedObject { get {return !Session.IsNewObject(this); } }"

For instance, in the standard DeleteObjectsViewController we use the second approach:

!View.ObjectSpace.IsNewObject(((DetailView)View).CurrentObject) || (View.ObjectSpace is NestedObjectSpace)); 


No comments:

Post a Comment