facebook

Form validation in JSF

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #226447 Reply

    kosl
    Member

    Hi,
    I have a problem with form validating using JSF.

    As we know the validator is not called when the validated field is
    empty. I know we can change it by seting the tag “required” but – then
    the error message is standard and same for all validated fields. I know
    how to change to message but I’m wondering whether I could have
    different error messages for different fields ?

    I would be grateful for any suggestions.

    kind regards

    karol oslowski

    #226450 Reply

    Riyad Kalla
    Member

    Karol,
    IIRC you can specify a “validate” method for your commandButton, in that method you could simply check all the fields Struts-style and add a FacesMessage for everyone that was empty where you wanted it to have an entry in it.

    #226486 Reply

    kosl
    Member

    Hello,
    Thanks, that’s indeed an option. The only problem with it is that I would prefer to indicate which fields are required in .jsp source and not in the backing bean as I think it’s more appropriate. Any ideas how to achieve that?
    Thanks a lot in advance!
    karol

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Form validation in JSF

You must be logged in to post in the forum log in