Asynchronous Client side form validation in WW2.2 is super easy, and super cool.

Here is what I learned while getting it running.

1) Have WW Validation working already. Go for it, use something cool like a nested validator with a email validation rule.
2) You need the latest DWR jar in WEB-INF/lib.
3) Add this code to your web.xml

    <servlet>
        <servlet-name>dwr</servlet-name>
        <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>dwr</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>

4) Update an existing form. Depending on how extensively you used WW form controls this step might take a few moments. The controls all need to be generated via WW tags. No being lazy and just using <form name="xxx". Ill explain why this is in a moment. You will need to follow these rules to stay on the happy path:


<script src="/agility/webwork/validationClient.js"></script>
<script src="/agility/dwr/interface/validator.js"></script>
<script src="/agility/dwr/engine.js"></script>
<script src="/agility/webwork/template/xhtml/validation.js"></script>
<form namespace="" id="input_form" name="SubmitUser" action="/agility/SubmitUser.action">

<p>
<label for="input_form_bo.firstName" class="label"><span class="required">*</span>First Name:</label>
<input name="bo.firstName" size="20" value="admin" id="input_form_bo.firstName" onblur="validate(this);" type="text">
</p>
<input type="submit" name="submit" value="Save" class="primary"/>
</form>
<p>

5) Thats about it. You should be off to the races using asynchronous client side validation!!!