mercredi 22 juillet 2009

Grails - App Engine - No validation available

Well, With the couple Grails/GAE, I move from one problem to another:(

The today issue came in two steps:

First I add some constraints to my object and notice that they are not managed. All objects violating these constraints are created.

I look at the generated controller code and note that the validate() method is not called before saving the object. I of course add it and everything works fine.

def save = {
def instance= new Item(params)
instance.validate()
if(!instance.hasErrors() ) {
try{
persistenceManager.makePersistent(instance)
} finally{
flash.message = "instance ${instance.id} created"
redirect(action:show,id:instance.id)
}
}

render(view:'create',model:[instance:instance])

}

Now I upgrade my inline application and note that it doesn't work anymore. There is the following server error if a constraint is broken (the case where there is no error works fine):

Error: Server Error

The server encountered an error and could not complete your request.

If the problem persists, please report your problem and mention this error message and the query that caused it.

If you want to check that behavior simply go to http://petclinic-grails.appspot.com/owner/add and try to create a owner with all fields empty.

It seems that the validate() is done by the hibernate plugin which is replaced by the appengine plugin.

Moreover I saw that flash messages don't have the expected behavior. They stay more than one page reload. I don' t have time to see why.

Aucun commentaire:

Enregistrer un commentaire