Check documentation for the latest version of dhtmlxSuite JSONCommonConnector and CommonConnector DHTMLX Docs

JSONCommonConnector and CommonConnector


There are 2 connectors you can use for touch-oriented DHTMLX libraries (such as DataTable, DataStore):

  • CommonConnector
  • JSONCommonConnector They both work the same way, but differ in type of returned data.
import java.sql.Connection;
import com.dhtmlx.connector.ConnectorServlet;
import com.dhtmlx.connector.JSONCommonConnector;
public class basic_connector extends ConnectorServlet {
   protected void configure() {
       Connection conn= ( new DataBaseConnection()).getConnection();
       JSONCommonConnector c = new JSONCommonConnector(conn);
       c.render_table("grid50000", "item_id", "item_nm,item_cd");


CommonConnector generates 'XML' data feed as in:

   <item id="1" title="War and Peace"  author="Leo Tolstoy"/>
   <item id="2" title="Hamlet"         author="William Shakespeare"/>
   <item id="3" title="Madame Bovary"  author="Gustave Flaubert"/>


JSONCommonConnector generates 'JSON' data feed as in:

   { id:"1", title:"War and Peace",    author:"Leo Tolstoy" },
   { id:"2", title:"Hamlet",           author:"Shakespeare" },
   { id:"3", title:"Madame Bovary",    author:"Gustave Flaubert" }

Adding tags/sections to data

Starting from version 1.5, there is a possibility to add the first child tags, sections to data returned by the connector. To add the tag(section), use method add_section:


For example, if you call add_section as follows:

CommonConnector c = new CommonConnector(conn);
c.add_section("config", "some_data");
c.add_section("config2", "<column>value1</column><column>value2</column>");

CommonConnector produces the next data:

    <item id="1" attr1="qwe" attr2="asd" />
    <item id="2" attr1="qwe" attr2="asd" />


If you call add_section as follows:

JSONCommonConnector c = new JSONCommonConnector(conn);
c.add_section("config", "'some_data'");
JSONObject data = new JSONObject();
data.put("column1", "value");
c.add_section("config2", data);

JSONCommonConnector produces the next data:

    data: [
      { 'id': '1', 'attr1':'qwe', 'attr2':'asd'},
      { 'id': '2', 'attr1':'qwe', 'attr2':'asd'}
    config: { 'some_data' },
    config2: { 'column1':'value' }

Simple Data Transfer

dhtmlxDataJsonConnector/dhtmlxDataConnector supports simplified protocol for CRUD requests

  • get all data
 GET  data?action=get

server response - collection of json (xml) objects

  • get info for some specific record
 GET  data?action=get&id=123

response - json(xml) object

  • delete
 GET  data?action=delete
 POST id=123

server response - 'true'/'false'

  • insert
 GET  data?action=insert
 POST id=123&some=value&other=value

response on success




on failed insert operation

  • update
 GET  data?action=delete
 POST id=123&some=value&other=value

response - 'true'/'false'

Back to top