Thank you for your reply ... your info it's very useful
Can I ask you only one question: the practice ... if it's possible, I want to show you what I doing
I have a function:
Code:
import java.util.Collection;
import java.util.HashSet;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.hibernate.validator.ClassValidator;
import org.hibernate.validator.InvalidValue;
public class ContactValidation {
Collection errors = null;
public Collection validate(Class clazz, Object obj) {
InvalidValue[] invalidValues = null;
try {
errors = new HashSet();
ClassValidator classValidator = new ClassValidator(clazz,loadproperties());
invalidValues = classValidator.getInvalidValues(obj);
System.err.println(" invalidValues " + invalidValues);
for (int i = 0; i < invalidValues.length; i++) {
errors.add(invalidValues[i].getMessage().trim());
System.err.println(invalidValues[i].getMessage().trim());
}
} catch (Exception e) {
e.printStackTrace();
}
return errors;
}
public ResourceBundle loadproperties() {
String baseName = "Contact.properties";
// ebook.properties is properties file name
ResourceBundle rb = null;
try {
// Get the resource bundle for the default locale
rb = ResourceBundle.getBundle(baseName);
} catch (MissingResourceException e) {
// The resource bundle cannot be found or
// the key does not exist in the resource bundle
}
return rb;
}
}
witch get the errors into Collection object.
in Action class I have next code:
Code:
public String insertContact(){
ContactValidation c = new ContactValidation();
Collection err = c.validate(Contact.class, contact);
if(err.size()>0){
this.setActionErrors(err);
//return Action.ERROR;
}
contactDAO.insertContact(contact);
return "SUCCESS";
}
where Contact contact;
in final, I have the same error ... I'm already desperate with HV
thank you again.