hibernategwtejbrequestfactorygwt-editors

GWT requestfactory validate entities on external server


Im usign gwt 2.7.0 request factory. Edit: Im not using client side validations, only server side validations (hibernate annotations)

The entity im trying to edit is called "Article.java".

In a normal scenario, i would edit an Article on the client side with a ArticleEditor (Extends from Editor). When the article reaches the server, validations are excecuted. If any validation goes wrong, the client side will receive a "Set < ConstraintViolation < ? > > oErrors " which i can use in the EditorFramework to show the errors on the form.

In my particular case i have two servers :

A = One is using gwt to edit ValueProxy (pojos) (Does not persist the entity).

B = Other has access to the database (hibernate), accesed by A via stateless EJB.

I made a copy of Article(do not contain any hibernate annotation, simple pojo) called "PersistentArticle.java" (contains all hibernate annotation logic). Bothe classes have the same attributes and methods.

After the Article is edited, it reaches the server side A, then i send the object via ejb message to server B. In B i create an instance of PersistentArticle from the Article class and try to persist. If any validation goes wrong it generates a javax.validation.ConstraintViolationException.

The problema is that i dont know how to bind the ValidationException generated by server B with the requestFavtory and the EditorFramework which are in server A , so i could show errors in the form. (In the normal scenario this is done automatically by requestfactory in server A)

Back in the clien side, i receive the ValidationException in the

public void onFailure(ServerFailure oError) method from the Receiver of the request and not in the

method onConstraintViolation(Set< ConstraintViolation< ? >> oErrors, which is the ideal.

Is it possible what im trying to do ? What do you recommend ?

English is not my mother tongue; please excuse any errors on my part.

Thaks in advanced.


Solution

  • RequestFactory will validate your objects before calling service methods, and abort everything if there are violations. If your validation doesn't fit in this scheme, then you can't take advantage of it.

    Your validation is done within a service method, so errors have to be sent back in the return value if you want to handle them on the client side. That means moving them to value proxies, and back to constraint violations on the client side.