Urgent Help : dhtmlxScheduler Integration in Website

Dear All,

We would like to use dhtmkxScheduler in our website page.

we are using struts 1.2 with jquery . we would like to include this dhtmlxscheduler in one of the jsp pages named calendar.jsp and would like to include this jsp page in the centre of main.jsp page using tiles. We have some queries and doubts and we would be very hapy to have all of you forum members to assist us in solving them.

1) Since the calendar.jsp page is an included jsp page in main.jsp page where in html and body tags are in main.jsp and calendar.jsp page has only possibility of having div tags. As a result of this we are unable to use and we saw that without placeing the init() in the body on load =“init()” the calander was not created. is there a way to solve this? is it possible to have init() to be launched without have having the body tag?

2) we are using struts1.2 application and we would like to have the events be loaded in the calande by means of struts action . I saw three methods xml, json and java connector .

              [b]a) [/b] the java connector method can it be used in struts action? if yes how? i
                             saw that server side was a servlet extending another class.In this situation
                             how can i implement this servlet using struts action?

              [b]  b)[/b] which amongst the 3 methods above is a better way for dynamic data
                             uploading? we are using the month view and we actually want that the
                             events be uploaded when we press the  button for next or previous
                              button. Is it possible to implement such dynamic uploading of data using
                              previous of next month button?

               [b]  c)[/b] In the doumentation we saw using java connector but we didnt
                              understand if it allows dynamic uploading of events from database or it
                               uploads all events at once?  

4)i saw in the java connector source code following things :-

in the html page a scheduleor load like scheduler.load(“events_rec.do?uid=”+scheduler.uid());
in the servlet side we saw these lines

	Connection conn= ( new DataBaseConnection()).getConnection();
	
	SchedulerConnector c = new SchedulerConnector(conn);
	c.event.attach(new Scheduler_RecBehavior(c));
	   c.render_table("events_rec","event_id","start_date,end_date,text,rec_type,event_pid,event_length","","");

           c.render_table will read the data from table events_rec and will automatically populate the scheduler with events or some more steps are needed?

Trisha
Rome, ITALY

As a result of this we are unable to use
Normally calling init code after placing scheduler’s html on the page must be enough. Also you can use

dhtmlxEvent(window, "load", function(){ ... code to init scheduler here ... })

  1. we are using struts1.2 application
    the events be loaded in the calande
    You can form xml, json or ical data stream by java code. Scheduler require data in one of such formats, it doesn’t matter is it static or generated by some servlet.

is a better way for dynamic data uploading?
It will work for any format ( assuming that you have some dyn. script which send back data in any of supported formats )

if it allows dynamic uploading of events from database
Connector supports dynamical loading.

4)i saw in the java connector source code following things :-
or some more steps are needed?
That is all, you need to point load command on client side to the URL of servlet and provide valid db configuration - all other will be done automatically.

Thankyou very much stanislav for your assistance !

The event you wrote worked very well and without body on load i am able to load the calendar.

I have another problem:

I would like to upload the events for every month i.e if i click on the previous and next button of month i should be able to upload events only of the month currently in view. How can i capture this event for previous and next button?

I would like to call a struts action on pressing this previous or next button for month and would like the calender be uploaded with events without refreshing the page? We decided to use the xml method for data upload instead of connector where in the xml page will be uploaded with all events of current month on every click and eventually upload the calender with the events in the xml.

If you could assist with the event capuring problem and the call to struts action and eventually how to dynamically upload the page using xml.

Do we have some source code implementation using struts and xml upload which i can use as refrerence?

Many thanks once again

I would like to upload the events for every month
You can use

  scheduler.setLoadMode("month");

which will enable dyn. loading - each time when month changed - call to server side url will be executed , with from and to parameters.

If you want more direct control over buttons

scheduler._click.dhx_cal_prev_button:function(){ //add code to load prev month here scheduler._click.dhx_cal_next_button(0,-1); } scheduler._click.dhx_cal_next_button:function(dummy,step){ //add code to load next month here scheduler.setCurrentView(scheduler.date.add( //next line changes scheduler._date , but seems it has not side-effects scheduler.date[scheduler._mode+"_start"](scheduler._date),(step||1),scheduler._mode)); }

Do we have some source code implementation using struts and xml upload which i can use as refrerence?
Unfortunately there is no such sample. Scheduler is fully client side, it only takes raw xml data from server - so server side code need not do anything special.

Hi Stanislav,

i was trying to implement the server side integration using struts1.2

  1. I created a struts action which redirects to a jsp page called events.jsp page.

  2. In the events.jsp page i have written a couple of events which i copied actually from the events.xml file.

  3. In the Calendar.jsp page which is the page where in we have specified the javascript for loading calendar. I have also included the following command for laoding the xml data present in the jsp page in this way

scheduler.load("<%=request.getContextPath()+"/"+“loadCalendar.do”%>"); which finally becomes
scheduler.load(“testDemo/loadCalendar.do”);

loadCalender.do is the action taking us to the events.jsp page.

My problem is that i am unable to load the events in my calender in this way. Is it correct the method which i have used by calling an action in schedulor.load() which ridirects to a jsp page containing content in xml format in order to load calender?

what is the mistake? am i missing something else?

events. jsp page is like this

Many Thanks in advance

Trisha

Your solution looks correct.
Be sure that data will be returned with

Content-type: text/xml

Also, in case of FF , it may be important , that there is no any extra output before xml start.

If its still silently dies, check that you have on the page

scheduler.config.xml_date="%Y-%m-%d %H:%i";

Hi Stanislav,

Thanks again!

It works well when i changed Content-type to text/xml.

I was trying to implement the previous and next button clicks to call another servlet actions. however it didnt work well.

I have following doubts :

  1. How should i retrieve the next or previous month values on next or previous button clicks? In this way i can call actions and query database to for uploading events of the required month only.

  2. The events code you gave me i have put them in a separate java script tag separate from the java script tag (dhtmlxEvent(window, “load”, function(){… )which initialises the calendar as the initialisisation was failing keeping them together.

the click code is like this

  1. where should i place this script? should it be somewhere near div tags of previous and next button?

  2. We would like to have have three different types of events and each type be displayed by 3 different colours. How can i intelligently do with scheduler? can i change colour from default yellow to a few more coulours based on events? Can i add one more field in xml file in order to distinguish between the events and to change the colour?

Thankyou very much in advance. If we are able to implement this we can succefully be able to acchieve our requirements using dhtmlxScheduler

Trisha

Hi Stanislav,

I am updating my previous msg which i wrote an hour ago.

The clicks on next and previous buttons work well. actually i had put : instead of = before function()

However there is a little problem. the next button works very well but the previous button does not works very well .i.e. it uploads the previous month only sometimes, quite strange but only some of the previous button clicks fills the calendar and not every time previous button click uploads the events.Is it a bug or some error of mine?

My other querries are the follwoing :

  1. How should i retrieve the next or previous month values on next or previous button clicks? In this way i can call actions and query database to for uploading events of the required month only.

  2. We would like to have have three different types of events and each type be displayed by 3 different colours. How can i intelligently do with scheduler? can i change colour from default yellow to a few more coulours based on events? Can i add one more field in xml file in order to distinguish between the events and to change the colour?

Thankyou very much in advance. If we are able to implement this we can succefully be able to acchieve our requirements using dhtmlxScheduler

We would like to have have three different types of events and each type be displayed by 3 different colours.

You can use scheduler.templates.event_class to attach custom css classes to events
samples\02_customization\01_events_coloring.html

Can i add one more field in xml file in order to distinguish between the events and to change the colour?
Yep, you can add any number of custom tags, any subtag of “” will be converted to property of event, and accessible as

scheduler.getEvent(id).my_property_name

However there is a little problem. the next button works very well but the previous button

Try to change code as

scheduler._click.dhx_cal_next_button = function(dummy,step){ if (step !=-1 ) scheduler.load("<%=request.getContextPath()+"/"+"loadCalendarNextMonth.do"%>");

How should i retrieve the next or previous month values
You can use scheduler._date inside click handlers to get the current date ( knowing which it must be not a problem to get prev or next month value )

Hi Stanislav,

Thanks for your reply again.

However i still couldn’t find out how should i retrieve the month value on pressing next or previous button. actually i would like the events be loaded dynamically by the struts action which will perform database query based on the month requested.

At this month i also wanna know if after querrying the databse i need to create an xml file for loading data or i need to return data from the action servlet in the xml format which will be automatically read by the calendar?

how should i proceed?

if you remember i had specified as

scheduler.load("<%=request.getContextPath()+"/"+“loadCalendar.do”%>"); which means on every next or previous button pressing or current page condition i need to pass month value to the action loadCalendar.do and return value should be some data in Xml format as i wrote in the jsp file?

Check the attached sample
1280745537.zip (47.9 KB)

Hi trisha!

I hope you can read this. It so happen we have the same framework (Struts) in working with dhtmlxscheduler. I would like to ask how did you come up to form in this:

"4)i saw in the java connector source code following things :-

in the html page a scheduleor load like scheduler.load(“events_rec.do?uid=”+scheduler.uid());
in the servlet side we saw these lines

Connection conn= ( new DataBaseConnection()).getConnection();

SchedulerConnector c = new SchedulerConnector(conn);
c.event.attach(new Scheduler_RecBehavior©);
c.render_table(“events_rec”,“event_id”,“start_date,end_date,text,rec_type,event_pid,event_length”,"","");
"

Can we put this part on action in Struts framework? I have the database drivermanager/data sources set in my spring-ibatis for database connection but it so happen that I can’t figure out on this SchedulerConnector be integrated it with struts.

thanks! i hope you could help me enlighten on this.

Greetings!

anyone can help me here? :frowning: