XAF is a powerful business application framework for .NET developers allowing you to concentrate more on business rules without the many distractions and tedious tasks normally associated with the traditional Windows, Web and Mobile development.
Search This Blog
Monday, December 21, 2015
Avoid auto-saving a master when a new non-aggregated child is created and making the New Action available for many-to-many lists
In v15.2.4 we have added the LinkNewObjectToParentImmediately property to the XafApplication and NewObjectViewController classes.
By default, XafApplication.LinkNewObjectToParentImmediately is set to true to keep the behavior of existing applications unchanged (a new object linked to the master object is created and the master object is committed when the New action is executed in the nested List View). However, in new applications created in the 15.2 version, the default value is overridden to false in code generated by the Solution Wizard.
Use XafApplication.LinkNewObjectToParentImmediately to change the behavior globally (note that this property is hidden in the Application Designer and you can set it only in code). Use NewObjectViewController.LinkNewObjectToParentImmediately to change the behavior for a specific View. The behavior of aggregated collections is not changed.
There are several positive results from this LinkNewObjectToParentImmediately=false change:
1. A reference to the master object is visible in the new child object immediately.
2. The master object is not committed and the link is not created when the New action is executed in the nested List View. At the database level that means that the reference to the master table is not added to the new child record immediately. The link is created later when the child object is committed. To keep the link, a user should save the master object; otherwise, the unlinked child object will be saved.
3. The New Action is now available directly in the nested ListView or the Link dialog for many-to-many XPO associations!
There were a lot of customer requests for the last two things, so I hope you will like this news. Please let me know what you think in comments.