Exposed frontend JavaScript API
General functions
Section titled “General functions”| Function | Return | Description | Deprecated |
|---|---|---|---|
| jsI18n(String) | void | Retrieve a frontend translation. The parameter is the translation key. |
no |
| jsOpenUserTaskInstance(String) | void | Open the dashboard workflow to view a user task. The parameter is the task instance id. |
no |
| jsOpenPath(String, String) | void | Open some node in OpenKM UI. The first parameter is the folder path. The second parameter is the document path. When the document path parameter is empty, a folder will be opened. |
no |
| jsOpenPathByUuid(String) | void | Open some node in OpenKM UI. The parameter is a valid node UUID (document, folder, mail, or record). |
no |
| jsRefreshFolder() | void | Refresh the UI (like the toolbar refresh button action). | no |
| jsWizard(String, String) | void | Execute wizard. The first parameter is a document path. The second parameter is a JSON string serialization of a GWTFileUploadResponse bean. The wizard should usually be called after uploading a document. |
no |
| i18n(String) | void | Retrieve a frontend translation. The parameter is the translation key. |
yes |
| openPath(String, String) | void | Open some node in OpenKM UI. The first parameter is the folder path. The second parameter is the document path. When the document path parameter is empty, a folder will be opened. |
yes |
| openPathByUuid(String) | void | Open some node in OpenKM UI. The parameter is a valid node UUID (document, folder, mail, or record). |
yes |
| refreshFolder() | void | Refresh the UI (like the toolbar refresh button action). | yes |
| jsCancelCheckout() | void | Cancel checkout of the selected document in the UI. | no |
| jsGetActualPath() | String | Return the path of the selected tree node in the navigator. | no |
| jsGetActualNodePath() | String | Return the path of the selected node in the navigator or file browser. | no |
| jsGetActualNodeUUID() | String | Return the UUID of the selected node in the navigator or file browser. | no |
| jsGetUser() | String | Return the GWTUser object serialized to JSON. | no |
| jsDownloadByUuid(String) | void | Download a document. The parameter is the UUID of the document. |
no |
| jsChangeSelectedTab(int) | void | Change the workspace tab. Allowed values: - 0 for Desktop. - 1 for Search. - 2 for Dashboard. - 3 for Administration. |
no |
Cryptography functions
Section titled “Cryptography functions”| Function | Return | Description | Deprecated |
|---|---|---|---|
| cryptographyLoaded() | void | Hide the UI popup status that indicates the cryptography applet is not yet loaded. | no |
| digitalSignatureEnded() | void | Indicate that the digital signature has finished. | no |
| digitalSignatureCanceled() | void | The digital signature has been canceled. | no |
| startDigitalSignature() | void | Start the digital signature. | no |
Applet functions
Section titled “Applet functions”| Function | Return | Description | Deprecated |
|---|---|---|---|
| destroyScannerApplet() | void | Clean the scanner applet. | no |
| destroyUploaderApplet() | void | Clean the bulk upload applet. | no |
HTML Editor functions
Section titled “HTML Editor functions”| Function | Return | Description | Deprecated |
|---|---|---|---|
| jsSearchDocumentHTMLEditorPopup() | void | Show the find document popup. | no |
| jsSearchFolderHTMLEditorPopup() | void | Show the find folder popup. | no |
Wiki functions
Section titled “Wiki functions”| Function | Return | Description | Deprecated |
|---|---|---|---|
| jsOpenWikiPage(String) | void | Open a wiki page. The parameter is the unique wiki title. |
no |
| openWikiPage(String) | void | Open a wiki page. The parameter is the unique wiki title. |
yes |
How to expose Java methods to JavaScript
Section titled “How to expose Java methods to JavaScript”Static method sample
Section titled “Static method sample”Expose static method named i18n(String property) to JavaScript as “jsI18n(String)” function:
/** * initJavaScriptApi */native void initJavaScriptApi() /*-{ $wnd.jsI18n = function(s) { return @com.openkm.frontend.client.Main::i18n(Ljava/lang/String;)(s); };}-*/;Non-static method sample
Section titled “Non-static method sample”Expose non-static method “executeRefresh()” from class Toolbar.java to JavaScript as the jsRefreshFolder function:
In the Toolbar Java class, create a method named “initJavaScriptApi()”:
public native void initJavaScriptApi(ToolBar toolBar) /*-{ $wnd.jsRefreshFolder = function() { toolBar.@com.openkm.frontend.client.widget.toolbar.ToolBar::executeRefresh()(); return true; }}-*/;After creating a new Toolbar object, call the “initJavaScriptApi()” method:
ToolBar toolBar = new ToolBar();mainPanel.topPanel.toolBar.initJavaScriptApi(mainPanel.topPanel.toolBar);Integration sample
Section titled “Integration sample”Create a “sample.jsp” file:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %><html> <head> <title>Sample test</title> <script> function refresh() { alert('executing refresh'); parent.parent.refreshFolder(); alert('done'); } </script> </head> <body> <a href="#" onclick="refresh()">Refresh UI</a> </body></html>