Saturday, January 7, 2012

Getting methods, fields, constructors for XPage Java classes


In my previous blog I was able to find out which Java classes were represented by global objects & functions of SSJS. For e.g. facesContext.getExternalContext() returns object of com.ibm.xsp.domino.context.DominoExternalContext. But what methods, fields, etc. are available in that class? To get those you use the Reflection API (java.lang.reflect package) in Java via which we can find out the methods, fields, etc in a class. Using this I built a small XPage which can explore these classes. Here’s how it looks:



It has a type-ahead feature to assist in writing package name.


Once your write the complete class name, click on any one of the buttons to get information about that class. One example is shown below – all the methods for class com.ibm.xsp.domino.context.DominoExternalContext:



Pitfalls
  1. You need to write complete class name. DominoExternalContext will NOT work. Write complete class name com.ibm.xsp.domino.context.DominoExternalContext.
  2. Lookout for case-sensitivity. com.ibm.xsp.domino.context.DOMinoExternalContext will return an error.
You can download the NSF from here.

No comments:

Post a Comment