aspose file tools*
The moose likes Struts and the fly likes JSF and Clint Side Coding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSF and Clint Side Coding" Watch "JSF and Clint Side Coding" New topic
Author

JSF and Clint Side Coding

sanjay kumar
Greenhorn

Joined: Oct 11, 2001
Posts: 3
Hi,

I have been using JavaScript heavily for user input and business rules validation. As JSF is server-side technology, would it be recommended to replace such clint side coding by JSF. Isn't it degrade performance and increase serverside load?

Thanks,
Sanjay
Hans Bergsten
Author
Ranch Hand

Joined: Dec 01, 2003
Posts: 106
Originally posted by sanjay kumar:
Hi,

I have been using JavaScript heavily for user input and business rules validation. As JSF is server-side technology, would it be recommended to replace such clint side coding by JSF. Isn't it degrade performance and increase serverside load?

Thanks,
Sanjay


I don't think the "JavaScript or not" question has a different answer for JSF than it has for any other server-side technlogy. If you move validation to the server, independent of which server-side technology you use, there will be a lot more round-trips, and a page refresh for each round-trip. If this is acceptable or not depends on your environment (e.g., LAN users vs. Internet users), and possibly other factors.

JavaScript for some things, like early validation, is often a good idea for making the application easier to use and more responsive. Because of the differences in JavaScript versions between browsers, it can be time consuming to develop and maintain, though, unless you can control the browser choice of all users. But even if you do validation with JavaScript, you must also do it on the server, since the user can easily disable JavaScript in the browser.

Real business logic in JavaScript, on the other hand, is something I don't like. First, it means that the application work only if JavaScript is enabled in the browser. Second, it makes it mcuh harder to write automated tests for the application. These may or may not be serious issues for a specific application.

I prefer using JavaScript to add value for browsers with JavaScript enabled, but in such a way that the application works even without it. Custom JSF components can generate JavaScript code (for instance for validation) in addition to the markup, making it fairly easy to develop an application that combine client-side and server-side logic like this.


Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
bas duijzings
Ranch Hand

Joined: Apr 07, 2004
Posts: 83
thanks hans for this elaboration. I just tried to write exactly the same in another thread, since i had the experience of a customer wanting javascript turned off.
thankfully your reply more elaborate than mine, but then again i havent written a book.


have a nice one
 
Consider Paul's rocket mass heater.
 
subject: JSF and Clint Side Coding