Remove_field("birthday") causes exception!

Hello, Team support!

I have simple Java connector and simple form with few field. The form validate and insert record
to DB.
In my DB schema (postgres) there is table with field (“birthday” - type timestamp ).
This field has not attribute “NOT NULL”, so if user don’t want to setup date I have to set NULL value to that field.
Java connector, in standard mode, setting up empty value = “”, but postgres wants NULL value.

I tried to use remove_field() method, but I get exception.

Code of my Java Connector

public class Form_connector extends ConnectorServlet {
	
	class FormBehavior extends ConnectorBehavior{
	    @Override 
	    public void beforeProcessing(DataAction action) {
	    	String status = action.get_status();
			if (status.equals("inserted") || status.equals("updated")) {
				if (action.get_value("birthday").equals("")) {
					//action.set_value("birthday", null); // does't set NULL value in SQL statement 
					action.remove_field("birthday"); // Trying to remove field 
				}
			}
			super.beforeProcessing(action);
	    }
	}
	
	@Override
	protected void configure() {
		Connection conn= ( new DataBaseConnection()).getConnection();
		FormConnector fc = new FormConnector(conn, DBType.PostgreSQL);
		// fc.enable_log("C:\\Temp\\formconnector.log", true);
		
		fc.event.attach(new FormBehavior());
		fc.render_table("customer", "customer_id", "firstname, lastname, middlename, phonenumber, email, birthday");
	}
}

Exception

SEVERE: Servlet.service() for servlet [form_connector] in context with path [/SpringMVC] threw exception
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(ArrayList.java:604)
	at java.util.ArrayList.get(ArrayList.java:382)
	at com.dhtmlx.connector.DataAction.sync_config(DataAction.java:98)
	at com.dhtmlx.connector.DataProcessor.check_exts(DataProcessor.java:270)
	at com.dhtmlx.connector.DataProcessor.inner_process(DataProcessor.java:222)
	at com.dhtmlx.connector.DataProcessor.process(DataProcessor.java:127)
	at com.dhtmlx.connector.BaseConnector.render(BaseConnector.java:411)
	at com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:242)
	at com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:210)
	at kz.sample.myapp.Form_connector.configure(Form_connector.java:49)
	at com.dhtmlx.connector.ConnectorServlet.doGet(ConnectorServlet.java:29)
	at com.dhtmlx.connector.ConnectorServlet.doPost(ConnectorServlet.java:39)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.traceNextValve(HttpRequestOperationCollectionValve.java:116)
	at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:98)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)

Please help!

Hello again!

It seems that there is a bug in the follow method

package com.dhtmlx.connector;
public class DataAction{
/..../
	public void sync_config(DataConfig config) throws ConnectorConfigException{
		for (int i=0; i<addf.size(); i++)
			config.add_field(addf.get(i));
		for (int i=0; i<delf.size(); i++)
			config.remove_field(addf.get(i)); // should be config.remove_field(delf.get(i)); 
	}
/..../
}

This is just my version of the possible occurrence of exception.

Best regards,
SeitArt

Hello again!
Sorry for persistence!
But I figure out how to bypass error.

public class Form_connector extends ConnectorServlet {
	class FormBehavior extends ConnectorBehavior{
		
	    @Override 
	    public void beforeProcessing(DataAction action) {
	    	
	    	super.beforeProcessing(action);
	    	String status = action.get_status();
			if (status.equals("inserted") || status.equals("updated")) {
				
				if (action.get_value("birthday").equals("")) {
					action.add_field("birthday", "");
					action.remove_field("birthday"); // Trying to remove field
				} else {
					String birthday = action.get_value("birthday");
					action.add_field("birthday", birthday);
				}
			}
	    }
	}
	
	@Override
	protected void configure() {
		Connection conn= ( new DataBaseConnection()).getConnection();
		
		FormConnector fc = new FormConnector(conn, DBType.PostgreSQL);
		
		fc.event.attach(new FormBehavior());
		fc.render_table("customer", "customer_id", "firstname, lastname, middlename, phonenumber, email");
	}
}

Main idea is follow:
1.Remove field “birthday” from render_table().
2.In method beforeProcessing()
2.1 if user entering real date value than we add field “birthday” for storing record to DB
2.2 if no value from user than we add and remove field “birthday”, that trick allow us to avoid error in connect lib.

Best regards,
SeitArt
we add field “birthday” in case real date value from user, and

Hi,
yes, you’re right, it’s a bug.
It’s fixed and will be included in official release.
Thanks!

Hello, radyno!

Thank you for answer!
How long wait this release?

Thank you!

Latest package, with all fixes, can be taken here -
github.com/DHTMLX/connector-php

Hello, Stanislav!

Thank you for information!
This link regards to php version of connector.
What about java version?

Best regards,
SeitArt

Latest jar file is attached.
connector_jar.zip (259 KB)

Many, many thanx, Stanislav!!!

Little question - what is the version of this connector ?

This is version 1.5 with all latest fixes

Thank you, I have connector 1.5_std_12913 from you.