Genii Weblog

Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.

Thu 27 Aug 2020, 08:17 PM
Inline JPEG image
In my earlier post, Quick primer on JSON-RPC, I promised to post videos showing some features of our new Exciton Boost, due out next week. A few days ago, I followed this up with a first at the REST API in REST Revisited. It is time to demonstrate the RPC API, but I want to start with a little context.
In the modern world, both server and client are very powerful. Processing power is abundant, but there are still decisions to be made about where processing should happen. These decisions may be based on security, on related data available, on where you want business logic to live, and many other reasons. In this simple demo, I should how you can use powerful RPC methods on data as it is being pulled out of Domino, even without changing the data on Domino. So, the logic is done there, but the results are passed to the client. You can use similar logic to change the data in Domino, or to change data as it is added to Domino, but we'll look at use cases for both in another demo.
HTML and JavaScript used in the demo. I hardcoded the UNID in this, but the logic would work the exact same way of I had walked a view and read a document from there. Note that there is no explicit authentication code because this lives in the same database and the session handles that.
<!DOCTYPE html>
const genHTM =   { jsonrpc: "2.0",  
                   method: "rtc.generateHTML",
                   params: [ "Everything", "XHTML", "CSSBorders=yes Generation=fragment " ],
                   id: 1
const glossary = { jsonrpc: "2.0",
                   method: "rtc.linkMatching",
                   params: [ "", "MedXref.nsf", "Medical Glossary", "Term", "Definition",
                             "Fieldname=Definition Hotspot=Mouseover Style=Highlight " ]
const links =    { jsonrpc: "2.0",
                   method: "rtc.linkMatching",
                   params: [ "", "MedXref.nsf", "MedLinks", "Term", "Link", "SingleMatch='Yes' " ]
function doIt(num) {
switch(num) {
  case 1:
    var data = [genHTM];
  case 2:
    var data = [glossary, genHTM];
  case 3:
    var data = [glossary, links, genHTM];
    var data = [genHTM];
  method: 'POST', 
  mode: 'same-origin',
  cache: 'no-cache',
  headers: {
    'Content-Type': 'application/json',
  body: JSON.stringify(data),
.then(response => response.json())
.then(data => {
 document.getElementById("demo").innerHTML = data[0].result;
.catch((error) => {
  console.error('Error:', error);
<button type="button" style="border-radius: 6px;" onClick="doIt(1);">Get the document as is</button><br>
<button type="button" style="border-radius: 6px;" onClick="doIt(2);">Get the document and apply the glossary on the way out</button><br>
<button type="button" style="border-radius: 6px;" onClick="doIt(3);">Get the document and apply the glossary and link matcher on the way out</button><br>
<p id="demo"></p>

Copyright 2020 Genii Software Ltd.