Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to implement drag from Java Desktop Application & drop to Native File?

875776Mar 9 2012 — edited Mar 9 2012
I am currently using JAVA 6 and my Java desktop application shows a list of the files from server. I would like to have a download selected files to native file system using Drag and Drop. I have gone through many links but almost every link describes the Drag and Drop with-in a Java swing applications. I have not found help to implement download using drag from Java desktop Application & drop to Native File.

For example, let's suppose, I have dragged the file from my java swing application and dropped directly to the desktop then download should take place and I should know where the file is being downloaded. The files that are being downloaded may be in GBs and take several hours to download. I need destination location because if the download fails then I can re-try download.

Please consider following steps to clarify what I have explained, how it will work and what is my requirement -

1. User runs application.
2. The list of files from server displays in JTable.
3. Now user restores down the application window.
4. User selects some files from JTable.
5. Drags out of the application onto his computer to download.
6. Downloading supposed to be started from server to the location where he drops that file on his computer.


Any help will be greatly appreciated.

Comments

Try restarting JDeveloper - it tends to solve the issue.
If you have reproducable steps to duplicate the problem let us know.
513317
I have isolated this issue down to the faces-config file. I have two phase-listeners that I install. In the faces-config these go into the lifecycle.
If I have the statements
<lifecycle>
<phase-listener>eig.faces.lifecycle.RenderResponsePhaseListener</phase-listener>
<phase-listener>eig.faces.lifecycle.RestoreViewPhaseListener</phase-listener>
</lifecycle>
I only get rectangular boxes. If I remove the phase listener(s) with the statement
<lifecycle>
</lifecycle>
I get the appropriate components rendered in design view. I need my phase listeners, is there any workaround or fix to this problem? I did try removing one (since I have see issues in RAD which will not accept two listeners) but this had no effect.
514312
I am facing the same problems too. It happened suddenly and I have not been able to restore it to the design view that it initially came up with. I tried to delete what you suggested and it still does not work. In my case I had:

<lifecycle>
<phase-listener>oracle.adf.controller.faces.lifecycle.ADFPhaseListener</phase-listener>
</lifecycle>
and I tried deleting the <phase-listener> and restarting JDeveloper.

The 'box' view is simply irritating.
513317
I narrowed this down exactly to the phase listener. In fact I had a custom component that I thought might be causing the problem but I eliminated that as the cause. The only thing I will say is that during each "test" that I did I had to shutdown and restart JDeveloper. Just eliminating the phase-listener did not solve the problem UNTIL I restarted the tool
514312
Changing faces-config.xml to remove the <phase-listener> tag and restarting JDeveloper does not help for me.
Can you please tell me the exact steps you are doing so I am sure I am not missing anything?
Thanks.
513317
I am hoping someone from JDeveloper can give us a reason why. My current thinking is that JDeveloper is running some portion of the JSF Lifecycle in order to generate the design view. Extrapolating that, anything you might do to plugin to that cycle could cause this problem. Examples include areas in <application>, <factory>, <lifecycle>.

Note: After writing above I went back because I remembered I also had both a variable resolver and property resolver that was removed in my initial test. Sure enough if I put my variable and property resolver in there it also breaks design view. This sort of confirms my theory, if you plugin anything that might effect lifecycle process you will break design view. Thus I have three ways of breaking design view, adding a phase listener, adding a variable resolver, or adding a property resolver.
75081
Does the phase listener compile and run successfully? If not, this could prevent the current VE from rendering correctly. The following works for me when I build the phase listener before registering it in the faces-config.

faces-config.xml:
<faces-config xmlns="http://java.sun.com/JSF/Configuration">
<lifecycle>
<phase-listener>project1.MyPhaseListener</phase-listener>
</lifecycle>
</faces-config>

MyPhaseListener.java:
package project1;

import javax.faces.event.PhaseListener;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;

public class MyPhaseListener implements PhaseListener
{

public MyPhaseListener()
{
}

public void beforePhase(PhaseEvent pe)
{
if (pe.getPhaseId() == PhaseId.RESTORE_VIEW)
System.out.println("Processing new Request!");

System.out.println("before - " + pe.getPhaseId().toString());
}


public void afterPhase(PhaseEvent pe)
{
System.out.println("after - " + pe.getPhaseId().toString());

if (pe.getPhaseId() == PhaseId.RENDER_RESPONSE)
System.out.println("Done with Request!\n");
}

public PhaseId getPhaseId()
{
return PhaseId.ANY_PHASE;
}
}
513317
Yup, the phase listener compiles. It is definitely working because my solution depends upon it working. I am very happy with JDeveloper, extremely happy with ADF, and as far as things working I'm in pretty good shape ... with the exception of this design time issue.

Since there is not return value or side effects expected from the calls, I can only assume that when JDeveloper encounters a decorator(s) like these it drops into a raw visual design mode. No other explainatin
269633
The JSF design time does execute the restore and render cycles similar to the runtime behavior.

So, if you have compiled phase listeners, they should be invoked as well.

Is it possible to provide a test case (war) with your phase listeners in place ? Will help us identify any potential bugs.
513317
Ok I have isolated this issue. In my phase listener I had this line of code:

private static final Logger _logger = Logger.getLogger(EigRequest.class.getPackage().getName());

and I changed it to
private static final Logger _logger =
Logger.getLogger(EigRequest.class.getName());

and design mode started to work. I guess either of the above works for me although I do not understand why the line works when you run the application but not in design mode.

Moral to the story is if something fails in any one of these types of decorators you will drop into a raw view mode. The question I have is if errors are occuring how do I figure out where they may be. There is no indication that anything is wrong with the exception that you lose most of the design mode functionality.

This was not a compile issue, this was not a runtime issue. It took me quite a few hours of writing a test program to validate that it was not just writing a phase-listener issue; then launching, editing, relaunching the application to find the problem. I will say that a good portion of the code came from a Eclipse project. If you add the offending lines of code while using JDeveloper you do not loose design mode immediately. You only see the problem the next time you start JDeveloper which complicates finding the problem.
269633
Does turning ON the diagnostic trace info in the preference reveal any useful info ?

Tools->Jsp and HTML Visual Editor->Show Design Time log
264361
I have faced the same problem. I have created a web app from scratch using ADF and BC4J. I like the tool too.

I have a phase listener in place. This phase listener interacts with the BC4J model and is dependent on the fact that a user should be authenticated, and it makes sense that it breaks when it runs out of the application server context.

I have given a solution to this problem: since the design time view does not work when the phase listener breaks, I just made the listener to be unbreakable by surrounding the whole code with a try{}catch sentence, where the catch does not do anything. This is the structure of what I did:

public void beforePhase(PhaseEvent phaseEvent) {
try
{

/*
HERE IS THE WHOLE CODE OF MY LISTENER FUNCTION
*/

}
catch(Exception e)
{
System.out.println("")
}

}

It just worked.

Rafa
75081
that works. I've also seen java.beans.Bean.isDesignTime() logic to make sure RT code does not get run.

st
450932
Hi sdulepet, what menu option you referring with "Jsp and HTML Visual Editor"? I can't see this option in my Tools option.

Thanks in advance
didier - oracle
In the menu Tools -> Preferences

Please open new threads for new questions.

Regards,

Didier.
547042
Hi,


a little note follows in case it will be helpful for somebody sometime.

I faced this situation again and the followings did not help:
- reopening the JSF JSP,
- restarting JDeveloper,
- readding libraries,
- disabling PhaseListeners,
- creating and closing a new empty JSF JSP.

Finally I identified the problem in JDeveloper console log: a session-scoped managed bean could not be instantiated due to a null pointer exception.

Fixing the code, cleaning and rebuilding the project, then restarting JDeveloper helped.


Regards,
Patrik
1 - 16
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 6 2012
Added on Mar 9 2012
7 comments
391 views