You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Simon Raveh <si...@icann.org> on 2015/09/28 23:28:08 UTC

Refresh tapestry kaptcha using ajax event link

Hi All,

I'm using Tapestry 5.4-beta-35  trying to refresh the Kaptcha image using an
ajax event link. I'm  using the following code:

<div class="form-item form-type-textfield form-item-captcha-response">
    <t:zone t:id="captchaZone" id="captchaZone">
        <div>
            <t:kaptchaimage t:id="kaptchaImage"/>
        </div>
        <div>
            What characters are shown in the box above?
        </div>
        <div class="mb20">
            <t:kaptchafield t:id="kaptchaField" t:image="kaptchaImage"
visible="true" label="characters"/>
        </div>
    </t:zone>
    <div>
        <p>
            <t:eventlink t:id="newImage" event="newImage"
zone="captchaZone" class="from-submit">New
                Image
            </t:eventlink>
        </p>
    </div>
</div>
And in the java class:
void onNewImage() {
    if (request.isXHR()) {
        ajaxResponseRenderer.addRender(captchaZone);
    }
}
I can see the ajax call being trigger on the server and the correct JSON
response is returned but the image does not refresh. I noticed that the
KaptchaImage onImage method is never invoked so new image is not being
generated, only the beginRender method is being called.
When doing the full page reload the following methods are being invoke on
the KaptchaImage component:
1. beginRender
2. onImage
	A. prepareResponse
	B. getStream
But when doing an ajax call only the begainRender method is being called
Any help will be appreciate
Thanks,
Simon