how to load a svg in gwt widget from an url

后端 未结 2 1692
刺人心
刺人心 2021-01-24 09:05

I have a servlet that delivers png and svg images. With png i have no problem:

Image image = new Image(GWT.getHostPageBaseURL() + token);

But h

2条回答
  •  情歌与酒
    2021-01-24 09:55

    I found a solution that works without any external library (like Andrei's Solution) but keeps also the embedded scripts working. I used the info from here - i used a HTMLPanel and loaded the image via "RequestBuilder":

        String url = GWT.getHostPageBaseURL() + link.getToken();
        RequestBuilder rB = new RequestBuilder(RequestBuilder.GET, url);
        rB.setCallback(new RequestCallback() {
    
            @Override
            public void onResponseReceived(Request request, Response response) {
                //create Widget
                chartImage = new HTMLPanel(response.getText());
                //add to layout   
                layout.add(chartImage);
    
            }
    
            @Override
            public void onError(Request request, Throwable exception) {
                // TODO Auto-generated method stub
    
            }
        });
    

提交回复
热议问题