Parametrization of Terminology Browser

Aus Termserver-CTS2
Wechseln zu: Navigation, Suche

There are some extra funcions that can be used via URL parameters. Generally all URL parameters can be combined with each other, although some combinations do not make any sense.

How to use URL parameter:

http://www.term.mi.fh-dortmund.de:8080/TermBrowser/gui/main/main.zul?Parameter1=Value1&Parameter2=Value2

Inhaltsverzeichnis

Deactivate/Hide parts of the TermBrowser

It is possible to hide some (unneeded) parts of the Browser ia URL Parameters:

Example
Opens current ICD (see Deep Links) and hides the tree containing all code systems / value sets and the menu.

http://www.term.mi.fh-dortmund.de:8080/TermBrowser/gui/main/main.zul?loadType=CodeSystem&loadName=ICD&hideSelection=1&hideMenu=1

Deep-Links

With deep links there is the possibility to open a code system or value set at start up via URL. It is also possible to open a certain concept and display its children.

The following URL (parameters) have to be used to load a code system directly:


For informations how to use url parameters read the section above (How to use URL parameter).


Examples:
Load current version of ICD:
http://www.term.mi.fh-dortmund.de:8080/Termbrowser/gui/main/main.zul?loadType=CodeSystem&loadName=ICD

Load current version of Value Set "Test ValueSet":
http://www.term.mi.fh-dortmund.de:8080/Termbrowser/gui/main/main.zul?loadType=ValueSet&loadName=Test%20ValueSet

Load chapter "Bösartige Neubildungen" of current ICD version:
http://www.term.mi.fh-dortmund.de:8080/Termbrowser/gui/main/main.zul?loadType=CodeSystem&loadName=ICD&c1=Neubildungen&c2=Boesartige%20Neubildungen

Send name, description and/or code of CS(V), VS(V), DV or CSEV to other (ZK)applications

It is possible to send the name, description and/or code of concepts, code systems and value setst to other (zk) applications due to javascripts' Cross-window messaging with postMessage.

The following tasks need to be done for that in the recieving applicaion:

ZUL-File of receiving application with JavaScript

The JavaScript sends an event to a component (here widgetMainWindow) and invokes the "onSendBackString" method, that has to be defined in the corresponding Java file.

    <window id="myWindow" use="myPackage.myWindow">       
 
        <!-- Add Eventlistener for incoming messages form "postMessage(String)" -->  
        window.addEventListener("message", receiveMessage, false);
 
        <!-- Script for receiving strings from Term Browser -->        
        <script type="text/javascript">            
            function receiveMessage(event){                                          
                var widgetMainWindow = zk.Widget.$('$mainWindow');
                var e                = new zk.Event(widgetMainWindow, "myMethod", event.data);                                
                zAu.send(e);                          
            }
        </script> 
 
        <div>
            <button id="bOpenTB"  label="Open Browser iFrame"  />
        </div>
 
    </window>

JAVA File with methodes myMethod and openBrowser

First the ZUL File has to be linked to a java file by using "use" or "apply" (see ZK Documentation). After that you have to create the onSendBackString mehtod that will be invoked by the JavaScript defined above.

onMySendBackFunction

public class MyWindow extends org.zkoss.zul.Window implements org.zkoss.zk.ui.ext.AfterCompose{
 
    ...
 
    // Java-Mehtod that will be called by JavaScript
    public void myMethod(org.zkoss.zk.ui.event.Event e){
        Object s = e.getData();
 
        try {            
            org.zkoss.zul.Messagebox.show("Successfully received Data: \n\n" + s);                        
        } catch (Exception ex) {
            Logger.getLogger(MyWindow.class.getName()).log(Level.SEVERE, null, ex); 
        }
    }
 
    // Example of calling TB via button that loads the current ICD
    bOpenTB.addEventListener(org.zkoss.zk.ui.event.Events.ON_CLICK, new EventListener() {
        @Override
        public void onEvent(org.zkoss.zk.ui.event.Event event) throws Exception {
            openBrowser("http://localhost:8080/TermBrowser/gui/main/main.zul?loadType=CodeSystem&loadName=ICD",                        
                        "111117",            // how to use this, see below                         
                        getTitle());         // that string will be shown in TB so that the user knows where the data will be send to
        }
    });                
 
 
    ...
 
}

OpenBrowser
Parameter:

The answer from the TB is only one single string. If the user wants two or three values to be send back, all data will be separated by a ";;" sequence. E.g. if name, description and code shall be send back the answer would be: "name;;description;;code". If one value is not present, e.g. there is no description for an element, "null" will be returned instead.

Details on method "openTermBrowser":
Other applications can load the TB in a org.zkoss.zul.Iframe via setSrc(url). There is no other possibility to load another application into its own other then using iframes (that has not to be a ZK iframe) that have their own desktop and session, as if it is loaded into a new tab of the browser. So due to security reasons it is difficult to send data across different tabs.

Dabei beinhaltet die URL zum einen die Adresse des Termbrowsers (z.B. http://localhost:8080/TermBrowser/gui/main/main.zul) und weitere Parameter, um auszuwählen, welche Objekte (Vokabulare, Value Sets, etc.) welche Daten (Name, Beschreibung oder Code) an App A zurücksenden können. Die Parameter werden weiter unten erläutert.

    /**
     * @param uri: URI of Term Browser (e.g. http://localhost:8080/TermBrowser/gui/main/main.zul)     
     * @param sendbackContent: Specifies what elements (domain values, code systems, code system versions, value sets, value set versions, concepts) 
     *                         get a new context menu to send back data. This string has to have a length of 6, otherwise it will not work. The 
     *                         digits tells the TB what data shall be send back to the calling application: 
     *                         0 = nothing/deactivated for that element
     *                         1 = name
     *                         2 = description
     *                         3 = name and description
     *                         4 = code
     *                         5 = name and code
     *                         6 = description and code
     *                         7 = name, description and code. 
     * @param appName: String that will be shown in TB so that the user knows where the data will be send to. Can be chosen freely.
     */
    private void openBrowser(String uri, String sendbackContent, String appName)
    {  
        if(SessionHelper.getValue("jsMethodAdded") == null)
        {
          Clients.evalJavaScript("window.addEventListener(\"message\", receiveMessage, false);");
          SessionHelper.setValue("jsMethodAdded", true);
        }
 
        String sAppName    = "sbAppName="    + appName;
        String sParameter  = "sbContent="    + sendbackContent;          
 
        // check for "/" at the end of the uri
        if(uri.endsWith("/")) uri = uri.substring(0, uri.length()-1);
 
        // check for "?" 
        if(uri.contains("?")) uri += "&";
        else                  uri += "?";
 
        uri += sAppName + "&" + sParameter;   // e.g. uri = "http://www.term.mi.fh-dortmund.de:8080/Termbrowser/gui/main/main.zul?loadType=CodeSystem&loadName=ICD";
 
        // new window
        wBrowser = new Window();
        wBrowser.setHeight("90%");
        wBrowser.setWidth("90%"); 
        wBrowser.setClosable(true);
 
        // new iframe
        Iframe iFrame = new Iframe();
        iFrame.setHeight("100%");
        iFrame.setWidth("100%");
        iFrame.setSrc(uri);
        iFrame.setParent(wBrowser);
        wBrowser.appendChild(iFrame);
        this.appendChild(wBrowser);       
        try {
            wBrowser.doModal();
        } catch (Exception ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); }
    }

How TermBrowser sends the message back

    public void sendBack(String text){            
        String javaScript = "window.top.postMessage('"+ text + "', '\\*')";    
        org.zkoss.zk.ui.util.Clients.evalJavaScript(javaScript);            
    }

Combinations with other URL parameters

Generally there is no restriction concerning the usage of other url parameters and sometimes is is recommended to deactivate some parts of the TB. All you have to do is to modify the url parameter of the method "openBrowser".

Example: uri = http://www.term.mi.fh-dortmund.de:8080/TermBrowser/gui/main/main.zul?loadType=CodeSystem&loadName=ICD&hideSelection=1&hideMenu=1&hideStatusbar=1

Meine Werkzeuge
Namensräume
Varianten
Aktionen
Navigation
Werkzeuge