Tuesday, December 10, 2013

"Command Not Handled Exception" after removing "XPageDebugToolbar_v3.0.1" custom control from XPages

It would have happened to me again. I mean the long trial and error and the wage wait process to find errors in XPages. For some reason, my XPage would not open up if I remove the XPageDebugToolbar_v3.0.1 custom control from my XPage. And again it worked if I added it back again.

I was like 0.o why would this happen. Has the Debug toolbar author found a way to mess up XPages if they dont need them anymore :P. 

Fortunately I remember that one of my dynamic view controls used a managed bean in which I had declared an object reference to the debug tool bar

private static final DebugToolbar dBar = DebugToolbar.get();

to the answer was to put "//" before the line of code and make it

//private static final DebugToolbar dBar = DebugToolbar.get();

Yeah. Comment-ing the code fixed the issue. Wierd. Guess it would have been better it does not error out and surprice like this. 


Tuesday, December 3, 2013

Getting current column name from dynamic view control in managed bean

I followed the standard example provided in the documents as well as visuals by NotesIn9.com

Hence I was trying to obtain my view name from one of the values in the "svals" variable. For some reason all my attempts kept failing and I even got worked up. I was tired and XPageDebugToolbar came to my rescue after a couple of days of headache.

"svals" seemed to hold references of all stuffs present in the page and that was a sheer nonsense in terms of what I was expecting

I got it through the following code fragment

for (Map.Entry entry: svals.entrySet()) {
dBar.info("Key = " + entry.getKey().toString() + ", Value = " + entry.getValue().toString());
}

So I tried using the ColumnDef object to determine the column name and that worked -

 if (colDef.getName().equals("C1")) {
dynamicColumn.setRendered(false);
}

Hurray I got my work complete now :). Hope this helps some one else as well :)

Debugging managed beans in xpages

I copied all design elements from the XPageDebugToolbar v3.0.1 to my database and followed the procedures to debug my code. Some irritating stuff kept throwing "Command Not Handled" exception.

The error page was set to the error page mentioned by the XPageDebugToolbar v3.0.1 as per the documentation and hence I changed it back to default settings. Now I was able to see some clear meaningless errors. rolf.
It displayed something like the dbar.warn or dbar.error pointed to undefined values and hence no such methods existed.

So I made an attempt to check the "eu/linqed/debugtoolbar/DebugToolbar" file. That is where I found a clear error which upon fixing fixed the issue. The class (java design element) did not open up and instead it spoke of some refresh error and asked me to hit F9. How wonderful.

Now I have a managed bean with following lines of codes in different parts of the class which enabled me debug and fix the issue.

private static final DebugToolbar dBar = DebugToolbar.get();

dBar.info(colDef.getName()+"==C1 is " + (colDef.getName().equals("C1")));

for (Map.Entry entry: svals.entrySet()) {
dBar.info("Key = " + entry.getKey().toString() + ", Value = " + entry.getValue().toString());
}

My code is now fixed and I am one happy me now. :)

Dont forget to download and use the XPageDebugToolbar. It is really a great work and made my life easier with XPages.

I used to use a custom built logger tool which I built a couple of years ago. I used the same to create log documents and dump all my debugging statements. This helped me watch my code all these years.Now that I had to use Dynamic View Control from Extension Library, I had to use managed beans to manipulate so me column values and hurray my xLog failed. It simply did not create any log documents. Some posts kept telling me to recycle objects after they are used. It did not help either.

Hope this helps some one. :)