I want to be able to show a new captcha image via an AjaxFallbackLink. But
I don't know what to do in onClick to make the captcha img tag reload.
public MyPage extends WebPage {
private CaptchaImageResouce captchaImageResource;
public MyPage() {
add(new Image("captchaImg", new PropertyModel(this,
"captchaImageResource")) {
private static final long serialVersionUID = 1L;
@Override protected void onBeforeRender() {
regenerateCaptcha(); // make a new image
super.onBeforeRender();
}
}.setOutputMarkupId(true));
add(new AjaxFallbackLink("link") {
@Override public void onClick(AjaxRequestTarget target) {
// WHAT DO I DO HERE? Is there some javascript to make the
img tag reload?
if (target != null) {
target.addComonent(MyPage.this.get("captchaImg")); //
This is not enough to make it show
}
}
}
}
public void regenerateCaptcha() {
captchaResource = new CaptchaImageResource(randomString(3, 5));
}
}