Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • In webwork CVS /src/webapp/validationServlet.js contains a sample ValidationServlet client javascript class. It handles the communication with the validation servlet, and exposes callbacks for handling the errors. NOTE : I think we can re-work this a bit. I currently have lots of onWhatever callbacks. I think we should just have onErrors, and let the template designer do what they want with the Errors object.
    • Sample Usage
    :
    • Code Block
    The errors param for the onErrors callback is a javascript object that has this structure
    • 
      var validation = new ValidationServlet('/validationServlet/client.js');
      validation.onErrors = function(inputObject, errors) {
      	// clear old errors
      	// display new errors
      }
      
    • The errors param for the onErrors callback is a javascript object that has this structure
      Code Block
      
      class Errors {
      	String[] actionErrors;
      	Map<String, String[]> fieldErrors; // fieldName is the key
    } var validation = new ValidationServlet("/webworkValidationServlet"); validation.onErrors = function(inputObject, errors) { // clear old errors // display new errors
    • 
      }
      
  • See this in action in webwork cvs head
    No Format
     
    /src/java/templates/xhtml/validation.vm
    /src/webapp/validationServlet.js
    /src/webapp/javascript-input.jsp
    

...