PDA

View Full Version : Exts filefield IE8 Spring 3 (Exception thrown not caught) Line: 4898 extjs-all-debug



mikkushukla
26 Sep 2011, 10:48 PM
Hi Team,
I have created a simple extjs form with filefield control. On server side I am using Spring MVC.
My application running perfeclty fine firefox and mozilla.

In case of IE 6/7/8. It is submittng form but with error and error is
Exception thrown not caught
Line: 4898 extjs-all-debug.js

I have googled it like anything but no clue about this error.

For your simplicity here is the demo
Login to

http://122.160.226.254:8080/promoteIt

username : shukla
password : miks

on left menu click Site->Wap Site
click on edit wap page icon
then submit the page you get the error in IE 6/7/8.
I think it is a bug.

Rest you see.


Thanks
Shubhanshu Shukla
Senior Software Engineer.

mkariti
6 Nov 2011, 6:25 AM
mikkushukla,
Can you please let me know how did you fix this?
Im running to the same problem.
Cheers
mkariti

mikkushukla
6 Nov 2011, 6:35 AM
Just avoid using this kind of approach in spring controller...


@RequestMapping(method = RequestMethod.POST)
public @ResponseBody String create(FileUploadBean uploadItem, BindingResult result){

ExtJSFormResult extjsFormResult = new ExtJSFormResult();

if (result.hasErrors()){
for(ObjectError error : result.getAllErrors()){
System.err.println("Error: " + error.getCode() + " - " + error.getDefaultMessage());
}

//set extjs return - error
extjsFormResult.setSuccess(false);

return extjsFormResult.toString();
}

// Some type of file processing...
System.err.println("-------------------------------------------");
System.err.println("Test upload: " + uploadItem.getFile().getOriginalFilename());
System.err.println("-------------------------------------------");

//set extjs return - sucsess
extjsFormResult.setSuccess(true);

return extjsFormResult.toString();
}

Correct Way for writing file upload controller is


public void create(FileUploadBean uploadItem, BindingResult result,HttpServletResponse response){
ExtJSFormResult extjsFormResult = new ExtJSFormResult();
if (result.hasErrors()){
for(ObjectError error : result.getAllErrors()){
System.err.println(“Error: ” + error.getCode() + ” – ” + error.getDefaultMessage());
}
//set extjs return – error
extjsFormResult.setSuccess(false);
response.setContentType(‘text/html’) ;
response.getWriter().write(extjsFormResult.toString());
response.flushBuffer();
return;
}
// Some type of file processing…
System.err.println(“——————————————-”);
System.err.println(“Test upload: ” + uploadItem.getFile().getOriginalFilename());
System.err.println(“——————————————-”);
//set extjs return – sucsess
extjsFormResult.setSuccess(true);
response.setContentType(‘text/html’) ;
response.getWriter().write(extjsFormResult.toString());
response.flushBuffer();
return ;
}

Thanks & Regards
Shubhanshu Shukla
Senior Software Engineer
Lumata Group Landon.

mkariti
6 Nov 2011, 6:46 AM
Hi mikkushukla,
Many thanks for your quick reply.
I actually dont use Spring framework.
I use Sencha and .Net and I came to the same problem.
Any I dea on how to solve this in my environment?
Many thanks
mkariti

mikkushukla
6 Nov 2011, 8:01 AM
Could you paste your server side code.

skirtle
6 Nov 2011, 8:48 AM
@mkariti. What are you returning from your server? I don't want to see the code, I just want to see the response as seen in Firebug, etc. What content-type header does the response have?

Make sure you have read and understood this section of the docs and that your server is complying:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.Basic-method-hasUpload

mkariti
6 Nov 2011, 9:38 AM
skirtle and mikkushukla many thanks for your reply.
Really appreciate it!
@mikkushukla - i will post it 2moro morning as I’m away of my computer.
@skirtle - Thanks for the link. I had a look at it a few days ago.Also, I’ve tried all kind of Content types:

context.Response.ContentType = "applicationj/json";
context.Response.ContentType = "application/xml";
context.Response.ContentType = "text/plain";
context.Response.ContentType = "text/html";

Also the response was accordingly. i.e. context.Response.Write("{'item':'A'}"); etc.
For some reason I only accepted
context.Response.ContentType = "applicationj/json";

Also, in Sencha I got my string this way: "<pre>string</pre>"
and only in FF not IE.
Many thanks once again.

skirtle
6 Nov 2011, 10:10 AM
Please try to focus on the response itself rather than the code used to generate it. The code you use makes absolutely no difference to how the browser or ExtJS interpret the response, all that matters is the response itself.

It may work in FF but that doesn't mean you can't use Firebug to capture the response and headers with a view to explaining the problem. It should be an identical response to the one in IE, after all.


Also, in Sencha I got my string this way: "<pre>string</pre>"

Not quite sure what you mean by this. A form upload response can be wrapped in an HTML textarea but wrapping it in pre tags will cause a parsing error when trying to decode the JSON.

Could you let us know exactly which ExtJS version you're using and what code is on the line that throws the exception? It should be pretty easy using the IE debugger to track down information about the stacktrace too.

mkariti
6 Nov 2011, 10:53 PM
Hi skirtle,
Here is what Im getting from Httpfox:


(Request-Line) POST /ServerData/uploadFilestotheServer.ashx HTTP/1.1
Host lmss.moshek
User-Agent Mozilla/5.0 (Windows NT 5.2; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-gb,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Referer http://lmss.moshek/Pages/org_InstitutionCreate.aspx?id=455
Cookie ASP.NET_SessionId=pe4uv0552vyu0i45exmdsg55; login=E2B59C91E2D6EB72C0399B838C833F1684773FE7C34BAEC4AFF443B171AF487EB842D63F95E3C2DA50CF7D2D11DC70C985D6C03508412E9780CC1F9E6A2BDFA4990ED8683497B7F24C663C5826932AA013C7CBCE92CF13CDCF5EF0B0BCE2156991E950064F4272FC37A8E7BB066DB54466B03C36
Content-Type multipart/form-data; boundary=---------------------------181274673728
Content-Length 7089

Also, Please see attached the images from firebug. one for form and one for action (Hope you can see the images).
Here is where I get the error.Sorry minified form so no line number:


function(json,safe){if(!dc){dc=isNative()?JSON.parse:doDecode}try{return dc(json)}

Many thanks
mkariti

mkariti
6 Nov 2011, 11:35 PM
Hi skirtle,
I think I misused the hasUpload (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.form.Basic-method-hasUpload)( ) function.
Any chance you can post a sample on how to use it? I cant find one that will clearly explain this.
IMany thanks
mkariti

skirtle
7 Nov 2011, 6:22 AM
From what I've seen so far there's nothing wrong with your request, the problem is in the response.

What I'd really like is to see the response and headers from the Net tab.

As far as I can tell from those screenshots (though they aren't enough to be definitive) your response is totally wrong. It seems to be a URL wrapped in PRE tags. Obviously that will fail when it's run through the JSON decoder.

mkariti
7 Nov 2011, 7:46 AM
Hi skirtle,
Many thaks once again.
I fainally got it to work but do have a few othert questions.
However, I do have other problem such as in case of internal (404 or 500) error, the response is not directed to the failure section.
Any Idea?
Many thanks
mkariti

skirtle
7 Nov 2011, 8:04 AM
This is documented, though you could be forgiven for not finding it:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Connection

See the last paragraph of the intro docs.

Your best bet is to treat errors as 200s but to include something in the JSON response to mark it as an error. Many people use the success property as a flag for this.

mkariti
7 Nov 2011, 10:55 PM
Many thanks skirtle. Thats exactly what im going to do!
Cheers
mkariti