You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Josh Kamau <jo...@gmail.com> on 2010/06/09 10:14:21 UTC

Captcha regeneration

Hi team;

I am trying to regenerate a captcha to help users incase the previous one
was not very clear. I have tried several things including the code below

                captchaImg = new CaptchaImageResource();
captcha = new Image("captchaImg", captchaImg);
captcha.setOutputMarkupId(true);
frmRegistration.add(captcha);
frmRegistration.setOutputMarkupId(true);
 IndicatingAjaxFallbackLink<String> lnkTryNewCapcha = new
IndicatingAjaxFallbackLink<String>("lnkTryNewCapcha") {

@Override
public void onClick(AjaxRequestTarget target) {
captchaImg = new CaptchaImageResource();
captcha.setOutputMarkupId(true);
captcha.render();
}
};
 frmRegistration.add(lnkTryNewCapcha);

However i am not successful. Which is the best way to do this.

Regards.
Josh.

Re: Captcha regeneration

Posted by Josh Kamau <jo...@gmail.com>.
I used NonCachingImage instead and it worked.

On Wed, Jun 9, 2010 at 12:15 PM, Josh Kamau <jo...@gmail.com> wrote:

> I think the old image is being cached by the browser. any idea how to stop
> this?
>
> regards.
>
>
> On Wed, Jun 9, 2010 at 11:45 AM, Robert Kimotho <ki...@gmail.com>wrote:
>
>> Here is some code that I think will help
>>
>>                        remove(image);
>>                        imagePass = randomString(6, 8);
>>                        captchaImageResource = new
>> CaptchaImageResource(imagePass);
>>                        image = new Image("captchaImage",
>> captchaImageResource);
>>                        add(image);
>>
>> you can have it inside your onClick(AjaxRequestTarget target) {}
>>
>> the key point to note is that you have to remove it first from the
>> component.
>>
>> Regards
>> Kimotho.
>>
>>
>> On Wed, Jun 9, 2010 at 11:14 AM, Josh Kamau <jo...@gmail.com>
>> wrote:
>>
>> > Hi team;
>> >
>> > I am trying to regenerate a captcha to help users incase the previous
>> one
>> > was not very clear. I have tried several things including the code below
>> >
>> >                captchaImg = new CaptchaImageResource();
>> > captcha = new Image("captchaImg", captchaImg);
>> > captcha.setOutputMarkupId(true);
>> > frmRegistration.add(captcha);
>> > frmRegistration.setOutputMarkupId(true);
>> >  IndicatingAjaxFallbackLink<String> lnkTryNewCapcha = new
>> > IndicatingAjaxFallbackLink<String>("lnkTryNewCapcha") {
>> >
>> > @Override
>> > public void onClick(AjaxRequestTarget target) {
>> > captchaImg = new CaptchaImageResource();
>> > captcha.setOutputMarkupId(true);
>> > captcha.render();
>> > }
>> > };
>> >  frmRegistration.add(lnkTryNewCapcha);
>> >
>> > However i am not successful. Which is the best way to do this.
>> >
>> > Regards.
>> > Josh.
>> >
>>
>
>

Re: Captcha regeneration

Posted by Josh Kamau <jo...@gmail.com>.
I think the old image is being cached by the browser. any idea how to stop
this?

regards.

On Wed, Jun 9, 2010 at 11:45 AM, Robert Kimotho <ki...@gmail.com> wrote:

> Here is some code that I think will help
>
>                        remove(image);
>                        imagePass = randomString(6, 8);
>                        captchaImageResource = new
> CaptchaImageResource(imagePass);
>                        image = new Image("captchaImage",
> captchaImageResource);
>                        add(image);
>
> you can have it inside your onClick(AjaxRequestTarget target) {}
>
> the key point to note is that you have to remove it first from the
> component.
>
> Regards
> Kimotho.
>
>
> On Wed, Jun 9, 2010 at 11:14 AM, Josh Kamau <jo...@gmail.com> wrote:
>
> > Hi team;
> >
> > I am trying to regenerate a captcha to help users incase the previous one
> > was not very clear. I have tried several things including the code below
> >
> >                captchaImg = new CaptchaImageResource();
> > captcha = new Image("captchaImg", captchaImg);
> > captcha.setOutputMarkupId(true);
> > frmRegistration.add(captcha);
> > frmRegistration.setOutputMarkupId(true);
> >  IndicatingAjaxFallbackLink<String> lnkTryNewCapcha = new
> > IndicatingAjaxFallbackLink<String>("lnkTryNewCapcha") {
> >
> > @Override
> > public void onClick(AjaxRequestTarget target) {
> > captchaImg = new CaptchaImageResource();
> > captcha.setOutputMarkupId(true);
> > captcha.render();
> > }
> > };
> >  frmRegistration.add(lnkTryNewCapcha);
> >
> > However i am not successful. Which is the best way to do this.
> >
> > Regards.
> > Josh.
> >
>

Re: Captcha regeneration

Posted by Robert Kimotho <ki...@gmail.com>.
Here is some code that I think will help

                        remove(image);
                        imagePass = randomString(6, 8);
                        captchaImageResource = new
CaptchaImageResource(imagePass);
                        image = new Image("captchaImage",
captchaImageResource);
                        add(image);

you can have it inside your onClick(AjaxRequestTarget target) {}

the key point to note is that you have to remove it first from the
component.

Regards
Kimotho.


On Wed, Jun 9, 2010 at 11:14 AM, Josh Kamau <jo...@gmail.com> wrote:

> Hi team;
>
> I am trying to regenerate a captcha to help users incase the previous one
> was not very clear. I have tried several things including the code below
>
>                captchaImg = new CaptchaImageResource();
> captcha = new Image("captchaImg", captchaImg);
> captcha.setOutputMarkupId(true);
> frmRegistration.add(captcha);
> frmRegistration.setOutputMarkupId(true);
>  IndicatingAjaxFallbackLink<String> lnkTryNewCapcha = new
> IndicatingAjaxFallbackLink<String>("lnkTryNewCapcha") {
>
> @Override
> public void onClick(AjaxRequestTarget target) {
> captchaImg = new CaptchaImageResource();
> captcha.setOutputMarkupId(true);
> captcha.render();
> }
> };
>  frmRegistration.add(lnkTryNewCapcha);
>
> However i am not successful. Which is the best way to do this.
>
> Regards.
> Josh.
>