Exposed frontend JavaScript API
OpenKM UI is developed with GWT framework what helps on calling Java methods from JavaScript.
The UI frontend Java methods are public exposed as JavaScript functions an can be used in frontend context.
More information about GWT JSNI at GWT Dev Codings Basics.
General functions
The methods that do not start with "js" will no longer be supported in the near future, we encourage you to move to js equivalent ones.
Function | Return | Description | Deprecated |
---|---|---|---|
jsI18n(String) |
void |
Retrieve a frontend translation. The parameter is the translation key. |
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 |
HTML Editor functions
Function | Return | Description | Deprecated |
---|---|---|---|
jsSearchDocumentHTMLEditorPopup() |
void |
Show find document popup. |
no |
jsSearchFolderHTMLEditorPopup() |
void |
Show find folder popup. |
no |
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
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
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);
Complete information about GWT JSNI at GWT Dev Codings Basics.