Exposed frontend JavaScript API
Esta página aún no está disponible en tu idioma.
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 dashboard workflow to view with user tas. The parameter is the taskinstance id. |
no |
| jsOpenPath(String, String) | void | Open some node in OpenKM UI. First parameter is folder path. Second parameter is document path. When document path parameter is empty will be opened a folder. |
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 UI ( like toolbar refresh button action ). | no |
| jsWizard(String, String) | void | Execute wizard. First parameter is a document path. Second parameter is a JSON to String serialization of GWTFileUploadResponse bean. The wizard usually should be called after a 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. First parameter is folder path. Second parameter is document path. When document path parameter is empty will be opened a folder. |
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 UI ( like toolbar refresh button action ). | yes |
| jsCancelCheckout() | void | Cancel document checkout of the selected document in UI. | no |
| jsGetActualPath() | String | Return the path of selected tree node in navigator. | no |
| jsGetActualNodePath() | String | Return the path of the selected node in navigator or file brower. | no |
| jsGetActualNodeUUID() | String | Return the uuid of the selected node in navigator or file brower. | no |
| jsGetUser() | String | Return 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 workspace tab. Allowed values: - 0 for Desktop. - 1 for Seach. - 2 for Dashboard. - 3 for Administration. |
no |
Cryptography functions
Section titled “Cryptography functions”| Function | Return | Description | Deprecated |
|---|---|---|---|
| cryptographyLoaded() | void | Hide UI popup status that indicates cryptography applet is not yet loaded. | no |
| digitalSignatureEnded() | void | Indicate the digital signature has finished. | no |
| digitalSignatureCanceled() | void | Cancelling digital signature has been canceled. | no |
| startDigitalSignature() | void | Start digital signature. | no |
Applet functions
Section titled “Applet functions”| Function | Return | Description | Deprecated |
|---|---|---|---|
| destroyScannerApplet() | void | Cleaned 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 find document popup. | no |
| jsSearchFolderHTMLEditorPopup() | void | Show 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 jsRefreshFolder function:
In the Toolbar Java 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 “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>