Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JSF Vs JavaScript

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a new learner of JSF.
I have a very basic question.
If JavaScript can do form validation at client side then why to use JSF to do the same thing on server side which incurs network traffic?
 
Saloon Keeper
Posts: 25461
180
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
1. Because sometimes people turn JavaScript off, for one reason or another. Including dire Microsoft security alerts about the latest JavaScript-related exploit.

2. Because trusting the client to provide sane data is insane. A considerable percentage of security exploits work because someone has hacked the client-side processing to return unexpected data in the hopes of breaking the server.

Use JavaScript to provide a faster user feedback. Use server-side validation to protect yourself. If you're using JavaScript as your first line of defense, you won't have to pay the server validation overhead until all client-side edits have permitted the server request to go through. And at that point, the "network traffic" is the data being updated, so there's no real penalty.

The one penalty you do pay of course, is in whatever work you do to duplicate the validation, But that extra investment in robustness is what separates the "toy" programs from enterprise-grade applications and why the hypothetical 10-year old kid isn't the equivalent of a trained software developer.

Of course, if you use a JSF tagset that can automatically generate both the client- and server-side validations from the same specifications, I won't stop you. In fact, I'm always on the lookout for tools of that type.
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And by the way, your picked subject for your post is too much misleading.
 
Tim Holloway
Saloon Keeper
Posts: 25461
180
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

John Todd wrote:And by the way, your picked subject for your post is too much misleading.



 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:

John Todd wrote:And by the way, your picked subject for your post is too much misleading.




When I read the subject, I thought he is asking about JavaScript -the language- and JSF -the framework- but it turns out that he is asking about client-side validation and why to duplicate it on the server.
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use javascript sometimes for updating calculated values in a form before submitting the form. In this way a customer can see what the effects of his actions are if the form is submitted. Par example I subtract the total inventory in the webpage when the customers uses a part within the inventory. This would be the inventory if the action is submitted and processed. Changing colors depending on the values is an another application of javascript.

Thereby I have a small change that the final submit fails, but normally this will not be the case.

 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic