GWT FileUpload doesn't work on Chrome and Opera - gwt

Hi
I have some appliacation written in GWT 2.2 (tested also on previuos versions) with file upload. Basicly there is FileUpload component with Struts servlet on server side. The problem is that it works fine on IE and FF, but does not work on Chrome and Opera.
I found some tip to use gwtupload library ( i build the simplest case ) and the problem still occurs... With gwtupload I get alert with:
"Error, your browser has not sent any information. Please try again or try it using another browser"
Simple code for gwtupload version:
defaultUploader = new SingleUploader();
verticalPanel.add(defaultUploader);
defaultUploader.addOnFinishUploadHandler(onFinishUploaderHandler);
// Load the image in the document and in the case of success attach it to the viewer
private IUploader.OnFinishUploaderHandler onFinishUploaderHandler = new IUploader.OnFinishUploaderHandler() {
public void onFinish(IUploader uploader) {
if (uploader.getStatus() == IUploadStatus.Status.SUCCESS) {
//new PreloadedImage(uploader.fileUrl(), showImage);
// The server can send information to the client.
// You can parse this information using XML or JSON libraries
// Document doc = XMLParser.parse(uploader.getServerResponse());
// String size = IUploader.Utils.getXmlNodeValue(doc, "file-1-size");
// String type = IUploader.Utils.getXmlNodeValue(doc, "file-1-type");
Window.alert("Upload work");
}
}
};
Deafult servlet on the serves side.
Again, it works only on FF and IE. I hope somebody faced similar problem. :)

It could be some nasty WebKit bug. I think to remember something about a problem uploading files with WebKit-based browsers on OS X. You may want to check the WebKit bug database.

Related

Codemirror (textarea replace) IE compatability issue

Going to log this here just in case anyone has a similiar issue.
"Having a bit of a weird issue and I am hoping that someone can point out if I'm making an error before I bug report or something.
In Chrome this works fine, in IE (version 9 or newer) it refuses to display the codemirror editor as long as its within form tags.
Evidence:
http://jsfiddle.net/ablueman/kmtorrkL (Ok in Chrome / Broken in IE)
form tags yes / form css yes.
http://jsfiddle.net/ablueman/kmtorrkL/32/ (Working in chrome and IE but not a form)
form tags no / form css yes.
http://jsfiddle.net/ablueman/kmtorrkL/33/ (working in chrome / Broken in IE.
form tags yes / form css no.
https://www.ablueman.co.uk/the/testbench/fourform.php
Evidence its not a quirks issue or otherwise something in jsfiddle.net
http://validator.w3.org/check?uri=https%3A%2F%2Fwww.ablueman.co.uk%2Fthe%2Ftestbench%2Ffourform.php
Damn thing validates as well.
If anyone has any ideas I'm all ears."
var myCodeMirror = CodeMirror.fromTextArea(QTA1, {
mode: "javascript",
lineNumbers: true
});
answer to follow .....
Just in case anyone finds this:
It is fixable by using:
var whatever = CodeMirror.fromTextArea(document.getElementById('theID'), { lineNumbers:true });
http://jsfiddle.net/ablueman/kmtorrkL/41/
But that means the manual is essentially incorrect and / or the selector is presumably wrong in IE's eyes. You get a undefined error.
Logged a bug report:
https://github.com/codemirror/CodeMirror/issues/2910
http://codemirror.net/doc/manual.html
"var myCodeMirror = CodeMirror.fromTextArea(myTextArea);"

Open browser in private=incognito mode from Thunderbird extension

I would like to open a URL in private mode from a Thunderbird extension. Right now, the following code works in "standard" non-private mode:
try {
var eps = Components.classes["#mozilla.org/uriloader/external-protocol-service;1"].
getService(Components.interfaces.nsIExternalProtocolService);
var ios = Components.classes["#mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
eps.loadURI(ios.newURI("http://www.example.com", null, null));
} catch (err) {}
Any idea how to achieve the same result in private mode? I'm interested to make it work with launching Chrome as the default browser. (Once again, Chrome is correctly launched with the code above).
You cannot really launch Firefox with a new url in a private window AFAIK. -private-window <url> will open a new private window, but still put the new tab in a regular one.
Chrome can be launched with chrome --incognito <url>, however you would need to launch it yourself via nsIProcess and therefore would first have to figure out where the chrome binary is.
If you can guarantee that the default handler is Chrome, then you might use nsIExternalProtocolService.getProtocolHandlerInfo(), use preferredApplicationHandler and QueryInterface that to nsILocalHandlerApp to find the .executable. Otherwise, you'll have to deal with the OS and/or known paths yourself.

Reference Error: Can't find variable: ChildBrowser, Cordova 1.7.0, jQueryMobile 1.0.1, iOS 5.1

I'm working on my first PhoneGap/Cordova app and using jQueryMobile as well. I'm trying to get the ChildBrowser plugin working but getting the error in the title when trying to call
ChildBrowser.install()
Its in my onDeviceReady function which is being called correctly and I've even verified that the ChildBrowser.js file is being called by adding an alert and wrapping the anonymous function that file in a try/catch and it does not seem to be throwing any errors during its execution. However the var does not seem to be valid within my index.html file.
Presumably there is some 'gotcha' here I am not aware of. Any thoughts?
Thanks in advance.
Combining info from http://blog.digitalbackcountry.com/2012/03/installing-the-childbrowser-plugin-for-ios-with-phonegapcordova-1-5/ and his linked post https://github.com/phonegap-starter/ChildBrowserPlugin it appears that the
ChildBrowswer.install();
step is no longer necessary. I am now using jQueryMobile 1.1 as well. Example function used to launch google in the ChildBrowser included below. I followed the .plist setup from the first link.
function onLinkClick() {
window.plugins.childBrowser.onLocationChange = function(loc){ alert("In index.html new loc = " + loc); };
window.plugins.childBrowser.onClose = function(){alert("In index.html child browser closed");};
window.plugins.childBrowser.onOpenExternal = function(){alert("In index.html onOpenExternal");};
window.plugins.childBrowser.showWebPage('http://www.google.com',
{ showLocationBar: true });
console.log(window.plugins.childBrowser);
}
and the link itself for completeness
<p>Click here to open a child browser window to Google</p>
Hopes this helps someone else as this question went unanswered for a couple of days.

Web crawling/scraping GWT based web pages

I am trying to crawl a web page that is built using GWT and uses the GWT RPC mechanism for AJAX calls. The page I am trying to crawl is not mine - so I can't edit the server side. I am very new to GWT and from my initial couple of days with it - I think that you can't de-serialize the data unless you've the case interface with you.
Am I right or Is there a way to crawl the data intelligently?
You could do it using htmlunit and WebClient:
//real code mixed with pseudo-code:
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3);
Map<String, String> urls = new HashMap<->();
LinkedList<String> urlsToVisit = new LinkedList<->();
urlsToVisit.put("http://some_gwt_app.com/#!home");
while (!urlsToVisit.isEmpty()) {
String page = urlsToVisit.remove();
if (urls.containsKey(page)) {
continue;
}
String rendered = webClient.getPage(page);
urls.put(page, rendered);
urlsToVisit.addAll(extractLinks(page));
}
You might have to experiment with the WebClient options a bit. In my case these seem to do a good job:
webClient.setThrowExceptionOnScriptError(false);
webClient.setRedirectEnabled(true);
webClient.setJavaScriptEnabled(true);
// important! Give the headless browser enough time to execute
// JavaScript. The exact time to wait may depend on your application.
webClient.waitForBackgroundJavaScript(20000);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
I scrape for a living, and GWT is the one framework that almost always flummoxes me. The fact that it passes serialized, non-human readable parameters prevents me from interject logic that will access the site.
On some simple GWT I've gotten scrapes to work be parsing the JavaScript and running portions as is, but I can't get all to work.

GWT Frame not working in Mozilla Firefox or in Google chrome, but working fine in IE

I am trying to download a file from server. The normal GWT RPC call doesnot allow me to do that, and hence I wrote a servlet to do that job for me. From the client side, I am creating a Frame object, and I set the servlet URL in it, and add that frame Object in my root panel.
When I execute this in IE, a window pops up asking for Save/Open file.
But when I execute the same in a Firefox or a Google Chrome browser, nothing is happing.
I am not getting any request on my servlet/server side.
Here is a slice of the code :-
String servletUrl = "http://localhost:13080/Browser/ui/dataExportServlet?level=ZERO";
Frame frame = new Frame(servletUrl);
frame.setVisible(false);
RootPanel.get().add(frame);
So, can someone please help me out.
This might be related to same origin policy.
Are both servlet and webapp running on port 13080?
If they differ, SOP might fail this.
If I understand correctly, IE has a more relaxed policy so it might work there but not in chrome.
See http://en.wikipedia.org/wiki/Same_origin_policy and Can I disable SOP (Same Origin Policy) on any browser for development?
In Chrome, you can use the Developer Tools (CTRL + SHIFT + I) to check if the IFrame is being added to the HTML, and if the frame's source is being set properly. You should also be able to see what content has been loaded into the iframe.
Alternately, set a breakpoint in your servlet to see if the iframe is being hit at all from Chrome.
I got the solution for this issue.
I removed the frames and added the following code :-
com.google.gwt.user.client.Window.open(url, "CSVDownload", "");
Now, this opens a new browser window, and then I get the pop-up to open/save the server side file in all 3 web-browsers. (IE, Mozilla FireFox, Chrome).
Thanks a lot!!!