views:

11

answers:

1

I am using Java applet as a box for uploading files. Choosing files from file system and dragging them on applet cause adding file pathnames into the input text box.

The design is currently following: Each 'Upload' button is surrounded by an applet for the drag-n-drop, a radio box and an input box. Each radio box has its own id. The drag-n-drop is realised using the methods from java.awt.datatransfer packagee. When user drops file(s) on the chosen applet, following Java code

          getAppletContext().showDocument
            (new URL("javascript:appletUpdateFile()"));
          }

calls javascript function. Everything works just fine. But there is a following problem - I use one applet for all Upload buttons. It's in fact the part of an external user script (IEPro) for CMS, so there might be really high count of 'Upload' buttons in the current page of CMS. Therefore creating unique applet for each button is not an acceptable solution.

It has to be somehow identify which input box (belonging to certain 'Upload' button / drag-n-drop box) should be updated. Currently it's determined by radio boxes. So user needs to select particular option before actual dragging file(s) on applets. From the user point of view this step is redundant.

I would like to somehow identify to which applet were dragged files without using radio boxes. Till now I have tried several approaches:

1) Identify using mouseover, mouseup, etc. on parent elements of applets - it could choose and set the right applet (setting radio box, variable, etc.). However it is not working, because all mouse events are simply ignored if the cursor holds files...

2) Using "this" keyword as an parameter of appletUpdateFile() function - this is clearly also not working, browsers of course cannot determine caller applet of 'new URL("javascript:appletUpdateFile()'

So, I hope I typed enough to introduce the problem. I would be grateful for any way (on the side of applet, or on the JavaScript side) to accomplish this task.

A: 

When you are generating the applet's object tag and the input boxes via PHP, Javascript or something else you could pass every applet an unique value (if they are generated in a loop, a candidate would be the current value of $i) which you do also use to identify the input box (e.g. set the "id" attribute to something like "inputBox$i"). The applet passes this value to your appletUpdateFile function, which then may access the corresponding input box via document.getElementById("inputBox"+idNumber).

Jaseg