struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Coast <nat...@codeczar.com>
Subject Re: problems using httpunit / rhino with struts validator
Date Wed, 22 Nov 2006 13:17:27 GMT
Thanks Niall,

perfect, you were right, it was an issue with the jcv_retrieveFormName. 
  I'll post again when I've figured out whether it's caused by rhino, 
validator, httpunit or a combination of all three :)

As a workaround I can override the jcv_retrieveFormName(form) in each 
jsp to return the correct value:

function jcv_retrieveFormName(form) {
	return "SearchKeyForm";
   }

the form is xhtml compliant generated by struts so no name attribute 
defined:
<form id="SearchKeyForm" method="post" 
action="/i18n-admin/i18n-admin/key/SearchKey.do" onsubmit="return 
validateSearchKeyForm(this);">

for some reason, jcv_retrieveFormName drops through to the final case 
formName = form.name which resolves to 'undefined'

   function jcv_retrieveFormName(form) {

       // Please refer to Bugs 31534, 35127, 35294, 37315 & 38159
       // for the history of the following code

       var formName;

       if (form.getAttributeNode) {
           if (form.getAttributeNode("id") && 
form.getAttributeNode("id").value) {
               formName = form.getAttributeNode("id").value;
           } else {
               formName = form.getAttributeNode("name").value;
           }
       } else if (form.getAttribute) {
           if (form.getAttribute("id")) {
               formName = form.getAttribute("id");
           } else {
               formName = form.attributes["name"];
           }
       } else {
           if (form.id) {
               formName = form.id;
           } else {
*****
***** This gets executed
*****
               formName = form.name;
           }
       }
       return formName;
   }

thanks again, had no idea where to look.

cheers
Nathan


Niall Pemberton wrote:
> 
> OK I'm making some assumptions here, so correct me if I'm wrong:
> 1) I assume that the form specific validation functions have been
> correctly generated by the <html:javascript> tag - for example if you
> have a form named "foo", you're getting functions like "foo_requred"
> generated? Can you verify this?

yes, this is generated
function validateSearchKeyForm(form) {
         if (bCancel) {
             return true;
         } else {
             var formValidationResult;
             formValidationResult = validateMaxLength(form);
             return (formValidationResult == 1);
         }
     }

     function SearchKeyForm_maxlength () {
      this.a0 = new Array("value.key", "Key can not be greater than 250 
characters.", new Function ("varName", "this.maxlength='250';  return 
this[varName];"));
      this.a1 = new Array("value.description", "Description can not be 
greater than 250 characters.", new Function ("varName", 
"this.maxlength='250';  return this[varName];"));
     }


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


Mime
View raw message