Parametrization of Terminology Browser
(Die Seite wurde neu angelegt: „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…“)
Zum nächsten Versionsunterschied →
Version vom 14. April 2014, 12:47 Uhr
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:
- There as to be a "?" behind the actual URL to indicate the end of the url and the begin of parameters
- After the "?" there can be inserted one or more parameters in the following pattern: www.abc.de?Parameter_Name=Value
- Parameters have to be separated with a "&": param1=value1¶m2=value2
- Parameters are case sensitive
- Mutated vowel and "ß" have to be replaced by "ae", "ue", "oe" and "ss"
- Blanks can be used and will be replaced with "%20" by the browser itself.
Inhaltsverzeichnis |
Deactivate/Hide parts of the TermBrowser
It is possible to hide some (unneeded) parts of the Browser ia URL Parameters:
- hideSelection=1, will hide the tree containing code systems and value sets. This has to be used in combination with deep links. Otherwise there will be no possibility to show any concepts.
- hideMenu=1, hides the upper menu.
- hideStatusbar=1 , hides the statusbar on the bottom of the browser
Example
Opens current ICD (see Deep Links) and hides the tree containing all code systems / value sets and the menu.
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:
- URL of the TermBrowser: http://www.term.mi.fh-dortmund.de:8080/Termbrowser/gui/main/main.zul
- loadType: possoble values are "CodeSystem" and "ValueSet"
- loadName: Name of the Code System / Value Set that shall be loaded. Do not forget to replace mutated vowels.
- loadId: Version ID of the Code System / Value Set (either loadId or loadName are requrired)
- c1,c2,... to open concepts and show their children (if any) as well. Due to load on demand, the full hierarchical path has to be used (see example below)
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:
- Need a ZUL-File(window)
- Add a JavaScript function receiveMessage(event) [name can be changed, see below]
- Add a EventListener to window (or other component) that listen on "message" and call the function receiveMessage(event)
- JAVA-File
- Method "myMethod(org.zkoss.zk.ui.event.Event e){...}"
- Method "openBrowser(String uri, String sendbackContent, String appName){...}"
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:
- appName: String that will be shown in TB so that the user knows where the data will be send to. Can be chosen freely.
- uri: URI of TermBrowser (e.g. http://localhost:8080/TermBrowser/gui/main/main.zul)
- 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.
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