File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Reading a passed Object from Javascript in Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Reading a passed Object from Javascript in Applet" Watch "Reading a passed Object from Javascript in Applet" New topic
Author

Reading a passed Object from Javascript in Applet

T Almo
Greenhorn

Joined: Sep 09, 2009
Posts: 10
Instead of using the applets File Dialog, I was hoping to use the standard <input type=file> to bring up the file dialog, then once the file is selected, pass it to the applet to do the upload. The problem with this (in Firefox 3) is that when I call the value in Javascript(ExtJS) with inputFile.dom.value, the browser removes the file path for security reasons, and I only get the filename. If I look at the inputFile.dom object in Firebug, I see that the value attribute contains the entire path.

Since the browser does the truncating upon the .value call, I was hoping I could just pass the entire dom object to the Applet, then read the value in the applet, which should contain the whole path. I've passed the object in by using ExtJS to dynamically set a parameter value to the dom object and use a getParameter() in the applet, but Im not really sure how to read it. The applet believes its an Object and when I do a println on it, it just outputs [object Object]. It should be a JSON object, I believe, but I dont have a good way of seeing whats in it on the applet side of things.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42365
    
  64
Doing a ".getClass().getName()" on it will tell you what kind of object it actually is.


Ping & DNS - my free Android networking tools app
T Almo
Greenhorn

Joined: Sep 09, 2009
Posts: 10
.getClass().getName() told me that its a String, so why does calling a println on it give me [object Object]? Ive tried setting the passed in parameter as a String as well (so the applet believes its a string) and that printed out the same object message.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading a passed Object from Javascript in Applet