You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Richards, Devin N (Devin)" <de...@lucent.com> on 2002/08/26 23:47:23 UTC

1.1-b2 validator question

I am using 1.1-b2 for two forms. Each form has it's own Form, Action, Validation.xml, ApplicationResources.properties and JSP files. The JSP's use the <html:javascript> tag to utilize the client side JavaScript validation methods. When the plug-in is configured like this:
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml,/WEB-INF/classes/com/myco/app1/app1Validation.xml, /WEB-INF/classes/com/myco/app2/app2Validation.xml" />
    </plug-in>

All of the validations seem to work correctly. However when it is configured like this:

    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml,/WEB-INF/classes/com/myco/app2/app2Validation.xml, /WEB-INF/classes/com/myco/app1/app1Validation.xml" />
    </plug-in>

When I navigate to /app2.do I end up with a bunch of JavaScript code dumped out on the page. 

When I look at the JSP source code when the form works the <html:javascript> is replaced by:

<SCRIPT LANGUAGE="Javascript1.1"> 
<!-- Begin 

     var bCancel = false; 

    function validateRmaForm(form) {                                                                   
        if (bCancel) 
      return true; 
        else 
       return validateRequired(form) && validateEmail(form) && validateMaxLength(form); 
   } 
	...snip...

When I look at the source code when it doesn't work the <html:javascript> is replaced by:
function validateMaxLength(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
	...snip...

It does not start with the "normal" <SCRIPT> tag , nor the comment. Any ideas? Would the two Validatoin.xml files help in debugging? Is this a bug?

TIA

-Devin

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: 1.1-b2 validator question

Posted by Donald Ball <db...@rhoworld.com>.
On 8/26/2002 at 5:47 PM Richards, Devin N (Devin) wrote:

>When I navigate to /app2.do I end up with a bunch of JavaScript code
>dumped out on the page. 
>
>When I look at the JSP source code when the form works the
><html:javascript> is replaced by:

<snip/>

>It does not start with the "normal" <SCRIPT> tag , nor the comment. Any
>ideas? Would the two Validatoin.xml files help in debugging? Is this a
bug?

I can't say why multiple validation files would mess you up, but fwiw, I
ran into this yesterday for another eason. It turns out that the value of
the name attribute of the html:javascript element didn't match the name of
the form-bean in question (there are too many similar things with similar
names in our struts app - don't know if this is a common problem or not?).
Suggest that the failure mode for html:javascript would be to not dump
anything to the page, rather than dump a chunk of malformed html.

- donald


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>