Home > OS >  Java GWT Image.onErrorHandler is not triggering
Java GWT Image.onErrorHandler is not triggering

Time:02-10

I have a image loading problem on GWT.

On server side:

  • I have a HttpServlet that creates and transfers Captcha images using "Screenshot of the image

    How should I debug it? Please help.

    tbCaptcha = new TextBox();
    
    imgCaptcha = new Image();
    imgCaptcha.addErrorHandler(new ErrorHandler() {
        public void one rror(ErrorEvent event) {
            d.ce("onCaptcha", "onError", System.currentTimeMillis());
            onCaptcha.execute();
        }
    });
    imgCaptcha.addLoadHandler(new LoadHandler() {
        public void onl oad(LoadEvent event) {
            d.cr("onCaptcha", "onLoad", System.currentTimeMillis());
        }
    });
    
    var login = TGS_LibScaleServletUtils.login();
    var newUrl = TGC_CaptchaUtils.newUrl(login.domain, login.port, login.spi);
    imgCaptcha.setUrl(newUrl);
    

    And yes, I am creating a new URL with a random parameter and using Image.prefetch as below:

    public static String newUrl(CharSequence domain, Integer port, CharSequence spi) {
        var newUrlCaptcha = TGS_UrlBuilderUtils.https()
                .domain(domain).port(port).directory(spi)
                .fileOrServlet(TGS_SURLUtils.LOC_NAME)
                .parameter(TGS_SURLUtils.PARAM_NAME, TGS_CaptchaUtils.SERVLET_REFRESH())
                .parameterRandom("r", 10).toString();
        Image.prefetch(newUrlCaptcha);
        return newUrlCaptcha;
    }
    

    Client side console:

    enter image description here

    CodePudding user response:

    Change to Light browser theme from Dark Dark Theme. As captcha image is transparent having black colored text, which matches with black background.

  • Related