-
1. Re: home grown data validation
asookazian Jul 25, 2009 11:45 PM (in response to scphantm.scphantm.gmail.com)I've written custom Seam validator classes for doing live business validation (rather than Hibernate Validators which is domain/entity-specific). You can use the validator attribute in your JSF component which calls the Seam component's validate method.
Like this:
@Name("seamValidatorCodes") @Scope(ScopeType.CONVERSATION) @org.jboss.seam.annotations.faces.Validator public class SeamValidatorCodes implements javax.faces.validator.Validator, java.io.Serializable { public void validate(FacesContext context, UIComponent cmp, Object value) throws ValidatorException { if (foo) throw new ValidatorException(new FacesMessage("this code already exists for this repair Id, please select a different one")); } }
-
2. Re: home grown data validation
scphantm.scphantm.gmail.com Jul 26, 2009 12:07 AM (in response to scphantm.scphantm.gmail.com)ok, but ive already written and debugged thousands of lines of javascript code to validate my fields across the whole app and i don't like the idea of having to port it to java so they can run in a bean.
all i really need is a way to mark the form invalid. is there a way i can do something like
jQuery("form").attr("valid") = false
?
-
3. Re: home grown data validation
joblini Jul 26, 2009 12:44 AM (in response to scphantm.scphantm.gmail.com)Hi Willie,
In general, returning
false
from your event handler should cancel the processing.Use the JQuery event handling features to cancel the submit of the form.
Regards,
Ingo -
4. Re: home grown data validation
scphantm.scphantm.gmail.com Jul 26, 2009 2:02 AM (in response to scphantm.scphantm.gmail.com)ok, how would i do that. i do i capture the form submit event? problem with that is it would also capture my previous screen button and i will have to jump thru a few hoops to get around that. which now i typed that wouldn't be so hard. but how else would i use the event system in jQuery.
i guess i will just have to test out if capturing the form submit event will mess with the ajax functionality stuff.
-
5. Re: home grown data validation
joblini Jul 26, 2009 2:34 AM (in response to scphantm.scphantm.gmail.com)Are you returning
false
from the button'sonclick
event? I would expect that would to do the trick.