Can't load dynamically the y_unit variable through Connector


I started using dhtmlx few days ago and I am facing a problem in loading dynamically the y_unit variable through the Java connector.

I have tried it in three different ways (flagged in the following code) but none of them worked.

Here is what I have on the Java part:

[code]protected void configure(HttpServletRequest request, HttpServletResponse response) {
Connection conn;;
try {
ArrayList dataCombo = new ArrayList();
ArrayList hashCombo = new ArrayList();
ArrayList data = new ArrayList();
SimpleDateFormat dhtmlxEventFmt = new SimpleDateFormat(“yyyy-MM-dd HH:mm”);

		conn = DriverManager.getConnection("hostname", "login", "pswd");

		// Generate sections
		OptionsConnector optConn = new OptionsConnector(conn);
		Statement stmtCombo = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
		ResultSet rs = stmtCombo.executeQuery("SELECT DISTINCT Z2AUFPL, Z2TEXT FROM CASAP.CAIMPORT order by Z2AUFPL asc");
		while ( {
			HashMap<String, String> hashString = new HashMap<String, String>();
			dataCombo.add(new SectionsCombo(rs.getString("Z2AUFPL"), rs.getString("Z2TEXT")));
			hashString.put("id", rs.getString("Z2AUFPL"));hashString.put("designation", rs.getString("Z2TEXT"));

//Method 1: optConn.render_array(dataCombo, “id”, “id(value),designation(label)”);
//Method 2: optConn.render_array(hashCombo, “id”, “id(value),designation(label)”);
//Method 3:
optConn.render_sql(“SELECT DISTINCT Z2AUFPL as value, Z2TEXT as label FROM CASAP.CAIMPORT order by Z2AUFPL asc”, “value”, “value,label”);

		// Génération de la lightbox
		Statement stmt = conn.createStatement();
		rs = stmt.executeQuery("SELECT * FROM CASAP.CAIMPORT");

		String start_date, end_date, text, section_id, color, data_id, template_tools, instruc_id;
		int id = 1;
		while ( {

			start_date = getStartDate(rs);
			end_date = getEndDate(rs);
			text = "Order "+id;
			section_id = getSection(rs);
			color = "green";
			data_id = getData(rs);
			template_tools = getTools();
			instruc_id = getInstructions();

			data.add(new SchedulerEvent(id, start_date, end_date, text, section_id, color, data_id, template_tools, instruc_id));


		SchedulerConnector c = new SchedulerConnector(null);
		c.servlet(request, response);
		c.set_options("section_id", optConn);
		c.render_array(data, "event_id","start_date,end_date,text,section_id,color,data_id,template_tools,instruc_id");
	} catch (SQLException e) {

And here is the configuration of the scheduler:

[code]var sections=scheduler.serverList(“section_id”);

				name:	"timeline",
				x_unit:	"day",
				x_date:	"%d-%M",
				x_step:	1,
				x_size: 21,
				x_start: 0,
				x_length:	21,
				y_unit:	sections,
				y_property:	"section_id",
				section_autoheight: false,
				dx:  100,    //La taille de la colonne contenant les ressources
				dy:  3,     //La hauteur ???
				event_dy:  "full",
					x_unit: "week", // the measuring unit of the axis (by default, 'minute')
					x_date: "%W" //the date format of the axis ("July 01")
			//Data loading
				{name:"description", height:23, map_to:"text", type:"textarea" , focus:true},
				{name:"custom", height:23, type:"select", options:sections, map_to:"section_id" },
				{name:"data", height:90, type:"template", map_to:"data_id"},
				{name:"time", height:72, type:"time", map_to:"auto"},
				{name:"tools", height:70, type:"template", map_to:"template_tools"},
				{name:"productioninst", height:72, type:"textarea", map_to:"instruc_id"}
				//,{name:"color", height:23, type:"textarea", map_to:"color"}
			scheduler.locale.labels.section_tools = "Outils";  //Define section name
			scheduler.init('scheduler_here',new Date(2013,5,30),"timeline");

Method 1 and method 2 doesn’t generate any error, but they do nothing on screen (even if my query returns one row).

Method 3 returns me this error:com.dhtmlx.connector.ConnectorOperationException: Invalid SQL: SELECT DISTINCT Z2AUFPL as value, Z2TEXT as label FROM CASAP.CAIMPORT ORDER BY Z2AUFPL ASC This method should only be called on ResultSet objects that are scrollable (type TYPE_SCROLL_INSENSITIVE). at com.dhtmlx.connector.DBDataWrapper.query( at at com.dhtmlx.connector.BaseConnector.get_resource( at com.dhtmlx.connector.OptionsConnector.render( at com.dhtmlx.connector.BaseConnector.fill_collections( at com.dhtmlx.connector.BaseConnector.xml_end( at com.dhtmlx.connector.BaseConnector.output_as_xml( at com.dhtmlx.connector.BaseConnector.render( at com.dhtmlx.connector.BaseConnector.render_array( at com.dhtmlx.connector.BaseConnector.render_array( at fr.authentic.scheduler.init.MySchedulerConnector.configure( at fr.authentic.scheduler.init.MySchedulerConnector.doGet( at javax.servlet.http.HttpServlet.service( at javax.servlet.http.HttpServlet.service( at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at org.apache.catalina.core.ApplicationFilterChain.doFilter( at org.apache.catalina.core.StandardWrapperValve.invoke( at org.apache.catalina.core.StandardContextValve.invoke( at org.apache.catalina.core.StandardHostValve.invoke( at org.apache.catalina.valves.ErrorReportValve.invoke( at org.apache.catalina.core.StandardEngineValve.invoke( at org.apache.catalina.connector.CoyoteAdapter.service( at org.apache.coyote.http11.Http11Processor.process( at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process( at$ at

I may have done something wrong, but I cannot figure it out. Could you help me?

you should use method 2 with several modifications:

  1. SectionsCombo must have 2 public fields:
public String value;
public String label;

It’s important that they are public and names are value/label.

  1. modify your code like here:
optConn.render_array(dataCombo, "id", "value,label");

After that collections must be loaded correctly.

Thanks for your anwer radyno.

I guessed you were talking about method 1 (as it the one using the class SectionsCombo), so I worked on it taking in account your advice :wink: . And there was some progress even if the result is still not ok.

Instead of having two sections with name ‘TOTO’ and ‘TITI’ (who said I lack of imagination? ^^), I have got two sections with name ‘{value=2,label=TOTO}’ and ‘{value=3,label=TITI}’.

If I replace “id” by “value” in the code you propose, I got the same result.

optConn.render_array(dataCombo, "value", "value,label");

I guess the object is wrongly formatted, but I got no idea what is wrong for the moment. Any idea?

My mistake. I forgot to set c.set_options parameters as they were when I first posted it. I got

c.set_options("section_id", hashCombo); which explains the wrong format of what was rendered.

Everything is ok now. Thanks for the precious help :slight_smile: .