Friday, 10 February 2012

Calling inner classes and enum from SSJS

While working on RSS Reader custom control for OpenNTF I had got stuck when trying to use enums. Basically I wanted to call the enum Proxy.Type to create instance of Proxy class. In Java you would write the code some thing like this:


But to write the same code in SSJS you need to concatenate the class and enum with $ (dollar) symbol. So your SSJS code would be:


The same goes when you are dealing with nested / inner classes. But why use the dollar symbol? I am not sure of the exact reason, but when a Java class with inner class or enum is compiled it generates two class files - one for outer and one for nested. For e.g.


The above class would generate class files as OuterClass.class and OuterClass$InnerClass.class.

0 comments:

Post a Comment