As you might know it is quite time-consuming to debug your xpage code.  I created a small function that you can use in xpages that will print to your Firefox – firebug console and allow some debugging for Xpages in Firefox.

xpage debugging in firefox

You will need to create a server-side JavaScript; script library in your xpage application and add the following function to the script library.  This function is used to show console info messages.

If you want to show different messages or types of messages check out the console api and change the following function where I used “console.info” to whatever message you want to display.

If you want to create a console entry add try to catch to your code to be safe and call the function messageInfo(“Your Message”); or messageInfo(“YourMessage”, this);  When the second parameter is entered it will write that as a control to the log.

function messageInfo(message, control)
{
if	(sessionScope.errorMessages != null)
	{
		if (sessionScope.errorMessages.length > 10)
		{
			sessionScope.errorMessages = "";
		}
	}
 
	var value:string = "";
 
	//Displays the errorMessage
	value += "console.info('"+ message +"');";
 
	var controlS:string ="";
	//Writes the control
	if	(control != null)
	{
		var controlToUse:com.ibm.xsp.component.xp = getComponent(control.id);
		controlS += "Current ID: " + controlToUse.getId() + "; " + control + "; ";
		controlS += "Parent ID: " + controlToUse.getParent().getId() + "; Parent Type: " + control.parent();
		//controlS += control.parent();
		value += "console.info('"+ controlS +"');";
	}
 
	//Writes the session variable
	if (sessionScope.errorMessages == null)
	{
		sessionScope.put("errorMessages", value);
		//sessionScope.put("errorMessagesCount", 0);
	}
	else
	{
		sessionScope.errorMessages += value;
		//sessionScope.errorMessagesCount += 1;
	}
}

Also add the following xpage scriptblock to your main page or layout custom control

 

This is still a work in progress.  So in order to keep the sessionScope clean i added this “(sessionScope.errorMessages.length > 1000)”.  It will clean the sessionScope each time it gets to a length of a 1000.  Also you will have to refresh the page before it will show in the console.  if you have any suggestions on how to do this without a refresh please comment.

Thanks hope you enjoy. You can contact me on Skype @ corvitech