Announcement

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

    Calendar RestDataSource XML

    I access to DataSource data, but the CalendarEvent is not visible :

    Code:
    public class MyTest implements EntryPoint {
    
    	  public void onModuleLoad() {
    
    	        OperationBinding fetch = new OperationBinding();
    	        fetch.setOperationType(DSOperationType.FETCH);
    	        fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
    	        fetch.setDataURL(GWT.getModuleBaseURL()+"calendar.xml");
    
    	        RestDataSource restEventDS = new RestDataSource() {
    	        	
    //	        	@Override
    				protected Object transformRequest(DSRequest dsRequest) {
    
    					System.out.println(dsRequest.getData());
    					return super.transformRequest(dsRequest);
    				}
    	        	
    //	        	@Override
    	        	protected void transformResponse(DSResponse response,
    	        			DSRequest request, Object data) {
    	        	
    	        		super.transformResponse(response, request, data);
    	        		
    	        		System.out.println("getStatus:"+response.getStatus());
    	        		ListGridRecord lgr[] = response.getData();
    	        		for(int i=0; i<lgr.length; i++) {
    	        			System.out.println(
    	        					"i:"+i+
    	        					" name:"+lgr[i].getAttribute("name")+
    	        					" description:"+lgr[i].getAttribute("description")+
    	        					" startDate:"+lgr[i].getAttribute("startDate")+
    	        					" endDate:"+lgr[i].getAttribute("endDate")+
    	        					""
    	        					);
    	        		}
    	        		
    	        	}
    	        };
    	        restEventDS.setDataFormat(DSDataFormat.XML);
    	        restEventDS.setOperationBindings(fetch);
    
    	        DataSourceSequenceField eventIdField = new DataSourceSequenceField("eventId");  
    	        eventIdField.setPrimaryKey(true);
    	        DataSourceTextField nameField = new DataSourceTextField("name");  
    	        DataSourceTextField descField = new DataSourceTextField("description");  
    	        DataSourceDateField startDateField = new DataSourceDateField("startDate");  
    	        DataSourceDateField endDateField = new DataSourceDateField("endDate");  
    	  
    	        restEventDS.setFields(eventIdField, nameField, descField, startDateField, endDateField);
    	  
    	        Calendar calendar = new Calendar();
    
    	        calendar.setDescriptionField("description");
    	        calendar.setEndDateField("endDate");
    	        calendar.setNameField("name");
    	        calendar.setStartDateField("startDate");	
    
    	        calendar.setDataSource(restEventDS); 
    
    	        calendar.getDataSource().fetchData();
    	        
    	        calendar.draw();
    
    }
    The result is :
    getStatus:0
    i:0 name:Le Nom description:La Desc startDate:Wed Jan 21 07:36:42 CET 2009 endDate:Wed Jan 21 17:29:49 CET 2009


    With calendar.xml :
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <response>
    	<status>0</status>
    	<startRow>0</startRow>
    	<endRow>1</endRow>
    	<totalRows>1</totalRows>
    	<data>
    		<record>		
    			<eventId>674555</eventId>
    			<startDate>Wed Jan 21 07:36:42 CET 2009</startDate>
    			<endDate>Wed Jan 21 17:29:49 CET 2009</endDate>
    			<name>Le Nom</name>
    			<description>La Desc</description>
    		</record>
    	</data>
    </response>
    If i set setAutoFetchData to true, the window message leave and say : "Contacting server..."

    If in the transformResponse() i use getAttributeAsDate instead getAttribute, i catch one exception : Uncaught JavaScript exception [com.google.gwt.core.client.JavaScriptException: (TypeError): Cet objet ne gère pas cette propriété ou cette méthode (object does not support this property or method)

    Where is my error to correctly fetch and display events of my Calendar using RestDataSource ?

    #2
    Calendar RestDataSource JSON

    I have another problem with Calendar.java r249 from SVN.

    Only if is error in dates, will appear the CalendarEvent only on Day View :

    I follow this post : http://forums.smartclient.com/showthread.php?t=3440 Using RestDataSource and JSON

    Code:
    {
    	response:  
    	{
    		status:0,
    	   	data:
    	   	[
    			{
    				eventId: 1,
    				name: "A Event",
    				description: "description A event",
    				startDate: new Date(2009,01,21,1,0,0),
    				endDate: new Date(2008,01,21,2,0,0)
    			},
    			{
    				eventId: 2,
    				name: "B Event",
    				description: "description B event",
    				startDate: new Date(2009,01,21,4,0,0),
    				endDate: new Date(2009,01,21,18,0,0)
    			}
    		]	
    	}
    }
    With this json data, i see only the bug date "A Event", (endDate before startDate)

    With Json, it seems to show the CalendarEvent, the STOP (year + month + day) MUST be previous than the START (year + month + day) and only time is correctly used.

    With XML, i need help....


    sjivan, have you an exemple of Calendar using RestDataSource XML or JSON to share ?
    Last edited by immobilia; 21 Jan 2009, 05:50.

    Comment


      #3
      For correct working, the good way is writing date with DateTimeSql format like "2009-01-21 03:00:00" :

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <response>
      	<status>0</status>
      	<startRow>0</startRow>
      	<endRow>1</endRow>
      	<totalRows>1</totalRows>
      	<data>
      		<record>			
      			<eventId>1</eventId>			
      			<startDate>2009-01-21 03:00:00</startDate>
      			<endDate>2009-01-21 05:00:00</endDate> 			
      			<name>Le Nom</name>
      			<description>La Desc</description>
      		</record>
      	</data>
      </response>

      Comment

      Working...
      X