DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26782>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26782

JavaScriptValidatorTag produces invalid JavaScript function name when form is subclass 
of ValidatorActionForm

           Summary: JavaScriptValidatorTag produces invalid JavaScript
                    function name when form is subclass of
                    ValidatorActionForm
           Product: Struts
           Version: 1.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Validator Framework
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


When using the JavaScriptValidatorTag to validate a form that is a subclass of 
ValidatorActionForm (to validate on a per action basis), the tag produces an 
invalid JavaScript function name containing one or more '/' characters. In 
this case, the validator-rules.xml form element's name attribute value must 
match the struts-config.xml action element's path attribute value which 
contains one or more '/' characters that need to be removed to create a valid 
JS function name, e.g., "function validate/MyAction(...) {...}" is invalid JS. 
Below is the current code with a possible patch following:

    /**
     * Returns the opening script element and some initial javascript.
     */
    protected String getJavascriptBegin(String methods) {
        StringBuffer sb = new StringBuffer();
        String name =
            formName.substring(0, 1).toUpperCase()
                + formName.substring(1, formName.length());


        sb.append(this.getStartElement());

// Possible patch: *********************************************************

    /**
     * Returns the opening script element and some initial javascript.
     */
    protected String getJavascriptBegin(String methods) {
        StringBuffer sb = new StringBuffer();
        String name = formName.replace('/', '_'); // remove any '/' characters
        name = name.substring(0, 1).toUpperCase()
                + name.substring(1, name.length());

        sb.append(this.getStartElement());

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to