Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-262

Expose JsFunction property in ValidatorAction

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.3.1 Release
    • None
    • JavaScript
    • None
    • Any

    Description

      Exposing the JsFunction property in ValidatorAction would make it possible for other tools to include Javascript routines as external scripts, inside of inline Javascript in an HTML page. This would reduce the size of pages containing client-side validation and the overall size of content transferred from server to browser.

      Shale commons validator integration uses commons validator to provide both client side and server side mapping. When the JSF renderer writes the validation Javascript code, it looks up the ValidatorAction for each validation routine. It then inserts the Javascript inline using ValidatorAction.getJavascript(). Since this code never changes and is likely to be used multiple times, I would like to instead insert something like this:

      <script src="/weblets/validator/validateEmail.js" />

      I can almost do this with Shale commons validator and Weblets, but I need to get the fully qualified resource name from the ValidatorAction, i.e. JsFunction. I can then map the resource name (org.apache.commons.validator.javascript.validateEmail) to a URL ("/weblets/validator/validateEmail.js") using Weblets.

      The entire change required is adding:

      /**

      • Gets the fully qualified class path of the Javascript function.
      • This is optional and can be used instead of the Javascript property.
      • @return The Javascript function's fully qualified class path, or
      • null if this property has not been set.
        */
        public String getJsFunction() { return jsFunction; }

      to ValidatorAction.java.

      After the change above, I am able output <script src=""> tags in Shale commons validator.

      The change could also be used in other web frameworks to do the same thing.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jctsay Jeff Tsay
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 0.5h
                0.5h
                Remaining:
                Remaining Estimate - 0.5h
                0.5h
                Logged:
                Time Spent - Not Specified
                Not Specified