You could write a validator for this
@Name("uniqueValidator")
| @Validator
| @Transactional
| public class UniqueValidator {
|
| @In EntityManager entityManager;
|
| public void validate(FacesContext facesContext, UIComponent component, Object
value)
| throws ValidatorException {
| Foo foo = (Foo) value;
| Foo foo1 = entityManager.createQuery("select f from Foo f where
f.uniqueProperty = :uniqueProperty").setParameter("uniqueProperty,
foo.getUniqueProperty()).getSingleResult();
| if (foo1 != null && !foo1.getId().equals(foo.getId)) {
| throw new ValidatorException("Unique Constraint Violation");
| }
| }
| }
In fact, we could have a generic version of this in Seam as part of s:validate.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4059691#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...