Validation in CSLA object

Validation in CSLA object

Old forum URL: forums.lhotka.net/forums/t/1423.aspx


dileepagarwal posted on Monday, October 09, 2006

Hi Rocky,

                   I am planning to use web service as a data portal channel in CSLA. I have some validation rules in my objects like name required and max length is not greater than 50 char. I am transferring these objects from server to remote client and binding them to .net data control in the client windows application. When a user will enter some data in the edit mode (assuming that user is not providing some required field data), Can I check the validation rules in the client side itself without sending the object to the remote server?

Thanks,

Dileep Agarwal

 

RockfordLhotka replied on Monday, October 09, 2006

Yes, this is really the whole point of the mobile object architecture enabled within CSLA .NET. You may want to review Chapter 1, as it covers the architectural concepts behind how and why this works.

dileepagarwal replied on Monday, October 09, 2006

Thanks for your response. It was my understanding also that the business rules would be validated on the client. But I tried to validate this behaviour in the PTServiceClient Project. When I entered the start date greater than end date and hit the save button (along with credentials), client calls the web service even though business rule is broken. Is this by design? Can we not avoid the call to the server since we know that the business rule is broken right on the client?

Thanks,

Dilepe Agarwal

 

RockfordLhotka replied on Monday, October 09, 2006

PTServiceClient is a client to a web service - it is not using the data portal's web service channel.

The data portal has a web service channel, which you can use to create an application where your business objects run on both the client and server.

Chapter 11 describes how to create a normal web service, and a client app for that web service. This client is PTServiceClient, and it is designed (following SO concepts) as a totally separate application from the web service itself. The CSLA-derived business objects only run in the web service, since that was my focus in Chapter 11.

What's interesting, and can be a brain-bender, is that the web service (built with CSLA objects) uses the data portal to talk to an application server - and that can be done using the web service data portal channel Geeked [8-|]

So your original question was about the web service data portal channel - in which case the validation rules will run on the client. You can test this using PTWin, and configuring the app to use the web service channel as described in Chapter 12.

Your follow up clarification is about PTServiceClient, which is a totally different scenario that does not use the web service data portal channel. In that context the client application is a separate application from the server application - and so can not share the business objects: that would violate service-oriented design principles.

Copyright (c) Marimer LLC