Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Ajax Validation

Validation servlet vs Interceptor

  • Using a validation servlet requires the app developer to map any servlet filters for any action that is to be validated to the validation servlet as well.
  • Using a validation interceptor executes the validation within the context of any mapped servlet filters, as well as within the context of the action.

Custom Ajax code or Third Party Library

  • The DOJO Toolkit promises to be a very flexible and powerful toolkit, however they are only ion in the beginning stages. A lot of the code is coming from other dhtml toolkit projects that are very mature.
  • We only require a fairly simple xmlhttp layer a the moment. Dojo have released their dojo.io.bind package http://dojotoolkit.org/intro_to_dojo_io.htmlImage Removed which should be sufficient for us, however I think we can produce our own XmlHTTP code for now.
  • I have implemented some custom xmlhttp / javascript code http://www.drivelater.com.auImage Removed - do a search. It works in IE and FireFox.

Should webwork provide a static resource loader

  • We need to provide a developer friendly way of exposing webwork static resources - primarily javascript files
    1. User could copy them into a folder
      • This either requires a separate zip download or packaging these files within the jar
      • This is a bad idea because it is error prone when the user upgrades
  • Provide a resource loading servlet that serves the resources from the webwork jar
    requires a servlet definition and mapping in web.xml
  • could use a webwork.properties setting for the servlet prefix to allow user to 'mount' the static resources under a different prefix
    this makes jar upgrades easy and transparent
  • I have a prototype of this working in one of my apps - however it is restricted to mounting a single package on a single prefix. No support for multiple mappings. No Format
    
    i.e.  mount com.opensymphony.webwork.static at /webwork 
    request /webwork/validationAjax.js 
    loads  com.opensymphony.webwork.static.validationAjax.js
    
  • Get the validationServlet to serve the javascript code. Use '/validationServlet/client.js' as the url
    1. Any other ideas ?

Supported Browsers

  • We need to define what browsers we will support.

JavaScript API

  • In webwork WW 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
      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
      }
      
  • See this in action in webwork WW cvs head
    No Format
     
    /src/java/templates/xhtml/validation.vm
    /src/webapp/validationServlet.js
    /src/webapp/javascript-input.jsp
    
  • Cloves' provided example API :
    Code Block
    
    function addActionErrors(messages); // should messages be an array?!
    function addErroraddFieldErrors(fieldName, messages); // should messages be an array?!
    function clearActionErrors();
    function clearErrorclearFieldErrors(fieldName);
    function clearErrors(formName);
    

New

...

Theme