Hello XAF Team,
As XPO does not support server-side validation, XAF provides Validation Module to perform client side validation.
But, how can I achieve server side validation in XAF?
For example, create a seperate IObjectSpace, and create objects within the IObjectSpace, and then commit changes. XAF does not provide server-side validation when committing changes, so invalid data is saved (no exception is raised to prevent IObjectSpace from comitting changes to database).
Regards,
James Zhong
Server Side Validation in XAF
Answers approved by DevExpress Support
Hello James,
It is currently possible to execute certain business logic on the application's server side:
C#...
SecuredDataServer dataServer = new SecuredDataServer(
connectionString, XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary,
securityProviderHandler, null, OnCommitting);
...
private static void OnCommitting(object sender, DevExpress.ExpressApp.Security.ClientServer.DataServiceOperationEventArgs e) {
foreach (object item in e.ObjectSpace.GetObjectsToSave(true)) {
//Execute some logic here...
…
The latter approach is possible, but we do not yet have much documentation on it as we are currently improving usability in this particular scenario.
Finally, it is also possible to throw validation errors in the overridden OnSaving method of your persistent object (as recommended at XPO Best Practices).
Thanks Dennis for your example code!
Hope you will enhance middle tier capabilities like above and add them to XAF documentation in the future.