Question

I'm trying to use captcha as it's shown in this example: http://www.oracle.com/technetwork/developer-tools/jdev/captcha-099103.html And it works fine in .jspx page or in .jsff page fragment, but I have to place captcha onto the first page of taskflow, and there... it's not updated! /* I mean the button "can't read image" doesn't work */ I have no idea why. Can anybody help?

Actually, I figured out how to do it by myself: we need captcha image binding in our bean and the resetting method:

private RichImage captchaImage;
public void setCaptchaImage(RichImage captchaImage) {
    this.captchaImage = captchaImage;
}
public RichImage getCaptchaImage() {
    return captchaImage;
}
public void resetCaptcha(ActionEvent actionEvent) {
    captchaImage.setSource("/captchaservlet?rand=" + 
                           String.valueOf(Math.random()));          
    AdfFacesContext.getCurrentInstance().addPartialTarget(captchaImage.getParent());
}

All, I didn't know how to do was adding parameter to "/captchaservlet" And now it works fine :)

But the next problem appears: when returning to this page with captcha from the second one in task flow I need to refresh captcha image. Is there any method that is executed on page return or something?

Was it helpful?

Solution

Aaaaaaaaaaaand I found even more elegant solution: one should just set the source of the captcha image to this method using the expression builder:

public String getCaptchaSource() {
    return "/captchaservlet?rand=" + String.valueOf(Math.random());
}

The button "Refresh", of course, should be set as a partial trigger for the image, as in the example. And that's it :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top