Results 1 to 4 of 4

Thread: dojo.js is truncated?

  1. #1
    Join Date
    Feb 2006
    Posts
    115

    Default dojo.js is truncated?

    I am working on an application, did some changes, and now I am getting an error in dojo.js. I am not sure when it broke, but here is a screen shot:
    Screen shot 2011-10-18 at 9.25.24 AM.jpg

    If I scroll all the way to the right, the end of the line looks truncated:
    Screen shot 2011-10-18 at 9.26.01 AM.jpg

    The error, according to Chrome's JavaScript Console, is in dojo.js, and is a SyntaxError: unexpected_token on line 14. There is a line 15, but its completely blank.

    Anyone have a clue what's going on? It may be a result of me upgrading to Roo 1.2.0.M1 (was on 1.1.5 that came with STS).

  2. #2
    Join Date
    Feb 2006
    Posts
    115

    Default

    Can anyone at least tell me where the dojo.js is located? From the HTML it looks like its somewhere in the server, in a /resources/ path, but I can't seem to find it.

  3. #3
    Join Date
    Feb 2006
    Posts
    115

    Default

    For those that may stumble upon this problem later, I am adding some details and the "fix".

    What lead me to the solution was that in FireFox the error is reported as such:
    Code:
    SyntaxError: missing ) in parenthetical
    From that, I found an forum posting mentioning that it's a bad JSON parse. I am not sure why Dojo doesn't have a better error-handling for mis-formed JSON, but thats a discussion for another Forum.

    Anyhow, the problem was that I was getting back an error from my controller. I had added this to my Controller's JSON method's RequestMapping:
    Code:
    headers = "Accept=application/json"
    Basically requiring the Accept header be set to JSON. The problem is that Dojo doesn't change the Accept header when you switch the handleAs to "json".

    Bottom line, Spring MVC was sending back an HTTP 500 error page, since there was no RequestMapping to handle the request, and Dojo was blowing up trying to parse the resulting page as JSON. The ultimate fix for me was to add the Accept header to the Dojo JSON request as following:
    Code:
    dojo.xhrGet({
    	url: "${get_site_users}",
    	handleAs: "json",
    	headers: {'Accept':'application/json'},
    	load: function(data,ioArgs) {
    		// Do something with 'data'
    	}
    });
    Once the header was being sent, things started working just fine.

  4. #4
    Join Date
    Feb 2006
    Posts
    115

    Default

    For future visitors, if you are looking for where the Dojo files are (.js, .css, .html), they are all located in the spring-js-resources JAR dependency. For my version of Roo, its spring-js-resources-2.2.1.RELEASE.jar.

Posting Permissions

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