• Post Reply Bookmark Topic Watch Topic
  • New Topic

ajax server-side validation  RSS feed

 
Anthony Taylor
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone point me in the direction of the correct way to handle server-side validation using ajax and jsf. I would like to use the validation tags provided with jsf but I would like to use ajax to submit the form and receive the error message from the jsf framework. This has been pretty mind numbing so far. if anyone has any information on this it would be greatly appreciated.
 
Sergey Smirnov
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what Ajax4jsf can do.
https://ajax4jsf.dev.java.net/

If you have an action method that returns the message valid for one of the navigation rule, the navigation will perform only if the validation is passed OK. So, if you have validation errors, the server-side validator produces error messages that user can see.

If you already has a page you want to invoke the server-side validators on, do the following:
* add Ajax4jsf to your project
* replace h:commandButton with a4j:commandButton (the attributes are the same)
* surround h:messages with a4jutputPanel. I.e:

<a4jutputPanel ajaxRendered="true">
<h:messages />
</a4jutputPanel>

P.S. If it is possible, use <redirect /> for the navigation rule. It changes the URL shown in the browser. Similar to the regular JSF request, Ajax request will not change the URL in the browser without using <redirect />
[ December 26, 2006: Message edited by: Sergey Smirnov ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!