Using Rootless Mode

NeuroKernel can be launched in multiple ways not just as a workstation. Using rootless mode of NeuroKernel, it is possible to embed NeuroKernel into your web page. In rootless mode, windows can be embedded into “DIV” elements as well, and NeuroKernel applets can also be used. A global object to communicate with NeuroKernel desktop manager, which should be crafted by the developer, will be available to the web page. Forms can be submitted securely without needing a captcha or form submit attack. Windows and dialogs can still be used. It is possible to pin them on the desktop so that when the page scrolls they can remain on the screen.

1. Using Document Window

Document window can only be created when in rootless mode. Rootless mode is a special mode where NeuroKernel can be embedded in a normal web page. The desktop window is not made visible on this mode to make the web page operational. In this mode, desktop window can spawn any kind of window, and it can also embed windows inside DIV elements using document window object. The size of the window is automatically updated when the size of the parent DIV element changes. This makes creative mashups with NeuroKernel possible. The code segment below shows an example use of document window in a desktop manager implementation.

final NFrame rootlessTest=new NFrame(getMainFrame());
new NButton(rootlessTest,"test").addListener(new IEventListener() {
    boolean pinned;
    @Override
    public void onEvent(NEvent e) {
        pinned=!pinned;
        rootlessTest.pinToDocument(pinned);
        NDocumentWindow doc=getRootDocument();
        doc.setBackground(NColor.BLUE);
        doc.scrollTo(2000, 0, NAnimation.Easing.EXPONENTIAL_IN);
    }
}, NEventTypes.ACTION);
 
rootlessTest.setSize(200, 150);
rootlessTest.setVisible(true);

2. Embedding in Elements

It is possible to embed windows inside a DIV elements. The embedded window will be automatically resized when the containing DIV element is resized.

NWindow window=getRootDocument().createWindow(htmlRenderer.getElement("staticpanel"));
new NComboBox(window,"test").getColumn().importData("Hello","World");
window.setSize(200, 200);
window.setVisible(true);

3. Communicating with System

Web page embedding NeuroKernel can communicate with the desktop manager task using javascript object passed to the custom document event called neurokernel. The sendMessage method of the object is used to communicate. This custom event is dispatched by kernel when the system is ready. Page can listen to the messages sent back from desktop manager by listening the message event on the window object.

  document.addEventListener("neurokernel", function(e) {
         e.detail.sendMessage("Hello there");
  });