开发者

Update the image in gwt CellList

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.getApp开发者_JAVA百科Link());
    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?


Add a paramether at the end of the url. Something like a random int. The image is not refreshed because the browser assumes it's same image as before and uses the image that's in it's cache.

Random random = new Random();
String url=GWT.getModuleBaseURL()+"fetchIcon?appId="+value.getId()+"&requestType=icon" + "&r=" + random.nextInt();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜