Announcement

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

    Unable to fetchdata using RestDataSource

    1) Entry Point is as follows:
    Code:
    		RestDataSource jDs = new RestDataSource();
    		jDs.setDataFormat(DSDataFormat.XML);
    		jDs.setDataURL("/VOIPA/search?action=query&product=icp&queryname=confirmcount&format=xml&count=10");
    		jDs.setRecordXPath("/response/data/record");
    		
    		OperationBinding fetch = new OperationBinding();
            fetch.setOperationType(DSOperationType.FETCH);
            fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
              
            jDs.setOperationBindings(fetch);
    		DataSourceField summary = new DataSourceField("MESSAGETYPE", FieldType.TEXT);
    		
    		DataSourceField title = new DataSourceField("REQUESTNUMBER", FieldType.TEXT);  
    		jDs.addField(summary);
    		jDs.addField(title);
    		
    		final SearchForm form = new SearchForm();  
    		form.setTop(50);  
    		form.setNumCols(3);  
    		TextItem query = new TextItem();  
    		query.setName("count");  
    		query.setTitle("Query");  
    		query.setDefaultValue("10"); 
    
    		final ListGrid myGrid1 = new ListGrid();
    
    		myGrid1.setWidth("100%");  
    		myGrid1.setHeight(100);
    		myGrid1.setWrapCells(true);  
    		myGrid1.setFixedRecordHeights(false);  
    		myGrid1.setShowAllRecords(true);  
    		myGrid1.setAlternateRecordStyles(true);  
    		myGrid1.setDataSource(jDs);
    		
    
    		 ButtonItem button = new ButtonItem();  
    		         button.setTitle("Search");  
    		         button.setStartRow(false);  
    		         button.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {  
    		             public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {  
    		            	 myGrid1.fetchData(form.getValuesAsCriteria());  
    		             }  
    		         });  
    		   
    		         form.setItems(query, button);  
    
    		
    
    		VLayout layout = new VLayout(15);  
    		layout.addMember(myGrid1);  
    		layout.addMember(form);  
    
    		layout.draw();
    2) Response Format: Servlet returns response in application/xml format in following format.
    Code:
    <response>
     <status>0</status>
     <startRow>0</startRow>
     <endRow>15</endRow>
     <totalRows>15</totalRows>
      <data>
       <record>
       <MESSAGETYPE>MultiPortResponse</MESSAGETYPE>
       <REQUESTNUMBER>6017008336100040</REQUESTNUMBER>
       </record>
    
       <record>
       <MESSAGETYPE>StoreStatus</MESSAGETYPE>
       <REQUESTNUMBER>6017008336100040</REQUESTNUMBER>
       </record>
     </data>
    </response>
    3) although this code works with smart client grid. Which is as follows:
    Code:
    isc.DataSource.create
    	({
    		dataURL:"http://impetus-861:9696/VOIPA/search?action=query&product=icp&queryname=confirmcount&format=xml",
    		dataFormat: "xml",
    		recordXPath:"/response/data/record",
    		fields:
    		{
    			REQUESTNUMBER:{title:"REQUESTNUMBER", name:"REQUESTNUMBER", required:true, type:"text"},
    			MESSAGETYPE:{title:"MESSAGETYPE", name:"MESSAGETYPE", required:true, type:"text"}
    		},
    		ID:"test"
    	});
    
    
    	isc.ListGrid.create
    	({
    		ID: "submittedOrders",
    		top:10,left:20,
    		width:920, height:130, 
    		alternateRecordStyles:true, 
    		showAllRecords:true,
    		showRollOver : true,
    		showHover : true,
    		editEvent: "click",
    		dataSource: test,
    		fields:
    		[
    			{name:"REQUESTNUMBER", title:"REQUESTNUMBER",  canEdit:false, width: 110, align: "center",recordClick:"getOrderDetail(record)"},
    			{name:"MESSAGETYPE", title:"MESSAGETYPE",  canEdit:false, width: 125 , align: "center"}
    		],
    		autoFetchData: true,
    		canReorderFields: true,
    			getCellCSSText: function (record, rowNum, colNum)
    			{
    
    				if (colNum == 0)
    				{
    					return "font-weight:bold; color:blue; text-decoration: underline;";
    				}
    				
    			}
    
    	})
    Last edited by ajjain; 19 Feb 2009, 09:42.

    #2
    Sorry to interrupt you all.. But following code changes resolved my problem.
    But I could not come to a conclusion for the absolute reason.
    Code:
    		RestDataSource jDs = new RestDataSource();
    		jDs.setDataFormat(DSDataFormat.XML);
    		jDs.setDataURL("/VOIPA/search?action=query&product=icp&queryname=confirmcount&format=xml&count=10");
    
    		OperationBinding fetch = new OperationBinding();
    		fetch.setOperationType(DSOperationType.FETCH);
    		fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
    
    		jDs.setOperationBindings(fetch);
    
    		DataSourceTextField reqNo = new DataSourceTextField("REQUESTNUMBER", "REQUESTNUMBER");  
    		DataSourceTextField msgType = new DataSourceTextField("MESSAGETYPE", "MESSAGETYPE");  
    
    		jDs.setFields(reqNo, msgType);
    
    		final ListGrid orderGrid = new ListGrid();  
    		orderGrid.setWidth(500);  
    		orderGrid.setHeight(224);  
    		orderGrid.setAlternateRecordStyles(true);  
    		orderGrid.setDataSource(jDs);  
    		orderGrid.setEmptyCellValue("--");
    
    
    		final IButton updateButton = new IButton("load");  
    		updateButton.setWidth(150);  
    		updateButton.addClickHandler(new ClickHandler() {  
    			public void onClick(ClickEvent event) {  
    				orderGrid.fetchData();
    			}  
    		});  
    		
    		VLayout layout = new VLayout(15);  
    		layout.addMember(orderGrid);  
    		layout.addMember(updateButton);
    		layout.draw();

    Comment


      #3
      did you track what change caused it to work?

      Comment

      Working...
      X