We've got some simple CRUD operations that we're doing just by declaring an 
entity-query and entity-home in components.xml, and building a list page and a 
form page that bind to them.  It works great, but one of our classes has a 
unique constraint on one of the fields.  Right now, if you enter data on the 
edit form and submit (this is bound to {#entityHome.persist}, the persist 
method throws a SQLException which is handled by the normal seam exception 
handling - I get a generic error page for the SQLException.  

I'd rather get a validation failure for the field *before* the persist fails, 
so I can show it on the edit form next to the field that needs to be unique, 
rather than handling it with an error page.  It'd be less nice but acceptable 
to show the error as a general Faces Message.   I guess I'd need to write a 
class that extends EntityHome and implements this behavior, but I thought I'd 
check if there was a better way.

We have a similar problem with delete when a foreign key is violated - I'd like 
to know what the recommendation is for handling the exception - Should I build 
a custom error page for SQLException, and try to parse the exception / message 
there to determine the key that failed?  Or is extending EntityHome and 
throwing a custom exception a better way?  Is there another better way?


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4059665#4059665

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4059665
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to