(日本語) ドイツ、We4IT社との日本総代理店契約締結のお知らせ
Wednesday June 15th, 2016Notes/Domino 日本語,Aveedo,aveedoニュース,Notes/Domino,XPages
Sorry, this entry is only available in Japanese.
(日本語) IBM Watson Summit 2016 Day2にて講演を行います[F2-1]
Monday May 23rd, 2016Notes/Domino 日本語,XPages,Watson SummitIoT,ニュース,Notes/Domino,XPages
Sorry, this entry is only available in Japanese.
How to invoke function from string by XPages SSJS
Monday March 14th, 2016XPages,Notes/Domino 日本語,XPages,JSONNotes/Domino,XPages アプリケーション開発,JSON,Lotus Domino Designer,XPages アプリケーション開発
What's the case you want to invoke the function from string?
There are many situations you want to invoke the function from string of function name. One of case is for example, you might want to switch the functions from the parameter value of HTML Get/Post method.
The example below is client-side javascript(CSJS) when it's triggered from the URL like "http://mydomain.com/ApplyFuncXAgent.xsp?func=callMe". Then switch the flow by the query parameter value of "func".
If you want to simplify the code above, you can write the code like below:
In this case, window object is used to retrieve the function object, then call the target function. However Server-side Javascript(SSJS) does not have the window object like CSJS. Therefore you need to tweak this code a little.
(1) Use "this" instead of "window"
(2) Use eval()
Both (1),(2) can get the same result.
To pass the parameters, Use call() or apply()
Now we could call the function from string of function name. Then if you want to pass the parameters as well when call the funcion, you can use call() or apply() functions. Actually this way is pretty same as CSJS.
For example, when I call the HTTP Get request like "http://mydomain.com/ApplyFuncXAgent.xsp?func=callMe&args=aa,bb". (I added [args=aa,bb] as the function argument's values.) , the SSJS code becomes like below:
The code above is the example of using call(). If you want to use apply(), then instead of passing the arguments separated by comma, pass the Array to the second argument of apply(). Below is the sample code:
Sample code of using XAgent
In my situation, I needed to get the JSON data from the many notes views as the asynchronous connection. (Passing the JSON data for Kendo UI Grid data.) So I decided to use the XAgent to return the JSON data, however I didn't want to create XAgent XPages as many as notes views. So the sample code below calls the function from the Get parameter value of function name and returns the JSON data by the specified function.
HTTP request is like this -> "http://mydomain.com/hoge.nsf/ApplyFuncXAgent.xsp?func=testFunc&args=aa,bb"
Below is the sample code of xpCommon.jss which contains the callFuncByString() above.
The advantage of this logic is avoiding to create many XAgent for notes views. But please remember that dynamically calling the functions from string value sometimes lose the serviceability of code. For example debugging purpose.
*This XAgent is just for example and for the real coding, please pay attention to the security when you use this concept since any SSJS standard functions can be called remotely if you don't add any restriction and it is very dangerous.
(日本語) IBM Connect 2016 XPAGES 最新動向 Part 2 - 外部連携
Monday February 8th, 2016IBM Connect 2016,Notes/Domino 日本語,XPages,ibm connect 2016XPages アプリケーション開発,Notes/Domino,XPages
Sorry, this entry is only available in Japanese.
(日本語) IBM Connect 2016 XPages最新動向
Wednesday February 3rd, 2016Lotus Domino Designer,Notes/Domino,XPages,IBM ChampionIBM Connect 2016,Notes/Domino 日本語,XPages
Sorry, this entry is only available in Japanese.
(日本語) IBM Connect会場内の雰囲気
Wednesday February 3rd, 2016IBM Connect 2016
Sorry, this entry is only available in Japanese.
(日本語) Business Partner Summit 基調講演 - 2016/01/31
Tuesday February 2nd, 2016IBM Connect 2016
Sorry, this entry is only available in Japanese.