Two Java connector doesn't work

When I outcomment the group or person part… it works.
Both together not. The person connector returns then nothing.

Person Connector:
@WebServlet(name = “PersonConnector”, urlPatterns = {“/Person/PersonConnector”})
public class PersonConnector extends ConnectorServlet {
@Override
protected void configure() {
Connection conn = ( new DataBaseConnection()).getConnection();
//Initialize connector
CommonConnector c = new CommonConnector(conn);
c.render_table(“person”, “P_Num”, “P_Title, P_FirstName, P_LastName”);
}
}

GroupConnector:
@WebServlet(name = “GroupConnector”, urlPatterns = {“/Group/GroupConnector”})
public class GroupConnector extends ConnectorServlet {
@Override
protected void configure() {
Connection conn = ( new DataBaseConnection()).getConnection();
//Initialize connector
CommonConnector c = new CommonConnector(conn);
c.render_table(“groups”, “G_Num”, “G_Name”);
}
}

HTML Code:

DHTMLX /*these styles allow dhtmlxLayout to work in fullscreen mode in different browsers correctly*/ html, body { width: 100%; height: 100%; margin: 0px; overflow: hidden; background-color:white; }
    <script type="text/javascript">

    dhtmlx.image_path = "codebase/imgs/";
    dhtmlxEvent(window,"load",function(){

        var main_layout = new dhtmlXLayoutObject(document.body, '2U');

        var left = main_layout.cells('a');
        left.setWidth('250');
        left.hideHeader();
        var accordion_1 = left.attachAccordion();

//Person
var PanelPerson = accordion_1.addItem(‘PanelPerson’,‘Person’);

        var GridPerson = PanelPerson.attachGrid();
        GridPerson.loadXML("inc/person/grid.xml"); 
        var lDataStorePerson = new dhtmlXDataStore();
        lDataStorePerson.load("Person/PersonConnector", "xml");
        
        var lDataProcessorPerson = new dataProcessor("Person/PersonConnector");
        lDataProcessorPerson.init(lDataStorePerson);

        GridPerson.sync(lDataStorePerson);

//Group
var PanelGroup = accordion_1.addItem(‘PanelGroup’,‘Group’);

        var GridGroup = PanelGroup.attachGrid();
        GridGroup.loadXML("inc/group/grid.xml"); 
        
        var lDataStoreGroup = new dhtmlXDataStore();
        lDataStoreGroup.load("Group/GroupConnector", "xml");
        
        var lDataProcessorGroup = new dataProcessor("Group/GroupConnector");
        lDataProcessorGroup.init(lDataStoreGroup);

        GridGroup.sync(lDataStoreGroup);
        
        PanelPerson.open();
        PanelGroup.close();

        var right = main_layout.cells('b');
        right.hideHeader();
        var toolbar_1 = right.attachToolbar();
        toolbar_1.setIconsPath('codebase/imgs/');

        //toolbar_1.loadXML('./data/toolbar.xml', function(){});
    });
    </script>

Your code loads data in both grids two times, as far as I can see - you are loading configuration and data separately, but the loading code is async, so there is no guarantee that datastore will load data after loading configuration in grid

I would recommend to change code as

var GridPerson = PanelPerson.attachGrid(); GridPerson.loadXML("inc/person/grid.xml", function(){ var lDataStorePerson = new dhtmlXDataStore(); lDataStorePerson.load("Person/PersonConnector", "xml"); GridPerson.sync(lDataStorePerson); });
in such case the datastores will load data and sync it to the grid only after grid configuration loading

I changed the code for both request (person and group). But it’s not better. One request is ok the other is empty. It seems that the response from one request terminates both.
What do you need to reproduce my problem?

Which java server you are using?

Maybe it configured to drop previous request when new one accepted?

Also, try to change syntax as

public class PersonConnector extends ThreadSafeConnectorServlet{ //changed protected void configure(HttpServletRequest req, HttpServletResponse res) { Connection conn = ( new DataBaseConnection()).getConnection(); CommonConnector c = new CommonConnector(conn); c.servlet(req, res); //added c.render_table("person", "P_Num", "P_Title, P_FirstName, P_LastName"); }

and similar to second connector, it will make code thread-safe

It works great. Thanks

Next steps/questions: :frowning: (Sorry)

  • How can I select the first items in both grids?
  • I want reload the grids if the Accord item becomes activ! Finally a have a form binded to the Grid. The Form has a select item which is related with a SelectOptionConnector (xml see below) Question: How can I reload the whole data (Grid, Form and first select items…) and in which order?

Person Form.XML

<?xml version="1.0" encoding="UTF-8"?>
  • How can I select the first items in both grids?

lDataStorePerson.load("Person/PersonConnector", "xml", function(){ //loading callback GridPerson.selectRow(0); });

To reload grid just reload datastores

datastore.cleaAll(); datastore.load(url); 

Ok make sense.
I will ask the Form question in the firm topic.
Thanks