Javascript API
From OpenKM Documentation
There're several UI javascript function public exposed. In some OpenKM customization cases is interesting accessing some public UI javascript functions ( take a look at this video [tab embeded web application].
Contents
General Functions
- jsI18n(String) - Returns frontend trasnlation where String is the translation key.
- jsOpenWikiPage(String) - Open wiki page where String is wiki title.
- jsOpenUserTaskInstance(String) - Open dashboard workflow view with user taskinstance, where String is the taskinstance.
- jsOpenPath(String, String) - Open some path in OpenKM UI. First String is folder path, second string is document path.
- jsopenPathByUuid(String) - Open some path in OpenKM UI where String indicates uuid.
- jsRefreshFolder() - Refresh ui, same as toolbar refresh button
- jsWizard(String, String) - Call wizard where first String is docPath and second String is json to string serialization of GWTFileUploadResponse bean.
- i18n(String) - Returns frontend trasnlation where String is the translation key ( deprecated from openkm 6.x ).
- openWikiPage(String) - Open wiki page where String is wiki title ( deprecated from openkm 6.x ).
- openPath(String, String) - Open some path in OpenKM UI. First String is folder path, second string is document path. ( deprecated from openkm 6.x ).
- openPathByUuid(String) - Open some path in OpenKM UI where String indicates uuid. ( deprecated from openkm 6.x ).
- refreshFolder() - Refresh ui, same as toolbar refresh button ( deprecated from openkm 6.x ).
Specific Cryptography Functions
- cryptographyLoaded() - Hide UI status indicating cryptography applet is yet loaded.
- digitalSignatureEnded() - Indicates digital signature has finished.
- digitalSignatureCanceled() - Cancelling digital signature has been canceled.
- startDigitalSignature() - Start digital signature.
Specific Applets Functions
- destroyScannerApplet() - Indicates should be cleaned the scanner applet
- destroyUploaderApplet() - Indicates should be cleaned the uploader applet
How expose GWT public methods to JS
Example 1- how to expose static method called i18n to public js as jsI18n
/**
* initJavaScriptApi
*/
native void initJavaScriptApi() /*-{
$wnd.jsI18n = function(s) {
return @com.openkm.frontend.client.Main::i18n(Ljava/lang/String;)(s);
};
}-*/;
Example 2- How to expose non static method from class Toolbar.java.
After Toolbar.java has been created can be called the initJavaScriptApi:
ToolBar toolBar = new ToolBar();
mainPanel.topPanel.toolBar.initJavaScriptApi(mainPanel.topPanel.toolBar);
Toolbar.java code:
/**
* initJavaScriptApi
*/
public native void initJavaScriptApi(ToolBar toolBar) /*-{
$wnd.jsRefreshFolder = toolBar.@com.openkm.frontend.client.widget.toolbar.ToolBar::executeRefresh();
}-*/;
For more information take a look at [latest GWT DevGuideCodingBasicsJSNI]