Announcement

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

    How to make a request synchronous

    Hi,

    Is there any way to make a request synchronous? I want to display different icons in a ListGridField based on a fetch result using cellFormater, the code is like this:
    Code:
    		fieldInfo.setCellFormatter(new CellFormatter() {
    			public String format(Object value, ListGridRecord record,
    					int rowNum, int colNum) {
    				infoImgUrl = Canvas.imgHTML("icons/statistics-icon_16x16.png");
    				String parentConsignment = record.getAttributeAsString("pk_consignment_id");
    				Criteria criteria = new Criteria("parent_consignment",parentConsignment);
    				dsConsignmentManifest.fetchData(criteria, new DSCallback() {
    					public void execute(DSResponse response, Object rawData, DSRequest request) {
    						if (response.getData().length > 0) {
    							infoImgUrl = Canvas.imgHTML("icons/status_palet_35x16.png");
    						}
    					}
    				});
    
    				return infoImgUrl;
    			}
    		});
    of course this doesn't work because the String has been returned before the fetch result comes back. Is there a better way to do this?

    #2
    Consider a different architecture. Making a network call for each cell format is just not feasible. No, you can't make the call synchronous.

    Best if you have your data for the grid include the image Url in another column and then format your desired column with the image.

    Comment


      #3
      Thanks david.

      i think your suggestion is right, i might have to use a LEFT JOIN to get data from the second table.
      Last edited by liudi; 23 Nov 2010, 21:39.

      Comment

      Working...
      X