Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem with calendar

    I'm currently using SmartClient_SC_SNAPSHOT-2010-12-27 but have also tried this with SmartClient_70rc2_LGPL. My problem is with a data source that communicates with a server in XML to store and retrieve dates for a Calendar. I can add the initial date and it posts to the server and retrieves and displays it again without any issues. When I add the second calendar entry, the blue box that represents the calendar event shows in the upper left of the calendar with "Untitled Window". If I refresh the page, both entries are retrieved from the server and it shows up ok. I don't see any errors in firebugs error console or in the SmartClient developer console.

    This is my datasource and calendar:
    Code:
    isc.DataSource.create({ 
    	ID: "customerCalendarDS",
    	recordXPath:"//com.dsailer.domain.calendar.Event", 
    	tagName:"com.dsailer.domain.calendar.Event",
    	fields:[
    	        {name:"id", primaryKey: true, type: "sequence"},
    	        {name:"name"},
    	        {name:"description"},
    	        {name:"startDate", type: "datetime", valueXPath: "timeInterval/start"},
    	        {name:"endDate", type: "datetime", valueXPath: "timeInterval/end"}
    	],
    	operationBindings:[
    		{operationType:"fetch", dataProtocol: "getParams", dataURL:"events"},
    		{operationType:"add", dataProtocol: "postXML", dataURL:"events"},
    		{operationType:"update", dataProtocol: "postXML", dataURL:"events", requestProperties:{httpMethod:"PUT"}},
    		{operationType:"remove", dataProtocol: "postParams", dataURL:"events", requestProperties:{httpMethod:"DELETE"}}
    	],
    	transformRequest : function (dsRequest) {
        	
        	var data = this.Super('transformRequest', arguments);
        	//What the server wants for an "interval" is something like:
        	//   <timeInterval>
        	//       <start>xxxx</start>
        	//       <end>xxxx</end>
        	//   </timeInterval>
            if (dsRequest.operationType == "add" || dsRequest.operationType == "update") {
            	//save our dates
            	var startStr = data["startDate"].toXStreamString();
            	var endStr = data["endDate"].toXStreamString();
            	
            	//delete them from the data
            	delete data.startDate;
            	delete data.endDate;
            	
            	//add back the format we want
            	data.timeInterval =  {};
            	data.timeInterval.start = startStr;
            	data.timeInterval.end = endStr;
            } 
            else if(dsRequest.operationType == "remove"){
            	//instead of passing an id=2 param just pass /2
            	
            	//NOT WORKING...
            	dsRequest.actionURL = data["id"];
        	}
        	
            return data;
        }
    });
    
    isc.Calendar.create({
        ID: "customerCalendar", 
        width : "50%",
        showResizeBar: "true",
        minWidth: "400",
        dataSource: customerCalendarDS, 
        autoFetchData: true,
        dateChanged : function () {
        	customerCalendarDS.fetchData({startDate:this.chosenDate});
        }
    });

    any ideas what the problem could be?

    #2
    so I decided I should read the docs instead of just skim them :)

    My server was orginally JSP, then converted to REST so the "create" was redirecting to return the list of items again. I changed it to be ajax/SmartClient friendly and return the created item and it's working great.

    Comment


      #3
      Haaa! The docs are your friend! But so are the forums... your posted code helped me to realize that SC doesn't automatically add a valueXPath value just because you set the startDateField and endDateField. So, thanks for sharing your code!!

      Comment

      Working...
      X