• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF: Performance for Mr.Bill

 
Dharani Dharan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Without JSF we achieve some of the funnctionality that JSF provides in the Client side Using Java Script. With JSF employing another Servlet to do some of its jobs and model classes and Handlers will it make a big performance difference between an application that uses Javascript for these purpose and another application using JSF and Struts or ATO.
Thanks,
Dharani.
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've also been thinking a lot about that recently. A lot of web frameworks, like JSF, handle all validation on the server, even mundane "field required" checks. I currently help maintain a web app that uses client side scripting to validate forms. I definitely feel that business logic validation belongs on the server, but I'm wondering if more basic validation (required, valid input characters, etc) should be on the client for performance reasons. In some respects it seems wasteful to hit the server just to determine that the user left a required field blank.
In a JSF environment, what are anyone's thoughts on creating custom components that include bindings to javascript functions for basic validation?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion such validation should occur on both the client and the server.
The server must perform validations since it cannot rely upon the fact that client-side validation has taken place -- it's just too easy to circumvent. But it's usually a nicer "user experience" if simple client-side validation can be performed.
So I always validate all incoming data on the server, but add client-side validation where appropriate. But never, ever assume that the client-side validation has taken place.
 
Bill Dudney
Author
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Great discussion! I agree with Bear that the validation should be in both places. The current JSF render kit in the RI does not supply JavaScript validations to the rendered output but there is nothing that prevents it but time & money for the RI developers.
So I would expect that one of the implementations (MyFaces, Oracle etc.) will have some renderers that have validators put JavaScript on the client. Then the validation would occur in the browser and on the server side.
This is my expectation, not my knowledge.
One more discussion point. I think that most validation belongs in 3 places. The browser, the web tier and the business tier (i.e. your ejb's or persistent objects) so that your underlying business functionality can be exposed via web services or Swing or some other UI and will still properly validate the data before putting it into the DB. Thoughts?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The browser, the web tier and the business tier ... Thoughts?

Absolutely agree. In what I consider a properly architected application, the business tier would be completely UI-agnostic and could not assume that the web tier even exists, let alone assume that validation (on either the client or server side) has been performed.
[ March 03, 2004: Message edited by: Bear Bibeault ]
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the insight guys. I agree with you too. Mostly I was concerned with the performance implications of not doing the basic validation on the client, but I definitely see the value of still doing the validation on the server.
 
Bill Dudney
Author
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something that I think would be cool but I have not had time to really think through is an XDoclet bit to generate the JavaScript for the browser side, a validation method for the web tier and a business tier validation method.
Thinking out loud:
For the same reason you don't want to pay the hit to go from browser to server to find out if 'fname' is required you don't want to go from web tier to db or business tier. So a local (i.e. web tier) copy of the validation would be helpful.
The problem is that all the code is re-implemented in three places. Wouldn't it be nice to specify it once and have it generated in the other three places.
It would be cool to have the code generated.
There are some issues with XDoclet being able to do this. There has to be too many assumptions about how everything gets put together with XDoclet.
Perhaps with the JSR175 work there will be a way to put the validations into one place...
Just dreaming I guess but it would be cool.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!