Drag and drop Firefox issue

I've encountered a rather annoying problem with drag and drop. Firefox will always accept a drop of a custom component! For example run and drag and drop in firefox:

http://java.sun.com/docs/books/tutorialJWS/uiswing/dnd/ex6/DragPictureDemo.jnlp

Do you know anyway to prevent this (I know IE does not accept the drop...)?

Thanks very much for any input!

[379 byte] By [MisterFlibblea] at [2007-11-27 10:32:01]
# 1

Change the type of the content to one that the browser doesn't understand.

Or, more simply, don't worry about it.

--

Guy: Doctor, when I touch my elbow it hurts.

Doc: Then don't touch your elbow.

bsampieria at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...
# 2

> Change the type of the content to one that the

> browser doesn't understand.

I though I was already doing this...

In my Transferable class:

protected static final DataFlavor fsgTOArrayFlavor = new DataFlavor(MyTO[].class, "MyTO Array");

protected static final DataFlavor myTOFlavor = new DataFlavor(MyTO.class, "MyTO");

public static final DataFlavor[] DATA_FLAVORS = new DataFlavor[]{myTOArrayFlavor, myTOFlavor};

public DataFlavor[] getTransferDataFlavors() {

return AbstractMyTransferHandler.DATA_FLAVORS;

}

> Or, more simply, don't worry about it.

I do have to worry about it ;)

MisterFlibblea at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...
# 3

what does FF do with it then?

bsampieria at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...
# 4

Nothing (try the example in the first post), though it really should not accept it as a drop. According to the Javadoc:

http://java.sun.com/javase/6/docs/api/java/awt/datatransfer/DataFlavor.html#DataFlavor(java.lang.Class,%20java.lang.String)

The mimeType = application/x-java-serialized-object, and I don't know why Firefox thinks it should understand this.

Do you still know how to make the content-type one that firefox does not accept?

Thank you!

MisterFlibblea at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...
# 5

> > Or, more simply, don't worry about it.

>

> I do have to worry about it ;)

>

> > what does FF do with it then?

>

> Nothing...

So nothing happens, but you have to worry about it? I don't understand that. The questions, IMO, should be:

1) Is something bad going to happen if a user does "action x"? (data security, etc.)

2) Is it likely that a user will even do "action x"?

If the answer to #1 is yes, you probably have to worry about it, but from what you've said already, I think the answer to #1 is no, and generally speaking, my experience tells me that the answer to #2 is no also.

If the answer is to #1 is no, then I would not worry about it. What can go wrong?

bsampieria at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...
# 6

I have an applet in a webpage that will accept drag and drops, however, if a user mistakingly drops into the browser page and not the applet, the drop is consumed, which is bad especially if you want an action to occur whenever a drop happens...

:(

In my opinion this would be a Firefox bug, but was wondering if there is a Java workaround. I guess I could tell people to just use IE.....

MisterFlibblea at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...
# 7

> I have an applet in a webpage that will accept drag

> and drops, however, if a user mistakingly drops into

> the browser page and not the applet, the drop is

> consumed, which is bad especially if you want an

> action to occur whenever a drop happens...

>

> :(

Okay, but the applet provides a target area. So how is it any different from dropping said content on any other app that's in a background window? Make sure the drop area is visually obvious.

Of course, if Firefox is taking this to be a file to show and then unloading the applet, that is not ideal. But I personally would not worry about such a thing happening that I felt a need to jump thru hoops to find a solution.

> In my opinion this would be a Firefox bug, but was

> wondering if there is a Java workaround. I guess I

> could tell people to just use IE.....

You could restrict to IE other ways too, but I really don't see the point. I don't know any other way to change the type except what you already posted. FireFox does support running Java from within Javascript, so this might be a side effect of that.

Message was edited by:

bsampieri

bsampieria at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...
# 8

> What does FF do

Looking a little closer, I found that if you open the Error Console of Firefox you see this error message:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsITransferable.getAnyTransferData]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://global/content/nsTransferable.js :: anonymous :: line 132" data: no]

It would great if Firefox worked like IE and not accept the drop, instead of silently failing :(

MisterFlibblea at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...
# 9

This is now in the Sun bug DB:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6581336

MisterFlibblea at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...
# 10

okay, I could be wrong, but I would think this a problem with FireFox, not Java. I'm not sure what Java can do about it if a drop target claims to accept the drop even when it can't handle it.

bsampieria at 2007-7-28 18:13:57 > top of Java-index,Desktop,Core GUI APIs...