facebook

How can I set breakpoints in html/javascript fragments?

  1. MyEclipse Archived
  2.  > 
  3. Web 2.0 / AJAX
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #287747 Reply

    I want to debug some javascript that comes from html that’s assembled at runtime by the application. What the app does is treat the “.html” file as something of a template with placeholders for runtime-generated content. While this should be done with a technology like JSP, this application already exists and I need to work on it.

    So if I view the html and set a breakpoint on a javascript line inside a script element, I apparently never hit my breakpoint because the URL the client references doesn’t refer to the html file? Instead, my servlet programmatically accesses that file while delivering content to the client.

    For example, let’s say I have an html file called my_app.html. My servlet is programmed to respond to a url like http://localhost:8080/myapp/home by opening my_app.html, plugging in some runtime content like the user’s name and streaming that to the client.

    So apparently the javascript debugger has no way to relate the file with my breakpoint in it to the content the client browser received?

    Do I need to externalize my JavaScript code into files that are separate from these html fragments? Or is there maybe a simpler strategy that doesn’t impact this existing application that much?

    Thanks for your help.

    #287769 Reply

    Riyad Kalla
    Member

    When you are viewing your app using the Web 2.0 Workbench, as you work with the app, in the DOM view are you seeing the updated/correct values including the JavaScript you are injecting from the server side?

    #287786 Reply

    I didn’t realize I could wait till then to set breakpoints. But I set my AJAX preferences to suspend-at-start. And the debugger shows my html plus javascript when I start my javascript-debug launch configuration on the debug menu. The only enabled tools on the debugger toolbar are green/go and red/stop (no step into, etc). I double-click in the margin to set a breakpoint on the first line of code in the script tag and see visual confirmation that my breakpoint is set. Press the green/go and I don’t hit that breakpoint.

    Then I filled out a form on this page and hit Submit. The debugger did not stop at any subsequent page loads until I launched a new debug session.

    #287867 Reply

    Riyad Kalla
    Member

    Hmm it sounds like the JS debugger isn’t digesting the new code right away coming back to it. I know we are doing a lot of work on JavaScript in 7.0, I’ll make a note of us to check into this for that release. Sorry about the hickup.

    Q: You know about using the browser view to browse to your particular page and then hitting the little “Bug” icon to start a debug session right there on that particular page right? (Might be an easier workflow for you)

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: How can I set breakpoints in html/javascript fragments?

You must be logged in to post in the forum log in