Results 1 to 4 of 4

Thread: Valang error: "Exception thrown and not caught"

  1. #1
    Join Date
    Nov 2005
    Location
    Atlanta
    Posts
    15

    Question Valang error: "Exception thrown and not caught"

    Hi,
    I have been using Spring for more than an year now but I am new to Valang validation framework.

    Using Spring 2.0 RC3 and Spring modules 0.6, I followed the steps in valang documentation. I am also using the new <form:> tags in my jsps and use sitemesh decorator to decorate the pages.

    I get the following javascript error.

    "Exception thrown and not caught".

    I verified a couple of times to make sure that I have the valang_codebase.js file included, the validate call is inside the form etc.

    Any ideas on what I might be missing?

    Thanks
    Mandar

  2. #2
    Join Date
    Oct 2006
    Location
    The Netherlands
    Posts
    9

    Default

    Try the following:

    At around line 119 of the JavaScript file, replace this code:

    Code:
    if (!element || element.tagName.toLowerCase() != 'form') {
          element = document.getElementById(name+'ValangValidator')
      }
    if (!element|| element.tagName.toLowerCase() != 'script') {
            throw 'unable to find form with ID \'' + name + '\' or script element with ID \'' + name +'ValangValidator\''
      }

    with this code:
    Code:
    if (!element || element.tagName.toLowerCase() != 'form') {
          element = document.getElementById(name+'ValangValidator')
        if (!element|| element.tagName.toLowerCase() != 'script') {
            throw 'unable to find form with ID \'' + name + '\' or script element with ID \'' + name +'ValangValidator\''
        }            
      }
    In the original code, it ends up checking a reference to the form element for a 'script' tagname and throwing the 'unable to find form or script element' exception.
    Last edited by Barend; Dec 4th, 2006 at 06:32 AM. Reason: the post ended up with a thumbs-down icon, which is just silly

  3. #3
    Join Date
    Dec 2006
    Posts
    8

    Default Valang error: "Exception thrown and not caught"

    I am getting a similar javascript error with client side Valang validation (server side validation works fine). I traced the error to the javascript code generated by valang:codebase tag. I have a input type=button on the page. It is not being handled and that is causing the exception. So I made a modification (as marked by the comment in code - line 351 onwards - below) in valang_codebase.js. However, the javascript generated in the page does not have the modification I made and I still get the error. What I have missed?

    Code:
            switch (this.type) {
            case 'submit':
            case 'hidden':
            case 'password':
    	// added case button to prevent exception being thrown for buttons
    	case 'button': 
            //--- end of modification
            case 'text':
                this.getValue = ValangValidator.Field.ValueGetters['textarea'] 
                break
            case 'checkbox':
            case 'radio':
                this.getValue = ValangValidator.Field.ValueGetters['inputSelector'] 
                break
            default:
                throw 'unexpected input field type \'' + this.type + '\''

  4. #4
    Join Date
    Dec 2006
    Posts
    8

    Default

    Never mind. I was including valand_codebase.js and using valang:codebase tag. I removed the tag and it started working properly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •