Expose JsFunction property in ValidatorAction
---------------------------------------------

                 Key: VALIDATOR-262
                 URL: https://issues.apache.org/jira/browse/VALIDATOR-262
             Project: Commons Validator
          Issue Type: Improvement
          Components: Framework
    Affects Versions: 1.3.1 Release
         Environment: Any
            Reporter: Jeff Tsay


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 
(com.ngweb.jsf.xul.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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to