I access to DataSource data, but the CalendarEvent is not visible :
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 :
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 ?
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(); }
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 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 ?
Comment