[wicket] ajaxlink 里面定义了一个 img 想要点击图片实现 验证码刷新

RR521521521 2017-09-28
// 验证码容器
        captchaImage = new CaptchaImage("captchaImage");
        captchaImage.setOutputMarkupId(true);
        /*add(captchaImage);*/
        lnkChange = new AjaxLink("lnkChange", this);
       /* lnkChange.addTargetComponent(captchaImage);*/
        lnkChange.add(captchaImage);
        add(lnkChange);
    }

    private void initPage() {
        String verifyCode = VerifyCodeUtils.generateVerifyCode(4);
        ByteArrayOutputStream imOut = new ByteArrayOutputStream();
        try {
            VerifyCodeUtils.outputImage(200, 80, imOut, verifyCode);
} catch (IOException e) {
   throw new RuntimeException(e);
}
        captchaImage.setImageResource(new CaptchaImageResource(verifyCode, imOut.toByteArray()));
        setRenderBodyOnly(true);
    }
Global site tag (gtag.js) - Google Analytics