You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by oliverw <ol...@weichhold.com> on 2008/02/03 13:07:11 UTC

Refreshing a Captcha Image

I've added a "Refresh Captcha" AjaxFallBackLink below my captcha image and
cannot figure out why the following code will only refresh the image after
pressing F5 in the browser? There's no errors. The refresh just isnt
working. Caching issue perhaps?

public RegistrationForm(String id)
{
	...

	add(new AjaxFallbackLink("refreshCaptcha")
	{
		@Override
		public void onClick(AjaxRequestTarget target)
		{
			setupCaptcha(target);
		}
	});
	setupCaptcha(null);

	...
}

void setupCaptcha(AjaxRequestTarget target)
{
	captchaPassword = StringHelper.randomString(6, 8);
	CaptchaImageResource captchaImageResource = new
CaptchaImageResource(captchaPassword);
	Image imgCaptcha = new Image("captchaImage", captchaImageResource);
	imgCaptcha.setOutputMarkupId(true); // required for AjaxFallbackLink
	addOrReplace(imgCaptcha);

	if(target != null)
		target.addComponent(imgCaptcha);
}

-- 
View this message in context: http://www.nabble.com/Refreshing-a-Captcha-Image-tp15252837p15252837.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Refreshing a Captcha Image

Posted by oliverw <ol...@weichhold.com>.
Thanks! Problem solved.


Nino.Martinez wrote:
> 
> Use noncaching image.. This is a known feature...
> 
> oliverw wrote:
>> I've added a "Refresh Captcha" AjaxFallBackLink below my captcha image
>> and
>> cannot figure out why the following code will only refresh the image
>> after
>> pressing F5 in the browser? There's no errors. The refresh just isnt
>> working. Caching issue perhaps?
>>
>> public RegistrationForm(String id)
>> {
>> 	...
>>
>> 	add(new AjaxFallbackLink("refreshCaptcha")
>> 	{
>> 		@Override
>> 		public void onClick(AjaxRequestTarget target)
>> 		{
>> 			setupCaptcha(target);
>> 		}
>> 	});
>> 	setupCaptcha(null);
>>
>> 	...
>> }
>>
>> void setupCaptcha(AjaxRequestTarget target)
>> {
>> 	captchaPassword = StringHelper.randomString(6, 8);
>> 	CaptchaImageResource captchaImageResource = new
>> CaptchaImageResource(captchaPassword);
>> 	Image imgCaptcha = new Image("captchaImage", captchaImageResource);
>> 	imgCaptcha.setOutputMarkupId(true); // required for AjaxFallbackLink
>> 	addOrReplace(imgCaptcha);
>>
>> 	if(target != null)
>> 		target.addComponent(imgCaptcha);
>> }
>>
>>   
> 
> -- 
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Refreshing-a-Captcha-Image-tp15252837p15253625.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Refreshing a Captcha Image

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Use noncaching image.. This is a known feature...

oliverw wrote:
> I've added a "Refresh Captcha" AjaxFallBackLink below my captcha image and
> cannot figure out why the following code will only refresh the image after
> pressing F5 in the browser? There's no errors. The refresh just isnt
> working. Caching issue perhaps?
>
> public RegistrationForm(String id)
> {
> 	...
>
> 	add(new AjaxFallbackLink("refreshCaptcha")
> 	{
> 		@Override
> 		public void onClick(AjaxRequestTarget target)
> 		{
> 			setupCaptcha(target);
> 		}
> 	});
> 	setupCaptcha(null);
>
> 	...
> }
>
> void setupCaptcha(AjaxRequestTarget target)
> {
> 	captchaPassword = StringHelper.randomString(6, 8);
> 	CaptchaImageResource captchaImageResource = new
> CaptchaImageResource(captchaPassword);
> 	Image imgCaptcha = new Image("captchaImage", captchaImageResource);
> 	imgCaptcha.setOutputMarkupId(true); // required for AjaxFallbackLink
> 	addOrReplace(imgCaptcha);
>
> 	if(target != null)
> 		target.addComponent(imgCaptcha);
> }
>
>   

-- 
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Refreshing a Captcha Image

Posted by ma nrave <ma...@gmail.com>.
what does firebug (or similar tools) show?

On Feb 3, 2008 2:07 PM, oliverw <ol...@weichhold.com> wrote:

>
> I've added a "Refresh Captcha" AjaxFallBackLink below my captcha image and
> cannot figure out why the following code will only refresh the image after
> pressing F5 in the browser? There's no errors. The refresh just isnt
> working. Caching issue perhaps?
>
> public RegistrationForm(String id)
> {
>        ...
>
>        add(new AjaxFallbackLink("refreshCaptcha")
>        {
>                @Override
>                public void onClick(AjaxRequestTarget target)
>                {
>                        setupCaptcha(target);
>                }
>        });
>        setupCaptcha(null);
>
>        ...
> }
>
> void setupCaptcha(AjaxRequestTarget target)
> {
>        captchaPassword = StringHelper.randomString(6, 8);
>        CaptchaImageResource captchaImageResource = new
> CaptchaImageResource(captchaPassword);
>        Image imgCaptcha = new Image("captchaImage", captchaImageResource);
>        imgCaptcha.setOutputMarkupId(true); // required for
> AjaxFallbackLink
>        addOrReplace(imgCaptcha);
>
>        if(target != null)
>                target.addComponent(imgCaptcha);
> }
>
> --
> View this message in context:
> http://www.nabble.com/Refreshing-a-Captcha-Image-tp15252837p15252837.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>