Databases Reference
In-Depth Information
C H A P T E R 8
■ ■ ■
Debugging & Tools
Developing plug-ins, especially your first plug-in, can be difficult without the appropriate tools and
debugging techniques. This chapter discusses how to instrument your plug-in. It also covers some tools
to help assist and speed up your plug-in development.
Debugging and Code Instrumentation
Instrumenting your plug-ins will help quickly and effectively resolve issues as you encounter them. In
some cases where your plug-in is used in other environments (i.e., you publish for others to use), you
may not have the luxury of viewing the application and will need to solely rely on what information you
can get from various debugging and logging tools.
This section will cover how to instrument both PL/SQL and JavaScript code. It is important to
instrument both parts, as they can both play major roles in your plug-ins.
JavaScript Console Wrapper
When writing JavaScript code for a plug-in, it is important to add as much debugging code as possible.
This can be extremely useful for debugging your own issues during the initial phases of plug-in
development and for resolving them once they are in production or others are using them.
Before continuing with this section, you should read the section under Tools Firebug and Console
in the Firefox on how to install and view Console outputs.
At a high level, Console allows you to add some additional code in JavaScript, which will display the
results in a special window. This means that you do not need to interrupt the user with debugging
messages, etc.
Some of the older browsers do not support JavaScript calls to the Console APIs. This can be a bit of
an annoyance since you may instrument your code with console.log calls and then have to remove
them before going to production.
APEX provides you with a simple JavaScript function called apex.debug . It handles the browser-specific
issues so you can keep it in your code and it will not crash applications that are run in older browsers.
When used, it will only display messages in the Console window when the application is run in debug
mode.
Figure 8-1 shows a simple example of the apex.debug function when the application is run in regular
(non-debug) mode. You'll notice that nothing was displayed in the Console window. Figure 8-2 shows
the exact same call when the application is run in debug mode. In this case, a message was displayed in
the Console window.
 
Search WWH ::




Custom Search