• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JSF client side validation

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

more than 6 years ago I worked last time with JSF 1.2. At this time the default validation mechanism just happened at the server and not a the client. If someone would like to add an additional client-side validation through Ajax, he was responsible to implement it on his own. Is this with JSF 2.0 still the case, or is there something like an automated client-side validation that would also generate this JavaScript code? Finally this would mean from my understanding that the same checks would executed twice (at client- and at server-level).

Regards,
Christian
 
Ranch Hand
Posts: 32
1
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, even in JSF 2.0 its all server side.  So for client side validation you either have to roll your own or find a suitable js library.  I rolled my own for a company years ago and haven't found anything better than what we developed because you want a full featured client side js framework to be able to provide the following.

1) color the offending inputs
2) provide popups next to the inputs upon focus to tell what the problem is
3) validate all inputs at the same time so the user doesn't get that annoying "I'll only tell you one problem at a time behavior"
4) Internationalization
5) Unlimited custom logic
6) Built in date logic

Another thing worth noting, is that you don't want the error messages buried in your html markup the way Dojo validation does.  You want them in a javascript array because if you add a new message you don't want to have to go hit all your pages that use that validator.  I hope this helps. If you find a really awesome framework, let us know.
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your feedback Matt.
 
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, JSF still doesn't do client-side validation.

Actually, based on my experience, client-side validation for many things can end up so messy that I found it easier to use server-side validation with AJAX.

One thing you can do in JSF2 is define your own custom tags using XML and add validation javascript to those tag definitions. I recommend doing XML custom tags over binary ones because they're easier to code and not as likely to break the next time JSF's internals get overhauled.
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic