Wow! SmartNSF (BETA-5) can now call java directly, and work with the parameters with ease!
This evening it was time to test the latest and greatest version of SmartNSF – BETA 5. When you have installed it (via an updatesite database for the server) and via a local update site in your Designer, you get some cool new features. First of all, intellisense seems to work very good so now it is much easier to get the available methods etc.
But, the really cool feature in this version is the support for CUSTOM strategies. This means that you can define a route like this (the example below is directly from the discussion.nsf sample database enclosed in the SmartNSF zip);
The URI infos will call the Info-class in the package org.opennrf.smartnsf. This means that an URL like http://www.vcode.no/test/discussion.nsf/xsp/.xrest/infos (note; URL is shown just for illustration purposes, and is not active) will call the java code shown below;
(Click on image to enlarge)
Tips, If you can find the java code directly, then ensure you open the Java perspective in Domino Designer;
Then you can navigate to the java objects in the Package Explorer like this;
What about other URIs (variables)?
From the example above it looked like it was very easy to produces JSON output from an arbitrary java-class. But what if you want to use URIs like this:
http://www.vcode.no/test/discussion.nsf/xsp/.xrest/info/123 (again, URL is just for illustration purposes)
Note that I have stuffed my own variable "123" to the URL above.
The SmartNSF developers with Christian Güdemann and Martin Jinoch hang out on the OpenNTF's Slack channel a lot, and Chritian answered my question within minutes (!). Giving me the correct pointers I was able to create this route;
Note the variables {myparam}. This is what should contain "123" in my sample.
The super-cool thing with SmartNSF is that all router variables (amongst other stuff) are transfered along the input-context to the backend java-class. Using the intellisense I could see that the context contained a method called getRouterVariables;
I modified the sample code to reveal the content of the getRouterVariables-method, like this;
Marked by 1, I define a Map of strings, and fill it with the result from the getRouterVariables-method. Marked by 2 I have a small loop dumping all the variables. Note that I prefix them with "p_" just to be able to locate them directly. The result from the code above was this;
Whoo!! In other words, the variable definition from the route was used directly, and I can now continue to use my other java-classes instantly!! Marvelous!!! Thanks a million Christian and Martin (hope I don't forget too many others now ).
Comments
Posted by Jesper Kiaer At 09:33:37 On 01.11.2017 | - Website - |