The JavaScript debugger
runs automatically when JavaScript code
is encountered. You control the debugger from the Domino® Designer debug interface.
Before you begin
If a server is set up for debug mode, ensure that a debug
configuration is connected before running JavaScript code. Results are unspecified
if a debug configuration is not connected.
Procedure
- Insert debugger statements in the JavaScript code as desired. In debug mode, this statement stops execution the same as a
breakpoint. In non-debug mode, this statement has no effect.
Note: Use debugger statements
only in code that runs on a server with IBM® Domino 9.0 Social Edition or
greater. The debugger statement does not work on
earlier versions of Domino and
may cause problems.
- Open or preview the XPage containing the JavaScript code and activate the design
element that causes the code to run. If Stop at
first line of server-side JavaScript is in effect, the code
stops at the beginning of the first JavaScript section. Otherwise the code
stops at the first breakpoint. If nothing is set, the code executes
without stopping.
- Go to the Eclipse debug interface. The following
views reflect the state of the run-time where it is stopped:
- The debug view shows the current stack frame, including the Java stack.
- The editor view shows the code being executed. An arrow on the
left points to the current line. You can edit the code, but you must
reactivate the target design element to have the code take effect.
- The variable view shows the names and current values of variables
in the current code.
- Continue execution using the debug controls. Click
the Resume toolbar button to resume execution and
stop at the next breakpoint. Click Step Into, Step
Over, and other toolbar buttons for alternate actions.
- Set and manage breakpoints in the XPages Source editor
as follows:
- Double-click in the left column of a line of code to
set a breakpoint. A blue circle appears in the column.
Be sure that the line of code is executable. Otherwise the breakpoint
is not effective.
- Double-click in the left column of a line of code containing
a breakpoint to clear the breakpoint.
- Right-click in the left column of a line of code containing
a breakpoint to set, clear, enable, or disable the breakpoint, or
to adjust its properties.
- To make a breakpoint conditional, right-click in the
left column of the line of code containing the breakpoint and select Breakpoint
Properties. In the Properties for dialog,
select Enable condition and enter a script
that returns true or false. Take care that the JavaScript is correct as no validation
occurs.
Example
The following code is for a server-side click event
for a button:var s = "hello world";
var n = 0;
debugger
while (n < 3) {
n++;
debugger
}
var db = session.getCurrentDatabase();
var title = db.getTitle();
debugger
requestScope.status = "All done"
The execution sequence
in debug mode is as follows:- You open the containing XPage on the run-time server and click
the button that starts the JavaScript code.
The debugger stops at the first debugger statement.
The variable s has the value hello world.
The variable n has the value 0.
- You click the Resume toolbar button. The
debugger stops at the second debugger statement.
The variable n has the value 1.
- You click the Resume toolbar button. The
debugger again stops at the second debugger statement.
The variable n has the value 2.
- You click the Resume toolbar button. The
debugger again stops at the second debugger statement.
The variable n has the value 3.
- You click the Resume toolbar button. The
debugger stops at the third debugger statement. The
variables db and title are defined.
The variable db is an object that can be expanded.
- You click the Resume toolbar button. The
code completes and the debugger exits.
The following picture illustrates the Eclipse debug interface
when execution is at the last debugger statement: