Scheduler with java

Hi all,
i’m new in dhtmlx.
Someone can help me about a simple example of scheduler java with database oracle?

I have write my example, but it not work, when process scheduler.load("events.do?uid="+scheduler.uid()); i have this message view attach:

[code]

html, body{ margin:0px; padding:0px; height:100%; overflow:hidden; }
 
 
[/code]

You need to map the connector’s servlet to “events.do” web path

where i do? in web xml?

yep, there is a war package for java connector which can be used as a sample

Thanks for fast reply.
In the example how can i establish connection with mysql user db?

Hi!
I’m in the same situacion, maurifara.
I also had that problem but I solved it in web.xml
But now my problem is whit database MySQL. I can’t save any event’s information.
Do you know why?
If you can do it, could you show me how or show me “events.do” ?
This is my “myconnector.do”:

public class BasicConnector extends ThreadSafeConnectorServlet {
@Override
protected void configure(HttpServletRequest req, HttpServletResponse res) {
//obtain DB connection
Connection conn=null;
try {
Class.forName (“com.mysql.jdbc.Driver”).newInstance ();
conn = DriverManager.getConnection(“jdbc:mysql://localhost/database”, “root”, “password”);
} catch (Throwable e) {
e.printStackTrace();
}

            //Initialize connector
	SchedulerConnector c = new SchedulerConnector(conn, DBType.MySQL);
            c.servlet(req, res);

            //configure used table and fields
	c.render_table("events","event_id","start_date,end_date,event_name,details");
    }

}

I hope your help
Thanks
PD: Sorry if I’ve written something wrong but I’m not English

Can be caused by default date format.
Try to enable log
docs.dhtmlx.com/doku.php?id=dhtm … nd_logging
and run the sql query from it directly against DB

First, thanks.
I dont unsderstand at all but I put this line:
c.enable_log(“log.txt”, true);
I also think that can be caused by default date format.
I have this in the function init():
scheduler.config.xml_date="%Y-%m-%d %H:%i";

Then I’ve tried to add an event directly in the DB and it appears in the web even I refresh but If I try it add other new in the web, against the same… I refresh and only appears the first.

c.enable_log(“log.txt”, true);
File log.txt will be created with all sql code for each operations, so you will be able to check is format of data correct or not.

If new events do not appear after scheduler reloading, try to change loading command as

scheduler.load(“data?uid=”+(new Date()).valueOf());

It must resolve caching issue. ( where “data” - current data loading url )

Ok, I do somenthing wrong because my log file is always empty. I can’t see anything about the format.

I also put : scheduler.load(“myconnector.do?uid=”+(new Date()).valueOf()); but nothing…

This is my code(part of jsp):

<head>
<script src="codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
<script src="codebase/ext/dhtmlxscheduler_agenda_view.js" type="text/javascript" charset="utf-8"></script>
<script src="codebase/ext/dhtmlxscheduler_year_view.js" type="text/javascript" charset="utf-8"></script>
<script src="codebase/connector.js" type="text/javascript" charset="utf-8"></script>
<script src="codebase/locale_es.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="codebase/dhtmlxscheduler_glossy.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>


<style type="text/css" media="screen">
	html, body{
		margin:10px;
		padding:0px;
		height:100%;
                <%--overflow:hidden;--%>
	}
    /*event in day or week view*/
	.dhx_cal_event.past_event div{
		background-color:teal !important;
		color:white !important;
	}
    /*multi-day event in month view*/
	.dhx_cal_event_line.past_event{
		background-color:teal !important;
		color:white !important;
	}
    /*event with fixed time, in month view*/
	.dhx_cal_event_clear.past_event{
		color:teal !important;
	}
</style>
<script type="text/javascript" charset="utf-8">
	function init() {

                scheduler.config.xml_date="%Y-%m-%d %H:%i";
                scheduler.config.day_date="%D, %d %M";
		scheduler.config.lightbox.sections=[
                        {name:"name", height:20, map_to:"text", type:"textarea", focus:true},
			{name:"description", height:60, map_to:"desc", type:"textarea"},
			{name:"location", height:20, type:"textarea", map_to:"details"},
                        {name:"type", height:20, map_to:"type",type:"select", options:[
                                {key:1, label:"Nomal"},
                                {key:2, label: "Important"}
                            ]},
			{name:"time", height:20, type:"time", map_to:"auto"}
		]
                scheduler.config.start_on_monday = true;
		scheduler.config.first_hour=0;
		scheduler.locale.labels.section_location="Localizacion";
                scheduler.locale.labels.section_type="Prioridad";
                scheduler.locale.labels.section_name="Nombre"
		scheduler.config.update_render="true"
                scheduler.config.multi_day = true;
                scheduler.config.scroll_hour=24;
                scheduler.config.mark_now=true;
                scheduler.locale.labels.agenda_tab = "Agenda";
		scheduler.config.details_on_dblclick=true;

                scheduler.templates.event_class=function(start,end,event){
                    if (start < (new Date())) //if date in past
                        return "past_event"; //then set special css class for it
                }
                scheduler.templates.event_text=function(start,end,event){
                    return "Name:<b> "+event.text+"</b><br>"+"Descr.: "+event.desc;
                }
                
		scheduler.init('scheduler_here',null,"month");

		//scheduler.load("myconnector.do?uid="+scheduler.uid());
                scheduler.load("myconnector.do?uid="+(new Date()).valueOf());
		var dp=new dataProcessor("myconnector.do");
		dp.init(scheduler);
                
	}
</script>

and the connector is:

public class BasicConnector extends ConnectorServlet {

	@Override
	protected void configure() {
		Connection conn= ( new DataBaseConnection()).getConnection();

		SchedulerConnector c = new SchedulerConnector(conn);
                c.enable_log("log.txt", true);
		c.render_table("events","event_id","start_date,end_date,text");

	}

}

I dont understand what is happening.

Any help?
I’ve also proved coy-paste the war sample and doesnt work.

I haven’t resolved my problem yet.

My log.txt file have this:

DB query
SELECT event_id,start_date,end_date,details,event_name FROM events

Done in : 3ms

But it doesn’t save events.
Where is the problem?
How can I do the insert into?

Helpp pleaaseee!

Hi,
sorry for the delay in answerring.
Log file doesn’t contain information about trying to save data, is it?
Please, make sure that configure method is called (you may set breakpoint for example).
Does dataprocessor use correct url to send save request?

Hi radyno and thanks!

Yes, file log only has the select but doesn’t contain any information about an insert and any error either.
I think the configure method works because if I put other select with a condition, for example:

c.render_sql("SELECT * FROM events WHERE user_email=‘X’ ", “event_id”, “start_date,end_date,details,event_name,user_email”) , it works.

My configure method is this:

public class BasicConnector extends ConnectorServlet {

	@Override
	protected void configure() {
		Connection conn= ( new DataBaseConnection()).getConnection();
		SchedulerConnector c = new SchedulerConnector(conn,DBType.MySQL);
                c.enable_log("log.txt", true);
                c.render_table("events", "event_id", "start_date,end_date,details,event_name,user_email","","");
                
                //c.render_sql("SELECT * FROM events WHERE user_email='X' ", "event_id", "start_date,end_date,details,event_name,user_email");
            
       }
}

And the dataprocessor url…I also think is correct:

             scheduler.init('scheduler_here',null,"month");
	     scheduler.load("myconnector.do?uid="+scheduler.uid());
             var dp=new dataProcessor("myconnector.do");
	     dp.init(scheduler);

What can I do?
The programme is only loading events (the ones I added myself directly in the database) but they are not inserted, modified or updated in the scheduler calendar

Please, check your private messages.

Code looks fine.
Can you enable log and provide results for invalid data saving operations ?

docs.dhtmlx.com/doku.php?id=dhtm … nd_logging

You need not this one, dhtmlxscheduler.js already includes all necessary parts

Hi,

  1. Thanks against for the message, radyno.
  2. Stanislav, if I don’t put the connector.js, show me this when I try to save an event:

La pagina localhost:8080 dice:

Apache Tomcat/6.0.33 - Informe de Error

Estado HTTP 500 -


type Informe de Excepción

mensaje

descripción El servidor encontró un error interno () que hizo que no pudiera rellenar este requerimiento.

excepción

java.lang.NullPointerException
	com.dhtmlx.connector.MySQLDBDataWrapper.escape(MySQLDBDataWrapper.java:17)
	com.dhtmlx.connector.DBDataWrapper.insert_query(DBDataWrapper.java:151)
	com.dhtmlx.connector.DBDataWrapper.insert(DBDataWrapper.java:199)
	com.dhtmlx.connector.DataProcessor.check_exts(DataProcessor.java:251)
	com.dhtmlx.connector.DataProcessor.inner_process(DataProcessor.java:199)
	com.dhtmlx.connector.DataProcessor.process(DataProcessor.java:118)
	com.dhtmlx.connector.BaseConnector.render(BaseConnector.java:292)
	com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:210)
	MySQL.BasicConnector.configure(BasicConnector.java:22)
	com.dhtmlx.connector.ConnectorServlet.doGet(ConnectorServlet.java:28)
	com.dhtmlx.connector.ConnectorServlet.doPost(ConnectorServlet.java:35)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

nota La traza completa de la causa de este error se encuentra en los archivos de diario de Apache Tomcat/6.0.33.


Apache Tomcat/6.0.33

Hi,
does log-file contain record about trying to save data for now? Could you provide it?
Also, try to include js files in the follow order:
dhtmlxscheduler.js
dataprocessor.js
connector.js

Ok, whithout the connector.js the log-file contain this:

After try to save an event:

====================================
Log started, Thu Mar 15 22:56:30 CET 2012

DB query
SELECT event_id,start_date,end_date,details,event_name FROM events

Done in : 12ms

And when I refresh the web:

====================================
Log started, Thu Mar 15 22:56:44 CET 2012

====================================
Log started, Thu Mar 15 22:57:14 CET 2012

DB query
SELECT event_id,start_date,end_date,details,event_name FROM events

Done in : 29ms

And exactly the same if I put the dhtmlxscheduler.js, dhtlmxdataprocessor.js and connector.js in that order.