YAV-tags is a JSP library tag for YAV Javascript validation tool
YAV is a javascript library which provides web forms validation via Javascript.
YAV-tags makes easier to use this library from JSP pages and adds server-side validation.
<yav:validate>
<form action="save.do">
Username: <input name="username" type="text" />
<yav:rule value="username|required" />
Age: <input name="age" type="text" />
<yav:rule value="age|integer" />
<input type="submit" />
</form>
</yav:validate>
YAV-tags 1.0 beta is out!
You can download it at sourceforge YAV-tags project download page.
This release implements all YAV rules on the server side having no known critical bugs. During beta stage we expect to discover and fix any bug, in order to release a production-ready version.
In case you experiment any problem, please report it at the YAV-tags bug tracking system.
<filter>
<filter-name>YavTags</filter-name>
<filter-class>net.sf.yavtags.YavFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>YavTags</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
replacing *.do to suit your needs.
<servlet>
<servlet-name>YavServlet</servlet-name>
<servlet-class>net.sf.yavtags.web.YavServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>YavServlet</servlet-name>
<url-pattern>/js/yav.js</url-pattern>
</servlet-mapping>
<%@taglib prefix="yav" uri="http://net.sf.yavtags"%>
<yav:validate>
<form action="xxx.do">
...
</form>
</yav:validate>
Username: <input name="username" type="text" />
<yav:rule value="username|required" />
Age: <input name="age" type="text" />
<yav:rule value="age|integer" />
Rule syntax is YAV's one.
You could add a tip for a field like that:
Username: <input name="username" type="text" />
<yav:help for="username" message="Provide a short username" />
Custom masks are defined this way:
Birthday: <input name="birthdate" type="text" />
<yav:mask name="myDateMask" format=" / / " chars="0123456789" />
<yav:rule value="birthdate|mask|myDateMask" />
At the client side YAV-tags simply generates the Javascript and HTML code required by YAV library.
While generating this Javascript code YAV rules are stored into the web application's ServletContext object, mapped to the form instance.
When form date is sent to server, request is intercepted by a servlet filter, who checks stored validation rules.
In case of a validation error, it shows encountered errors via a ServletException.