Ticket Q494110
Visible to All Users

Server Side Validation in XAF

created 12 years ago

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

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

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).

    Comments (1)

      Thanks Dennis for your example code!
      Hope you will enhance middle tier capabilities like above and add them to XAF documentation in the future.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.