Very Urgent----- regarding dhtmlx Scheduler--------

I want to save&delete a new event .just say me which event method is correct .

For Save onEventAdded or onEventChanged

& For Delete onBeforeEventDelete or anything



My problem is Im saving and updating a new event by onEventChanged method & deleting the event by onBeforeEventDelete method.But when i want to save a new event i click the save button it is not saving in my database but after clicking detaiails and then click on save it is saving my record.



In case of delete a saved record is not deleted immediately when i press delete button. If i refresh the page then i see the event is deleted.So i want to clear that saved event immediately when i click on the delete button instead of refresing the page.

I am sending you the source code below…Plese help me immediate…pls …pls





My Jsp File

----------------



    

    



==============================================================================



This is my Java Class

--------------------------



public class SaveAppointmentData extends HttpServlet {

private static final String CONTENT_TYPE = “text/html; charset=windows-1252”;



DataSource ds = null;

public void init(ServletConfig config) throws ServletException {

try {



InitialContext ctx=new InitialContext();

ds=(DataSource)ctx.lookup(config.getInitParameter(“JNDIString”));

} catch (Exception exp) {

exp.printStackTrace();

}

}



public void doPost(HttpServletRequest request,

HttpServletResponse response) throws ServletException, IOException

{response.setContentType(CONTENT_TYPE);

Connection connnection = null;

Statement statement = null;

Statement st1 = null;

boolean cheeckUpdateCase=false;

String inSql="";

response.setContentType(CONTENT_TYPE);

response.setHeader(“Cache-Control”,“no-cache”);

PrintWriter out = response.getWriter();

String evId = request.getParameter(“eventId”);

String sDate = request.getParameter(“startDate”);

String eDate = request.getParameter(“endDate”);

String textNote = request.getParameter(“text”);

String functionStatus = request.getParameter(“status”);

String empId = request.getParameter(“empid”);

String detailsNote ="";

String statusNote =“A”;



System.out.println(“evId”+evId);

System.out.println(“sDate”+sDate);

System.out.println(“eDate”+eDate);

System.out.println(“Inside Ajax”+textNote);





// DateFormat df = new SimpleDateFormat(“dd-MMM-yyyy HH:mm:ss”);

// Date startDate=null;

// try {

// startDate = (Date)df.parse(sDate);

// } catch (ParseException e) {

// e.printStackTrace();

// }

// Date endDate=null;

// try {

// endDate = (Date)df.parse(eDate);

// } catch (ParseException e) {

// e.printStackTrace();

// }

try {

connnection = ds.getConnection();

st1= connnection.createStatement();

if(functionStatus.equalsIgnoreCase(“Save”)){

cheeckUpdateCase=updateCase( st1, evId);

if(cheeckUpdateCase==true){

inSql = “UPDATE EMP_APPOINTMENTS SET START_DATE=to_date(’”+sDate+"’,‘DD-MON-YYYY HH24:mi:ss’),END_DATE=to_date(’"+eDate+"’,‘DD-MON-YYYY HH24:mi:ss’),TEXT=’"+textNote+"’,DETAILS=’"+detailsNote+"’,STATUS=’"+statusNote+"’,EMP_ID=’"+empId+"’ WHERE EVENT_ID=’"+evId+"’";

}else{

inSql = “INSERT INTO EMP_APPOINTMENTS (EVENT_ID,START_DATE,END_DATE,TEXT,DETAILS,STATUS,EMP_ID) values (”+evId+",to_date(’"+sDate+"’,‘DD-MON-YYYY HH24:mi:ss’),to_date(’"+eDate+"’,‘DD-MON-YYYY HH24:mi:ss’),’"+textNote+"’,’"+detailsNote+"’,’"+statusNote+"’,’"+empId+"’)";

}

}

if(functionStatus.equalsIgnoreCase(“Delete”)){

inSql =“DELETE FROM EMP_APPOINTMENTS WHERE EVENT_ID=’”+evId+"’";

}

System.out.println(inSql);

statement= connnection.createStatement();

statement.execute(inSql);



} catch (SQLException sqe) {

sqe.printStackTrace();

} finally {

try {



if (statement != null) {

statement.close();

statement = null;

}

if (connnection != null) {

connnection.close();

connnection = null;

}

} catch (SQLException e) {

e.printStackTrace();

}

}



out = response.getWriter();

out.flush();

out.close();

}

public boolean updateCase(Statement st1,String eventId){

ResultSet rs=null;

boolean ret=false;

try {



rs=st1.executeQuery(“Select EVENT_ID from EMP_APPOINTMENTS where EVENT_ID=’”+eventId+"’");

while(rs.next()){

ret=true;

}

} catch (SQLException sqe) {

sqe.printStackTrace();

}

finally {

try {

if (rs != null) {

rs.close();

rs = null;

}



} catch (SQLException e) {

e.printStackTrace();

}

}

return ret;

}

}

In case of delete a saved record is not deleted immediately when i press delete button
add return true; to the end of onbeforeeventdelete event


scheduler.attachEvent(“onBeforeEventDelete”, function(event_id,event_object){
… any custom code …
return true;
});

>>but after clicking detaiails and then click on save it is saving my record.
OnEventChanged event occurs after event was edited ( by direct edit or by details form ) event doesn’t occurs if some property of event was changed directly through API