Hi,
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 (rs.next()) {
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"));
hashCombo.add(hashString);
}
rs.close();
//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 (rs.next()) {
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));
id++;
}
rs.close();
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) {
e.printStackTrace();
}
}[/code]
And here is the configuration of the scheduler:
[code]var sections=scheduler.serverList(“section_id”);
scheduler.createTimelineView({
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",
render:"bar",
section_autoheight: false,
dx: 100, //La taille de la colonne contenant les ressources
dy: 3, //La hauteur ???
event_dy: "full",
second_scale:{
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
//===============
scheduler.config.lightbox.sections=[
{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");
scheduler.load("scheduler_connector1.do");[/code]
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(DBDataWrapper.java:374)
at com.dhtmlx.connector.DBDataWrapper.select(DBDataWrapper.java:214)
at com.dhtmlx.connector.BaseConnector.get_resource(BaseConnector.java:447)
at com.dhtmlx.connector.OptionsConnector.render(OptionsConnector.java:57)
at com.dhtmlx.connector.BaseConnector.fill_collections(BaseConnector.java:706)
at com.dhtmlx.connector.BaseConnector.xml_end(BaseConnector.java:693)
at com.dhtmlx.connector.BaseConnector.output_as_xml(BaseConnector.java:582)
at com.dhtmlx.connector.BaseConnector.render(BaseConnector.java:427)
at com.dhtmlx.connector.BaseConnector.render_array(BaseConnector.java:394)
at com.dhtmlx.connector.BaseConnector.render_array(BaseConnector.java:367)
at fr.authentic.scheduler.init.MySchedulerConnector.configure(MySchedulerConnector.java:101)
at fr.authentic.scheduler.init.MySchedulerConnector.doGet(MySchedulerConnector.java:36)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
I may have done something wrong, but I cannot figure it out. Could you help me?