Mozilla based browsers provide more powerful debugging tools so it is usually best to start there.
Firebug is probably the most useful debugging tool for Mapbuilder. It provides extensions to Firefox which allow numerous debugging features, but of most use is you can see all the GET/POST requests and responses.
Once installed, select Tools->Firebug->Disable Firebug (ticked). Then when you reload a page, you will see all the GET/POST requests in a console window at the bottom of the browser window.
This allows you to insert breakpoints, step through code etc.
To run, load a mapbuilder webpage. Open the Debugger. Insert breakpoints. Then Reload the mapbuilder webpage.
Web Developer extension for Mozilla based browsers
This adds lots of debugging goodies to Firefox/Seamonkey etc. and is well worth installing. Available at:
Microsoft Windows Script debugger (IE)
Use this for debugging Internet Explorer. Unfortunately it is quite poor compared to the Mozilla tools.
Download from: http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp
Docs at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdbug/Html/sdbug_1.asp
The debugger will appear when IE executes the line. You then can set the breakpoints through the rest of the code. Beware that it doesn't seem to always stop at breakpoints. When that happens just put a debugger statement at that location.
View Rendered Source (Mozilla)
This allows you to view the actual HTML code as used to display the page, including the HTML output of the widgets.
Install by selecting Tools->Extensions->"Get more extensions" and search for rendered source. Then it will be available under Tools->View Rendered Source
View Rendered Source (IE)
There is a view rendered source for IE as well, available at http://billfriedrich.tripod.com/index.html?Web.
XMLHttpRequest bookmarklet IE
A nice bookmarklet to see the XMLHttpRequests in internet explorer
In the config.xml file, you can insert a <debug> tag inside a widget and model tags.
This will trigger alert messages displaying XML, XSL, and HTML used during the widget rendering.
To figure out why a WMS layer isn't loading, it useful to load the GetMap URL in a browser window by itself to check the error output. Use the Web Developer Extensions (above) or view rendered source (above) to access to URL of the WMS image. Then try the image URL in the browser by itself. You may be receiving an XML error from the WMS.
- Paste the URL shown below (should be pasted as one single long string) in the location bar of a running Mapbuilder browser window.
- A new window will open displaying two textarea boxes.
Example 1. To view the rendered source of the currently loaded document, type the following in the top text box and click "evaluate":
Example 2. To inspect the properties and methods of the Mapbuilder "config" object, copy/paste the following into the top text box and click "evaluate":
Printing the Mapbuilder Object Model
Paste the script snippet below into the top text box of the ad hoc debug window, then click "evaluate" to print out a nicely indented Mapbuilder object model.
This helps troubleshoot a configuration file or just make sure things are set properly. It also makes for a great learning tool for developers who are new to Mapbuilder!
The script snippet
Example Output (using Mapbuilder Complete Demo)
"A script on this page is causing Mozilla/Firefox to run slowly..."
You may see this warning when running the script with gbEnumerateModel=1. Just hit "cancel" to continue running the script. You may see this warning multiple times before the script completes.
Bug in IE:
I have tested this script in the latest versions of Mozilla and Firefox, but noticed that there is an error in IE.
XML-XSLT Tester - XFactor
XFactor is an easy-to-use XSLT editor and tool that is available as a software companion to XSLT For Dummies.
XFactor allows you to load external XML and XSLT document and then view the transformed output. The loaded documents can then be edited so that you can test and troubleshoot your XSLT. Features syntax highlighting, auto-indenting...
XML-XSLT Tester - Treebeard
Similar to XFactor above, except that it seems to have a richer set of features. Treebeard allows you to load external XML and XSLT document and then view the transformed output.
Treebeard does not seem to work properly with Java 1.5.x. Users have reported it works fine with 1.4.2.