struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31509] New: - html:javascript tag doesn't work right with jsFunctionName set
Date Fri, 01 Oct 2004 23:50:34 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31509>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31509

html:javascript tag doesn't work right with jsFunctionName set

           Summary: html:javascript tag doesn't work right with
                    jsFunctionName set
           Product: Struts
           Version: 1.2.4
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Validator Framework
        AssignedTo: dev@struts.apache.org
        ReportedBy: erh+apache@nimenees.com


1: create a custom <validator> that has the "jsFunctionName" attribute set.
2: create a page that includes the html:javascript tag.
3: Examine the generated javascript for the validateMyForm() function.
Notice that the line that sets the formValidationResult variable calls the
function defined by the validator tag "method" attribute instead of the correct
one specified by jsFunctionName.

Here's an example, where I tried to create a slightly different "required" field
validation:
<validator name="required_fullmsg"
              classname="org.apache.struts.validator.FieldChecks"
                 method="validateRequired"
           methodParams="java.lang.Object,
                         org.apache.commons.validator.ValidatorAction,
                         org.apache.commons.validator.Field,
                         org.apache.struts.action.ActionMessages,
                         javax.servlet.http.HttpServletRequest"
                    msg="errors.detail"
             jsFunction="org.swapsimple.javascript.validateRequiredFullMsg"
             jsFunctionName="validateRequiredFullMsg"
        />

I copied org.apache.commons.validator.javascript.validateRequired.js and changed
 line 17 to look like this:
oRequired = eval('new ' + formName.value + '_validateRequiredFullMsg()');

This works with a small patch to JavascriptValidatorTag.java (attached).

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message