Render-Error JavaConnector postgres dynamic_loading


#1

Hello everyone

would like to fill a grid with contacts (contact-manager)
Everything works fine. But if add dynamic_loading(true) to the serlvet it gets an error.

[code]

Contact Manager
<style>
    html, body {
        width: 100%;      /*provides the correct work of a full-screen layout*/ 
        height: 100%;     /*provides the correct work of a full-screen layout*/
        overflow: hidden; /*hides the default body's space*/
        margin: 0px;      /*hides the body's scrolls*/
    }
</style>
    dhtmlxEvent(window,"load",function(){
    
        var myDataStore = new dhtmlXDataStore({
            url:"http://127.0.0.1/dhtmlXServlet/JSONSrvlt",
            datatyp: "json"
            });
    
    
        var layout = new dhtmlXLayoutObject(document.body,"2U");
        var contactsGrid = layout.cells("a").attachGrid();
        layout.cells("a").setText("Contacts");
        contactsGrid.setHeader("Name,Last Name,Email");   //sets the headers of columns
        contactsGrid.setColumnIds("fname,lname,email");         //sets the columns' ids
        contactsGrid.setInitWidths("100,100,*");   //sets the initial widths of columns
        contactsGrid.setColAlign("left,left,left");     //sets the alignment of columns
        contactsGrid.setColTypes("ro,ro,ro");               //sets the types of columns
        contactsGrid.setColSorting("str,str,str");  //sets the sorting types of
        
        contactsGrid.enableSmartRendering(true,50);
        
        contactsGrid.init();
        contactsGrid.sync(myDataStore);

// contactsGrid.load(“http://127.0.0.1/dhtmlXServlet/JSONSrvlt”);
contactsGrid.attachHeader("#text_filter,#text_filter,#text_filter");

        layout.cells("b").setText("Contact Details");
        contactForm = layout.cells("b").attachForm();
        contactForm.loadStruct("data/form.xml");
        contactForm.bind(contactsGrid);
        
        var dpg = new dataProcessor("http://127.0.0.1/dhtmlXServlet/JSONSrvlt");         //inits dataProcessor
        dpg.init(myDataStore);   //associates the dataProcessor instance with the grid
        dpg.attachEvent("onAfterUpdate", function(sid, action, tid, tag){
        if (action == "inserted"){
            contactsGrid.selectRowById(tid);        //selects the newly-created row                          
            contactForm.setFocusOnFirstActive();//set focus to the 1st form's input                              
            }
        });
        
        
        contactForm.attachEvent("onButtonClick", function(name){
            contactForm.save();     //sends the values of the updated row to the server

// var selectedItem = contactsGrid.getSelectedRowId();
// contactsGrid.save(selectedItem);
// contactsGrid.setCursor(rowId);

        });
        layout.cells("b").setWidth(500);
        
        var menu = layout.attachMenu();
            menu.loadStruct("data/menu.xml");
            menu.setIconsPath("icons/");

        var toolbar = layout.attachToolbar();
            toolbar.setIconsPath("icons/");
            toolbar.loadStruct("data/toolbar.xml");
            toolbar.attachEvent("onclick",function(id){
                if(id=="newContact"){ //'newContact' is the id of the button in the toolbar

// var rowId=contactsGrid.uid(); //generates an unique id
// var pos = contactsGrid.getRowsNum(); //gets the number of rows in grid
// contactsGrid.addRow(rowId,[“New contact”,"",""],pos); //adds a new row
// contactsGrid.selectRowById(rowId);
// contactForm.setFocusOnFirstActive();
myDataStore.setCursor(myDataStore.add({fname:“neuer Kontakt”}));
};
if(id==“delContact”){
var rowId = contactsGrid.getSelectedRowId();
var rowIndex = contactsGrid.getRowIndex(rowId);
if(rowId!=null){
contactsGrid.deleteRow(rowId);
if(rowIndex!=(contactsGrid.getRowsNum()-1)){
contactsGrid.selectRow(rowIndex+1,true);
} else{
contactsGrid.selectRow(rowIndex-1,true);
};
};
};
});
});

</script>
[/code]

my JavaConnector servlet:

[code] protected void configure() {
Connection conn=null;

	try {
		Class.forName("org.postgresql.Driver").newInstance();
		conn = DriverManager.getConnection("jdbc:postgresql://localhost/test","postgres", "postgres");

// Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
// ResultSet rs = stmt.executeQuery(“SELECT id,title,author,price from dhtml.books”);

	} catch (Throwable e) {
		e.printStackTrace();
	}

	JSONCommonConnector c = new JSONCommonConnector(conn,DBType.PostgreSQL);
	c.dynamic_loading(true);
	//GridConnector c = new GridConnector(conn);
	c.render_table("dhtmlx.contacts", "contact_id", "fname,lname,phone_1,phone_2,email,homepage,skype");
	c.enable_log("C:\\temp\\dhtmlx.log", false);

}[/code]

On the client side is the grid wich work as expected. After scrolling the grid a new request starts to the servlet:

Request URL:http://127.0.0.1/dhtmlXServlet/JSONSrvlt?continue=true&start=50&count=50

and then getting the following error

java.io.IOException: Stream closed at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:45) at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:140) at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229) at com.dhtmlx.connector.LogManager.close(LogManager.java:114) at com.dhtmlx.connector.BaseConnector.end_run(BaseConnector.java:598) at com.dhtmlx.connector.JSONCommonConnector.output_as_xml(JSONCommonConnector.java:114) at com.dhtmlx.connector.JSONCommonConnector.output_as_xml(JSONCommonConnector.java:91) at com.dhtmlx.connector.BaseConnector.render(BaseConnector.java:427) at com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:242) at com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:210) at ch.fkl.dhtmlx.JSONSrvlt.configure(JSONSrvlt.java:33) at com.dhtmlx.connector.ConnectorServlet.doGet(ConnectorServlet.java:29)

What i am doing wrong?


#2

According to the log your problem is not related to the dhtmlxConnector itself.
Please, try to implement the thread-safe code initialization:
docs.dhtmlx.com/connector__java … ialization


#3

Does not work either…get the same error…

Have you got any other ideas?


#4

Please, try to check your server settings.
As the logging is broken according to your provided snippet.