1

I am storing image in Google App Engine using Blob. When i add new data in CellList using ListDataProvider's add() method its getting render perfect.

Below is the extended version of AbstractCell:

@Override
public void render(com.google.gwt.cell.client.Cell.Context context,
        AppsBean value, SafeHtmlBuilder sb) {
    String url=GWT.getModuleBaseURL()+"fetchIcon?appId="+value.getId()+"&requestType=icon";
    sb.appendHtmlConstant("<Table>");
    sb.appendHtmlConstant("<tr><td rowspan='3'>");
    sb.appendHtmlConstant("<img src='"+url+"' style='width : 75px ;height: 75px;' />");
    sb.appendHtmlConstant("</td><td>");
    sb.appendEscaped(value.getAppName());
    sb.appendHtmlConstant("</td></tr><tr><td>");
    sb.appendEscaped(value.getAppLink());
    sb.appendHtmlConstant("</td></tr><tr><td>");
    sb.appendEscaped(value.getAppDesc());
    sb.appendHtmlConstant("</td></tr>");
    sb.appendHtmlConstant("</Table>");
}

Servlet Code:

        String appId = get(request, "appId");
    String requestType = get(request, "requestType");
    log.info("Your request for apps icon: " + appId + ", requestType: " + requestType);
    if (requestType.equalsIgnoreCase("icon")) {
        Apps icon = appsServiceImpl.getApp(Long.valueOf(appId));
        log.info("We got apps for you: " + icon);
        if(icon != null){
            log.info("We got store logo for you: " + icon.getIcon());
            response.getOutputStream().write(icon.getIcon());
        }
    }

Now when i am updating the image in Blob i want same to be reflected in CellList's Cell. For updating of cell i am using ListDataProvider's set() method.

Using set() method, the Text data in Cell getting updated perfect but the image is not getting updated. The url also getting generated perfectly but is not again generating the call to the Servlet once the cell got rendered.

Can anyone what should i do so that will again generate the call to Servlet?

4

1 回答 1

0

在 url 的末尾添加一个参数。类似于随机整数的东西。图像未刷新,因为浏览器假定它与以前的图像相同,并使用其缓存中的图像。

Random random = new Random();
String url=GWT.getModuleBaseURL()+"fetchIcon?appId="+value.getId()+"&requestType=icon" + "&r=" + random.nextInt();
于 2011-09-09T18:10:14.610 回答