In my previous post I described how you can install WTP in Flex Builder and how you can create a combined Java/Flex project and run it.
But what if you want to debug both the Flex and Java code from the project at the same time?
Actually, it is pretty simple. The steps are very similar with the ones described in the previous post for running the application.
First thing let’s add two break points one in Flex code and one in Java code. My project is using LCDS (LiveCycle Data Services) and I have a custom adaptor written in Java to read/write data to and from databases. So I place one breakpoint inside ActionScript in the function that is called when I want to add a new item and the other breakpoint inside the Java adaptor class that actually adds the item to the database.
The next step is to stop the server from Server view if it is running. After this you need to start it but in debug mode (for these actions you have at the top right of the Server view some icons that perform these actions).
After the server started you right click on the Flex application file and choose from “Debug as” entry of the contextual menu “Flex Application”. This will start the default browser with the Flex application running.
If I click the button that adds a new item, Flex Builder will go in Debug view and you will see the Flex debugger. If you resume, Flex Builder will continue the execution and as the Flex code calls the server destination you will go to the Java code and again Flex Builder goes in debug view this time for Java. Here are the two screenshots one for Flex and one for Java:
We saw how to create a new project that has both Java and Flex natures, then how we can run and debug the project. But what if you have an existent Java project and you want to be able to edit Flex files? I will show you the easiest way in the next post.