Frontend UI extensions stuff

Internatinalization

Register new translations from Database query.

INSERT INTO OKM_TRANSLATION (TR_MODULE, TR_KEY, TR_TEXT, TR_LANGUAGE) VALUES ('extension', 'new_extension.button.add', 'Add', 'en-GB');
INSERT INTO OKM_TRANSLATION (TR_MODULE, TR_KEY, TR_TEXT, TR_LANGUAGE) VALUES ('extension', 'new_extension.button.add', 'Añadir', 'es-ES');

Use in your code:

GeneralComunicator.i18nExtension("new_extension.button.add");

Also can be used default OpenKM translations:

GeneralComunicator.i18n("button.close");

Sample

Remember any extension internationalized must implements LanguageHandlerExtension. Each time the user interface change language this handler is fired.

private class ToolBarButton extends ToolBarButtonExtension implements LanguageHandlerExtension {
	public ToolBarButton(Image image, String title, ClickHandler handler) {
		super(image, title, handler);
	}
 
	@Override
	public void checkPermissions(GWTNode node, GWTNode nodeParent, int originPanel) {
		// TODO
	}
 
	@Override
	public void checkPermissions(GWTDocument doc, GWTNode node) {
		// TODO
	}
 
	@Override
	public void checkPermissions(GWTMail mail, GWTNode node) {
		// TODO
	}

	@Override
	public void checkPermissions(GWTRecord record, GWTNode node) {
		// TODO
	}
 
	@Override
	public void enable(boolean enable) {
		// TODO
	}
 
	@Override
	public boolean isEnabled() {
		return true;
	}
 
	@Override
	public void onChange(LanguageEventConstant event) {
		if (event.equals(HasLanguageEvent.LANGUAGE_CHANGED)) {
                        setTitle(GeneralComunicator.i18n("download.button.tittle"));
		}
	}
}

Registering RPC ( Remote Process Call ) service

Servlets are used to do GWT RPC ( Remote Process Calls ). In order to registering a new Servlet file ( web.xml ) must be modified and OpenKM re-compiled.

Into web.xml ( src/main/webapp/WEB-INF ) must be added the servlet declaration:

<servlet>
    <servlet-name>SomeServletName</servlet-name>
    <servlet-class>SomeJavaClassName</servlet-class>
</servlet>
 
<servlet-mapping>
    <servlet-name>SomeServletName</servlet-name>
    <url-pattern>/SomeServletName</url-pattern>
</servlet-mapping>

RPCService class defines all RPC constants service that can be used from GWT:

ServiceDefTarget endPoint = (ServiceDefTarget) messageService;
endPoint.setServiceEntryPoint(RPCService.MessageService);
messageService.deleteSent(1, new AsyncCallback<Object>() {
        @Override
	public void onSuccess(Object result) {
	}
 
	@Override
	public void onFailure(Throwable caught) {
	}
});