Refresh tapestry kaptcha using ajax event link

2015-09-28 Thread Simon Raveh
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:







What characters are shown in the box above?







New
Image




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




smime.p7s
Description: S/MIME cryptographic signature


ChenilleKit 1.3.3 and tapestry-kaptcha 5.4-beta28 are incompatible

2015-02-25 Thread Balázs Palcsó
Hi,

The reason for the below exception that I had both ChenilleKit and
tapestry-kaptcha on my classpath.
If I remove tapestry-kaptcha I don't get the below error.

Regards,
Balazs

On 25 February 2015 at 23:10, Balázs Palcsó palcso.bal...@gmail.com wrote:

 Hi,

 Thanks for the quick replies. I will try to implement it.

 Regarding ChenilleKit JARs. I have added this dependency to build.gradle:
 compile 'org.chenillekit:chenillekit-tapestry:1.3.3' which brings in these
 files. chenillekit-core-1.3.3, chenillekit-google-1.3.3,
 chenillekit-image-1.3.3, chenillekit-tapestry-1.3.3
 The deployed version only contains one copy of each of these JARs.
 The full stacktrace is

 java.lang.RuntimeException: Service id 'KaptchaProducer' has already been
 defined by
 org.chenillekit.image.ChenilleKitImageModule.buildKaptchaProducer(Map) (at
 ChenilleKitImageModule.java:38) and may not be redefined by
 org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl(Map) (at
 KaptchaProducerImpl.java:34) via
 org.apache.tapestry5.kaptcha.modules.KaptchaModule.bind(ServiceBinder) (at
 KaptchaModule.java:39). You should rename one of the service builder
 methods.
 at
 org.apache.tapestry5.ioc.internal.RegistryImpl.init(RegistryImpl.java:186)
 at
 org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:181)
 at
 org.apache.tapestry5.internal.TapestryAppInitializer.createRegistry(TapestryAppInitializer.java:175)
 at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:103)
 at
 org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
 at
 org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
 at
 org.apache.catalina.core.ApplicationFilterConfig.init(ApplicationFilterConfig.java:107)
 at
 org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
 at
 org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at
 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
 at
 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
 at java.util.concurrent.FutureTask.run(FutureTask.java:262)
 at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:744)


 Best regards,
 Balazs

 On 25 February 2015 at 02:51, Geoff Callender 
 geoff.callender.jumpst...@gmail.com wrote:

 In the following code, I made ImageInlineStreamResponse by extending
 InlineStreamResponse from
 http://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile.

 public ImageInlineStreamResponse getPictureAsImageStream(Integer
 someId) throws FileNotFoundException {

 File file = toFileUsingMySecretPathAlgorithm(someId);

 return new ImageInlineStreamResponse(file);
 }


 ImageInlineStreamResponse calls super(file), then sets the contentType
 appropriately, eg. this.contentType = image/jpeg.

 Two modifications to InlineStreamResponse :

 - add this constructor:

 public InlineStreamResponse(File file) throws
 FileNotFoundException {
 this.is = new FileInputStream(file);
 this.filename = file.getName();
 }

 - in prepareResponse(...), add this:

 // Set content length to prevent chunking - see
 //
 http://tapestry-users.832.n2.nabble.com/Disable-Transfer-Encoding-chunked-from-StreamResponse-td5269662.html#a5269662
 try {
 response.setHeader(Content-Length,  +
 is.available());
 }
 catch (IOException e) {
 // Aaargggh!
 Unrecoverable? Client will simply fail to receive the file.
 e.printStackTrace();
 }

 HTH,

 Geoff

 On 25 Feb 2015, at 11:58 am, Thiago H de Paula Figueiredo 
 thiag...@gmail.com wrote:

  On Tue, 24 Feb 2015 20:29:44 -0300, Balázs Palcsó 
 palcso.bal...@gmail.com wrote:
 
  Hi,
 
  Hi!
 
  I am developing an application that allows uploading images with
 tapestry
  5.4-beta-28.
 
  My plan is to store the uploaded files on the file system. I have
 managed
  to implement this bit, but I am struggling to come up with a solution
 to
  show the uploaded images.
 
  I prefer some kind of database, as storing files in the filesystem can
 be a pain and serving them can be a serious security risk, but that's not
 the point of this message. :)
 
  I am getting an error if I include ChenilleKit Tapestry in the
 classpath
  Service id 'KaptchaProducer' has already been defined by
  org.chenillekit.image.ChenilleKitImageModule.buildKaptchaProducer(Map)
 
  This means there's two ChenilleKit JARs

tapestry kaptcha image does not refesh after an ajax form submit?

2014-09-10 Thread John
Hi,

How do I get a kaptcha image to refresh when a zone is rerendered on an ajax 
request? At present this only happens for a form that submits for the page. 
Without a new code the next validation always fails.

John

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


jquery events with ajax form submission of kaptcha code

2014-08-11 Thread John
I thought this problem was limited to dialogajaxlink but I see teh same thing 
now with ajax forms and jquery.

The first time the form is used the submit event works, when it is rerendered 
it doesn't work the next time.

In the example below the first time the forgot password process is started by 
clicking the link in the ClientAccess component the PasswordHelp component the 
forms appear and work fine. When you cancel and click the forgot password link 
again, the first form with the kaptcha element wont submit again when you press 
Next.

I'm now thinking this may be a kaptcha issue in that kaptcha codes should not 
be reused anyway? In which case how do I request a new code in my component?

Reloading the page gets rid of the problem, similar to the issue I had with 
dialogajaxlink.

I have a prototype running on a test server where the problem can easily be 
reproduced: https://bespokebookings.com:8443/bbapp/Ad/JohnDoe1

What is wrong?

regards,
John


ClientAccess.tml

html xmlns:t=http://tapestry.apache.org/schema/tapestry_5_3.xsd;
  xmlns:p=tapestry:parameter
div class=access
t:zone t:id=signupZone id=signupZone
t:if t:test=!authenticated

t:zone t:id=helpNicknameZone id=helpNicknameZone
t:if t:test=showNicknameHelp
!--t:nicknamehelp/--
/t:if
/t:zone

t:zone t:id=helpPasswordZone id=helpPasswordZone
t:passwordhelp nicknameParm=${nickname} 
showParm=${showPasswordHelp}/
/t:zone

form t:type=form t:id=signupForm t:secure=true 
t:zone=^
p${message:text.accessgreeting}/p

t:label for=nickname 
class=left${message:label.nickname}/t:label
input t:type=TextField t:id=nickname 
t:validate=required,minlength=3 size=20/
t:if test=!signup
nbsp;span title=forgot nickname 
class=helpt:eventlink t:id=forgotnickname 
t:zone=helpNicknameZone?/t:eventlink/span
/t:if
br/
t:label for=password 
class=left${message:label.password}/t:label
input t:type=PasswordField t:id=password 
t:validate=required size=20/
t:if test=!signup
nbsp;span title=${message:hint.forgotpassword} 
class=helpt:eventlink t:id=forgotPassword 
t:zone=signupZone${message:text.forgotpassword}/t:eventlink/span
/t:if
br/
t:if test=!signup
${message:text.registerinfo}
br /
p:else
${message:text.privacyinfo}
br/
t:label for=question 
class=left${message:label.question}/t:label
t:select t:id=question value=questionId 
model=questions t:blankOption=NEVER/
br/
t:label for=answer 
class=left${message:label.answer}/t:label
input t:type=TextField t:id=answer 
t:validate=required,minlength=2 size=15/
br/

t:label for=phone 
class=left${message:label.phone}/t:label
input t:type=TextField t:id=phone 
t:validate=regexp=[0-9]*,minlength=8
   size=15 maxlength=15 t:mixins=jquery/tooltip 
title=${message:hint.mphone}/
br/

t:label for=email 
class=left${message:label.email}/t:labelbr/
input t:type=TextField t:id=email 
t:validate=email,minlength=6
   size=40 maxlength=40 t:mixins=jquery/tooltip 
title=${message:hint.email}/
br/

t:label for=age 
class=left${message:label.age}/t:label
t:select t:id=age value=age t:blankOption=ALWAYS
  t:mixins=jquery/tooltip 
title=${message:hint.age}/
br /

t:label for=sex 
class=left${message:label.sex}/t:label
t:select t:id=sex value=sex model=literal:M,F 
t:blankOption=NEVER
  t:mixins=jquery/tooltip 
title=${message:hint.sex}/
br/
t:label 
for=consent${message:label.consent}/t:label
input t:type=Checkbox t:id=consent
   t:mixins=jquery/tooltip 
title=${message:hint.consent}/

br/
t:kaptchaimage t:id=kaptcha/
br/
span${message:kaptchawarning}/span
br/
t:kaptchafield image=kaptcha/
br/
/p:else
/t:if
t:errors

Re: kaptcha component reloading issues with Firefox

2014-02-08 Thread Thiago H de Paula Figueiredo
On Fri, 24 Jan 2014 19:48:13 -0200, Dimitris Zenios  
dimitris.zen...@gmail.com wrote:



I prefer number 3.


Fixed using option number 3. :)




On Fri, Jan 24, 2014 at 10:13 PM, Bob Harner bobhar...@gmail.com wrote:


Actually, Tapestry's Response interface and ResponseImpl
implementation (a thin facade over HttpServletResponse) don't include
an addHeader method, so we would either have to 1) combine the two
setHeader calls or 2) use HttpServletResponse directly, or 3) change
the Response interface (a backward-incompatible API change, although
maybe worth doing, since I guess very few people would be affected).

On Fri, Jan 24, 2014 at 2:56 PM, Dimitris Zenios
dimitris.zen...@gmail.com wrote:
 It would be nice also to provide a patch file.The only change needed  
is

to
 replace the second setHeader with addHeader. After that we can inform  
a

 person with commit access to merge your patch.


 On Fri, Jan 24, 2014 at 1:22 AM, Ilya Obshadko  
ilya.obsha...@gmail.com

wrote:

 Okay, https://issues.apache.org/jira/browse/TAP5-2275


 On Fri, Jan 24, 2014 at 8:46 AM, Dimitris Zenios
 dimitris.zen...@gmail.comwrote:

  You should start by writing a jira bug report
  On 23 Jan 2014 00:09, Ilya Obshadko ilya.obsha...@gmail.com
wrote:
 
   So I have discussed the issue with Kaptcha library author and  
found

out
   that the problem is, in fact, with Tapestry implementation  
itself.

  
   https://code.google.com/p/kaptcha/issues/detail?id=72
  
   Tapestry component uses response.setHeader(Cache-Control)  
twice,

and
  the
   second call obviously overrides the first one. Is it going to be
fixed?
  
  
  
   On Tue, Jan 21, 2014 at 12:59 PM, Ilya Obshadko 
 ilya.obsha...@gmail.com
   wrote:
  
I'm not sure if anyone else has that issue: reloading the zone
  containing
kaptcha component does not trigger image reloading, so the  
whole

 thing
becomes unusable (because internal CAPTCHA text is already
different,
  but
image is not). This affects ONLY Firefox, all the other major
 browsers
   are
OK. Don't have an idea why (probably Firefox doesn't respect  
cache

   control
headers because of some reasons).
   
After spending some time to fix it, I've ended up with simple
copy-and-paste versions of KaptchaField and KaptchaImage  
classes

with
   only
one small difference in KaptchaImage:
   
   
boolean beginRender(MarkupWriter writer)
   
{
   
captchaText = producer.createText();
   
   
   
Link link = resources.createEventLink(image,
RandomStringUtils.randomAlphanumeric ( 8 ) );
   
   
writer.element(img,
   
   
src, link.toURI(),
   
   
width, producer.getWidth(),
   
   
height, producer.getHeight());
   
   
resources.renderInformalParameters(writer);
   
   
writer.end();
   
   
return false;
   
}
   
It might be a good idea to fix it in the main branch.
   
--
Ilya Obshadko
   
   
  
  
   --
   Ilya Obshadko
  
 



 --
 Ilya Obshadko


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha component reloading issues with Firefox

2014-01-24 Thread Dimitris Zenios
It would be nice also to provide a patch file.The only change needed is to
replace the second setHeader with addHeader. After that we can inform a
person with commit access to merge your patch.


On Fri, Jan 24, 2014 at 1:22 AM, Ilya Obshadko ilya.obsha...@gmail.comwrote:

 Okay, https://issues.apache.org/jira/browse/TAP5-2275


 On Fri, Jan 24, 2014 at 8:46 AM, Dimitris Zenios
 dimitris.zen...@gmail.comwrote:

  You should start by writing a jira bug report
  On 23 Jan 2014 00:09, Ilya Obshadko ilya.obsha...@gmail.com wrote:
 
   So I have discussed the issue with Kaptcha library author and found out
   that the problem is, in fact, with Tapestry implementation itself.
  
   https://code.google.com/p/kaptcha/issues/detail?id=72
  
   Tapestry component uses response.setHeader(Cache-Control) twice, and
  the
   second call obviously overrides the first one. Is it going to be fixed?
  
  
  
   On Tue, Jan 21, 2014 at 12:59 PM, Ilya Obshadko 
 ilya.obsha...@gmail.com
   wrote:
  
I'm not sure if anyone else has that issue: reloading the zone
  containing
kaptcha component does not trigger image reloading, so the whole
 thing
becomes unusable (because internal CAPTCHA text is already different,
  but
image is not). This affects ONLY Firefox, all the other major
 browsers
   are
OK. Don't have an idea why (probably Firefox doesn't respect cache
   control
headers because of some reasons).
   
After spending some time to fix it, I've ended up with simple
copy-and-paste versions of KaptchaField and KaptchaImage classes with
   only
one small difference in KaptchaImage:
   
   
boolean beginRender(MarkupWriter writer)
   
{
   
captchaText = producer.createText();
   
   
   
Link link = resources.createEventLink(image,
RandomStringUtils.randomAlphanumeric ( 8 ) );
   
   
writer.element(img,
   
   
src, link.toURI(),
   
   
width, producer.getWidth(),
   
   
height, producer.getHeight());
   
   
resources.renderInformalParameters(writer);
   
   
writer.end();
   
   
return false;
   
}
   
It might be a good idea to fix it in the main branch.
   
--
Ilya Obshadko
   
   
  
  
   --
   Ilya Obshadko
  
 



 --
 Ilya Obshadko



Re: kaptcha component reloading issues with Firefox

2014-01-24 Thread Bob Harner
Actually, Tapestry's Response interface and ResponseImpl
implementation (a thin facade over HttpServletResponse) don't include
an addHeader method, so we would either have to 1) combine the two
setHeader calls or 2) use HttpServletResponse directly, or 3) change
the Response interface (a backward-incompatible API change, although
maybe worth doing, since I guess very few people would be affected).

On Fri, Jan 24, 2014 at 2:56 PM, Dimitris Zenios
dimitris.zen...@gmail.com wrote:
 It would be nice also to provide a patch file.The only change needed is to
 replace the second setHeader with addHeader. After that we can inform a
 person with commit access to merge your patch.


 On Fri, Jan 24, 2014 at 1:22 AM, Ilya Obshadko ilya.obsha...@gmail.comwrote:

 Okay, https://issues.apache.org/jira/browse/TAP5-2275


 On Fri, Jan 24, 2014 at 8:46 AM, Dimitris Zenios
 dimitris.zen...@gmail.comwrote:

  You should start by writing a jira bug report
  On 23 Jan 2014 00:09, Ilya Obshadko ilya.obsha...@gmail.com wrote:
 
   So I have discussed the issue with Kaptcha library author and found out
   that the problem is, in fact, with Tapestry implementation itself.
  
   https://code.google.com/p/kaptcha/issues/detail?id=72
  
   Tapestry component uses response.setHeader(Cache-Control) twice, and
  the
   second call obviously overrides the first one. Is it going to be fixed?
  
  
  
   On Tue, Jan 21, 2014 at 12:59 PM, Ilya Obshadko 
 ilya.obsha...@gmail.com
   wrote:
  
I'm not sure if anyone else has that issue: reloading the zone
  containing
kaptcha component does not trigger image reloading, so the whole
 thing
becomes unusable (because internal CAPTCHA text is already different,
  but
image is not). This affects ONLY Firefox, all the other major
 browsers
   are
OK. Don't have an idea why (probably Firefox doesn't respect cache
   control
headers because of some reasons).
   
After spending some time to fix it, I've ended up with simple
copy-and-paste versions of KaptchaField and KaptchaImage classes with
   only
one small difference in KaptchaImage:
   
   
boolean beginRender(MarkupWriter writer)
   
{
   
captchaText = producer.createText();
   
   
   
Link link = resources.createEventLink(image,
RandomStringUtils.randomAlphanumeric ( 8 ) );
   
   
writer.element(img,
   
   
src, link.toURI(),
   
   
width, producer.getWidth(),
   
   
height, producer.getHeight());
   
   
resources.renderInformalParameters(writer);
   
   
writer.end();
   
   
return false;
   
}
   
It might be a good idea to fix it in the main branch.
   
--
Ilya Obshadko
   
   
  
  
   --
   Ilya Obshadko
  
 



 --
 Ilya Obshadko


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha component reloading issues with Firefox

2014-01-24 Thread Dimitris Zenios
I prefer number 3.


On Fri, Jan 24, 2014 at 10:13 PM, Bob Harner bobhar...@gmail.com wrote:

 Actually, Tapestry's Response interface and ResponseImpl
 implementation (a thin facade over HttpServletResponse) don't include
 an addHeader method, so we would either have to 1) combine the two
 setHeader calls or 2) use HttpServletResponse directly, or 3) change
 the Response interface (a backward-incompatible API change, although
 maybe worth doing, since I guess very few people would be affected).

 On Fri, Jan 24, 2014 at 2:56 PM, Dimitris Zenios
 dimitris.zen...@gmail.com wrote:
  It would be nice also to provide a patch file.The only change needed is
 to
  replace the second setHeader with addHeader. After that we can inform a
  person with commit access to merge your patch.
 
 
  On Fri, Jan 24, 2014 at 1:22 AM, Ilya Obshadko ilya.obsha...@gmail.com
 wrote:
 
  Okay, https://issues.apache.org/jira/browse/TAP5-2275
 
 
  On Fri, Jan 24, 2014 at 8:46 AM, Dimitris Zenios
  dimitris.zen...@gmail.comwrote:
 
   You should start by writing a jira bug report
   On 23 Jan 2014 00:09, Ilya Obshadko ilya.obsha...@gmail.com
 wrote:
  
So I have discussed the issue with Kaptcha library author and found
 out
that the problem is, in fact, with Tapestry implementation itself.
   
https://code.google.com/p/kaptcha/issues/detail?id=72
   
Tapestry component uses response.setHeader(Cache-Control) twice,
 and
   the
second call obviously overrides the first one. Is it going to be
 fixed?
   
   
   
On Tue, Jan 21, 2014 at 12:59 PM, Ilya Obshadko 
  ilya.obsha...@gmail.com
wrote:
   
 I'm not sure if anyone else has that issue: reloading the zone
   containing
 kaptcha component does not trigger image reloading, so the whole
  thing
 becomes unusable (because internal CAPTCHA text is already
 different,
   but
 image is not). This affects ONLY Firefox, all the other major
  browsers
are
 OK. Don't have an idea why (probably Firefox doesn't respect cache
control
 headers because of some reasons).

 After spending some time to fix it, I've ended up with simple
 copy-and-paste versions of KaptchaField and KaptchaImage classes
 with
only
 one small difference in KaptchaImage:


 boolean beginRender(MarkupWriter writer)

 {

 captchaText = producer.createText();



 Link link = resources.createEventLink(image,
 RandomStringUtils.randomAlphanumeric ( 8 ) );


 writer.element(img,


 src, link.toURI(),


 width, producer.getWidth(),


 height, producer.getHeight());


 resources.renderInformalParameters(writer);


 writer.end();


 return false;

 }

 It might be a good idea to fix it in the main branch.

 --
 Ilya Obshadko


   
   
--
Ilya Obshadko
   
  
 
 
 
  --
  Ilya Obshadko
 

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




Re: kaptcha component reloading issues with Firefox

2014-01-23 Thread Dimitris Zenios
You should start by writing a jira bug report
On 23 Jan 2014 00:09, Ilya Obshadko ilya.obsha...@gmail.com wrote:

 So I have discussed the issue with Kaptcha library author and found out
 that the problem is, in fact, with Tapestry implementation itself.

 https://code.google.com/p/kaptcha/issues/detail?id=72

 Tapestry component uses response.setHeader(Cache-Control) twice, and the
 second call obviously overrides the first one. Is it going to be fixed?



 On Tue, Jan 21, 2014 at 12:59 PM, Ilya Obshadko ilya.obsha...@gmail.com
 wrote:

  I'm not sure if anyone else has that issue: reloading the zone containing
  kaptcha component does not trigger image reloading, so the whole thing
  becomes unusable (because internal CAPTCHA text is already different, but
  image is not). This affects ONLY Firefox, all the other major browsers
 are
  OK. Don't have an idea why (probably Firefox doesn't respect cache
 control
  headers because of some reasons).
 
  After spending some time to fix it, I've ended up with simple
  copy-and-paste versions of KaptchaField and KaptchaImage classes with
 only
  one small difference in KaptchaImage:
 
 
  boolean beginRender(MarkupWriter writer)
 
  {
 
  captchaText = producer.createText();
 
 
 
  Link link = resources.createEventLink(image,
  RandomStringUtils.randomAlphanumeric ( 8 ) );
 
 
  writer.element(img,
 
 
  src, link.toURI(),
 
 
  width, producer.getWidth(),
 
 
  height, producer.getHeight());
 
 
  resources.renderInformalParameters(writer);
 
 
  writer.end();
 
 
  return false;
 
  }
 
  It might be a good idea to fix it in the main branch.
 
  --
  Ilya Obshadko
 
 


 --
 Ilya Obshadko



Re: kaptcha component reloading issues with Firefox

2014-01-23 Thread Ilya Obshadko
Okay, https://issues.apache.org/jira/browse/TAP5-2275


On Fri, Jan 24, 2014 at 8:46 AM, Dimitris Zenios
dimitris.zen...@gmail.comwrote:

 You should start by writing a jira bug report
 On 23 Jan 2014 00:09, Ilya Obshadko ilya.obsha...@gmail.com wrote:

  So I have discussed the issue with Kaptcha library author and found out
  that the problem is, in fact, with Tapestry implementation itself.
 
  https://code.google.com/p/kaptcha/issues/detail?id=72
 
  Tapestry component uses response.setHeader(Cache-Control) twice, and
 the
  second call obviously overrides the first one. Is it going to be fixed?
 
 
 
  On Tue, Jan 21, 2014 at 12:59 PM, Ilya Obshadko ilya.obsha...@gmail.com
  wrote:
 
   I'm not sure if anyone else has that issue: reloading the zone
 containing
   kaptcha component does not trigger image reloading, so the whole thing
   becomes unusable (because internal CAPTCHA text is already different,
 but
   image is not). This affects ONLY Firefox, all the other major browsers
  are
   OK. Don't have an idea why (probably Firefox doesn't respect cache
  control
   headers because of some reasons).
  
   After spending some time to fix it, I've ended up with simple
   copy-and-paste versions of KaptchaField and KaptchaImage classes with
  only
   one small difference in KaptchaImage:
  
  
   boolean beginRender(MarkupWriter writer)
  
   {
  
   captchaText = producer.createText();
  
  
  
   Link link = resources.createEventLink(image,
   RandomStringUtils.randomAlphanumeric ( 8 ) );
  
  
   writer.element(img,
  
  
   src, link.toURI(),
  
  
   width, producer.getWidth(),
  
  
   height, producer.getHeight());
  
  
   resources.renderInformalParameters(writer);
  
  
   writer.end();
  
  
   return false;
  
   }
  
   It might be a good idea to fix it in the main branch.
  
   --
   Ilya Obshadko
  
  
 
 
  --
  Ilya Obshadko
 




-- 
Ilya Obshadko


Re: kaptcha component reloading issues with Firefox

2014-01-22 Thread Ilya Obshadko
So I have discussed the issue with Kaptcha library author and found out
that the problem is, in fact, with Tapestry implementation itself.

https://code.google.com/p/kaptcha/issues/detail?id=72

Tapestry component uses response.setHeader(Cache-Control) twice, and the
second call obviously overrides the first one. Is it going to be fixed?



On Tue, Jan 21, 2014 at 12:59 PM, Ilya Obshadko ilya.obsha...@gmail.comwrote:

 I'm not sure if anyone else has that issue: reloading the zone containing
 kaptcha component does not trigger image reloading, so the whole thing
 becomes unusable (because internal CAPTCHA text is already different, but
 image is not). This affects ONLY Firefox, all the other major browsers are
 OK. Don't have an idea why (probably Firefox doesn't respect cache control
 headers because of some reasons).

 After spending some time to fix it, I've ended up with simple
 copy-and-paste versions of KaptchaField and KaptchaImage classes with only
 one small difference in KaptchaImage:


 boolean beginRender(MarkupWriter writer)

 {

 captchaText = producer.createText();



 Link link = resources.createEventLink(image,
 RandomStringUtils.randomAlphanumeric ( 8 ) );


 writer.element(img,


 src, link.toURI(),


 width, producer.getWidth(),


 height, producer.getHeight());


 resources.renderInformalParameters(writer);


 writer.end();


 return false;

 }

 It might be a good idea to fix it in the main branch.

 --
 Ilya Obshadko




-- 
Ilya Obshadko


kaptcha component reloading issues with Firefox

2014-01-20 Thread Ilya Obshadko
I'm not sure if anyone else has that issue: reloading the zone containing
kaptcha component does not trigger image reloading, so the whole thing
becomes unusable (because internal CAPTCHA text is already different, but
image is not). This affects ONLY Firefox, all the other major browsers are
OK. Don't have an idea why (probably Firefox doesn't respect cache control
headers because of some reasons).

After spending some time to fix it, I've ended up with simple
copy-and-paste versions of KaptchaField and KaptchaImage classes with only
one small difference in KaptchaImage:


boolean beginRender(MarkupWriter writer)

{

captchaText = producer.createText();



Link link = resources.createEventLink(image,
RandomStringUtils.randomAlphanumeric ( 8 ) );


writer.element(img,


src, link.toURI(),


width, producer.getWidth(),


height, producer.getHeight());


resources.renderInformalParameters(writer);


writer.end();


return false;

}

It might be a good idea to fix it in the main branch.

-- 
Ilya Obshadko


Re: kaptcha deployment error

2013-08-02 Thread Taha Hafeez Siddiqi

Why are you binding KaptchaProvider service in your AppModule when it is 
already bound in tapestry-kaptcha ?

regards
Taha

On 02-Aug-2013, at 8:51 AM, Nikola Vulovic nivuk...@gmail.com wrote:

 this is the error:
 java.lang.RuntimeException: Service id 'KaptchaProducer' has already been
 defined by
 org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl(Map) (at
 KaptchaProducerImpl.java:34) via
 org.apache.tapestry5.kaptcha.services.KaptchaModule.bind(ServiceBinder) (at
 KaptchaModule.java:38) and may not be redefined by
 org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl(Map) (at
 KaptchaProducerImpl.java:34) via
 domaci850.services.AppModule.bind(ServiceBinder) (at AppModule.java:33).
 You should rename one of the service builder methods.
 
 This is appmodule
 import org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl;
 import org.apache.tapestry5.kaptcha.services.KaptchaProducer;
 
 public static void bind(ServiceBinder binder) {
  // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
  // Make bind() calls on the binder object to define most IoC services.
  // Use service builder methods (example below) when the implementation
  // is provided inline, or requires more initialization than simply
  // invoking the constructor.
  binder.bind(KaptchaProducer.class, KaptchaProducerImpl.class);
 }
 Added library's
 tapestry-kaptcha-5.3.7.jar
 kaptcha-2.3.2.jar
 kaptcha-2.3.2-jdk14.jar
 
 What should be renamed?
 Thanks for help
 
 -- 
 Pozdrav Nikola Vulovic


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha deployment error

2013-08-02 Thread Nikola Vulovic
do not know why?
Services are not very clear to me and documentation is unclear
it worked when I removed line
binder.bind(KaptchaProducer.class, KaptchaProducerImpl.class);


On Fri, Aug 2, 2013 at 5:21 AM, Nikola Vulovic nivuk...@gmail.com wrote:

 this is the error:
 java.lang.RuntimeException: Service id 'KaptchaProducer' has already been
 defined by
 org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl(Map) (at
 KaptchaProducerImpl.java:34) via
 org.apache.tapestry5.kaptcha.services.KaptchaModule.bind(ServiceBinder) (at
 KaptchaModule.java:38) and may not be redefined by
 org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl(Map) (at
 KaptchaProducerImpl.java:34) via
 domaci850.services.AppModule.bind(ServiceBinder) (at AppModule.java:33).
 You should rename one of the service builder methods.

 This is appmodule
 import org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl;
 import org.apache.tapestry5.kaptcha.services.KaptchaProducer;

  public static void bind(ServiceBinder binder) {
   // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
   // Make bind() calls on the binder object to define most IoC services.
   // Use service builder methods (example below) when the implementation
   // is provided inline, or requires more initialization than simply
   // invoking the constructor.
   binder.bind(KaptchaProducer.class, KaptchaProducerImpl.class);
  }
 Added library's
 tapestry-kaptcha-5.3.7.jar
  kaptcha-2.3.2.jar
 kaptcha-2.3.2-jdk14.jar

 What should be renamed?
 Thanks for help

 --
 Pozdrav Nikola Vulovic




-- 
Pozdrav Nikola Vulovic


Re: kaptcha deployment error

2013-08-02 Thread Lance Java
1. Tapestry is built on top of an IOC container (called unimaginatively
Tapestry IOC)
2. Services are added to the IOC registry by an IOC Module (
http://tapestry.apache.org/tapestry-ioc-modules.html)
3. Components often require Services
4. Component libraries can include a Tapestry-Module-Classes entry in
their jar manifest which will cause tapestry to load additional IOC Modules
5. Tapestry IOC provides loads of goodies including service overriding,
decorating and contributions

Some reading to get you started:
http://tapestry.apache.org/ioc.html
http://tapestry.apache.org/component-libraries.html
On 2 Aug 2013 10:18, Nikola Vulovic nivuk...@gmail.com wrote:

 do not know why?
 Services are not very clear to me and documentation is unclear
 it worked when I removed line
 binder.bind(KaptchaProducer.class, KaptchaProducerImpl.class);


 On Fri, Aug 2, 2013 at 5:21 AM, Nikola Vulovic nivuk...@gmail.com wrote:

  this is the error:
  java.lang.RuntimeException: Service id 'KaptchaProducer' has already been
  defined by
  org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl(Map)
 (at
  KaptchaProducerImpl.java:34) via
  org.apache.tapestry5.kaptcha.services.KaptchaModule.bind(ServiceBinder)
 (at
  KaptchaModule.java:38) and may not be redefined by
  org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl(Map)
 (at
  KaptchaProducerImpl.java:34) via
  domaci850.services.AppModule.bind(ServiceBinder) (at AppModule.java:33).
  You should rename one of the service builder methods.
 
  This is appmodule
  import
 org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl;
  import org.apache.tapestry5.kaptcha.services.KaptchaProducer;
 
   public static void bind(ServiceBinder binder) {
// binder.bind(MyServiceInterface.class, MyServiceImpl.class);
// Make bind() calls on the binder object to define most IoC services.
// Use service builder methods (example below) when the implementation
// is provided inline, or requires more initialization than simply
// invoking the constructor.
binder.bind(KaptchaProducer.class, KaptchaProducerImpl.class);
   }
  Added library's
  tapestry-kaptcha-5.3.7.jar
   kaptcha-2.3.2.jar
  kaptcha-2.3.2-jdk14.jar
 
  What should be renamed?
  Thanks for help
 
  --
  Pozdrav Nikola Vulovic
 



 --
 Pozdrav Nikola Vulovic



kaptcha deployment error

2013-08-01 Thread Nikola Vulovic
this is the error:
java.lang.RuntimeException: Service id 'KaptchaProducer' has already been
defined by
org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl(Map) (at
KaptchaProducerImpl.java:34) via
org.apache.tapestry5.kaptcha.services.KaptchaModule.bind(ServiceBinder) (at
KaptchaModule.java:38) and may not be redefined by
org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl(Map) (at
KaptchaProducerImpl.java:34) via
domaci850.services.AppModule.bind(ServiceBinder) (at AppModule.java:33).
You should rename one of the service builder methods.

This is appmodule
import org.apache.tapestry5.kaptcha.internal.services.KaptchaProducerImpl;
import org.apache.tapestry5.kaptcha.services.KaptchaProducer;

 public static void bind(ServiceBinder binder) {
  // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
  // Make bind() calls on the binder object to define most IoC services.
  // Use service builder methods (example below) when the implementation
  // is provided inline, or requires more initialization than simply
  // invoking the constructor.
  binder.bind(KaptchaProducer.class, KaptchaProducerImpl.class);
 }
Added library's
tapestry-kaptcha-5.3.7.jar
 kaptcha-2.3.2.jar
kaptcha-2.3.2-jdk14.jar

What should be renamed?
Thanks for help

-- 
Pozdrav Nikola Vulovic


Updating kaptcha mvn dependency in tapestry-kaptcha

2013-05-30 Thread Ben Titmarsh
The Tapestry-Kaptcha project relies on version 2.3 of com.google.code.kaptcha.

After much fuss from the author, 2.3.2 has been added to this mvn repo:

https://m2repos.googlecode.com/svn/nexus

Can we get the dependency updated in the tapestry-kaptcha project to point to 
this version so that we don't have to mess around with getting the JAR on our 
project classpath?






  

kaptcha

2012-11-26 Thread John
please share opinions on the best Tapestry Kaptcha solution please, i.e. 
easiest to integrate and simple to use - I believe there is more than 1 choice

TIA

Re: kaptcha

2012-11-26 Thread Stephan Windmüller
On 26.11.2012 15:03, John wrote:

 please share opinions on the best Tapestry Kaptcha solution please,
 i.e. easiest to integrate and simple to use - I believe there is more
 than 1 choice

Hi John,

please do not start a new thread by replying to an existing message and
changing the subject. Instead, please write a new e-mail. Thanks.

About your question: We use the kaptcha component integrated in
Tapestry:

http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/kaptcha/components/package-summary.html

Example code:

t:kaptchaimage t:id=captchaImage/
br/
t:kaptchafield label=Security Check t:id=captchaField
image=captchaImage t:visible=true/

HTH
 Stephan



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Kaptcha - alternative libraries

2012-02-06 Thread captain_rhino
I have used the standard kaptcha and I'm happy with it.

The problem is the end users (and the boss) don't think it is easily read..
I explained to him this is kind of how they are but he's seen others that
look easier to read and have functionality such as a refresh icon (to change
the text of the captcha image).

My question such is:

1.  Is it easy to change the google captcha librray behind the scenes to use
a different one.  And can anyone suggest another one that is easy to plug
in?

2.  Can the existing tapestry captcha be easily changed to have a refresh
button?

thx in advance.

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Kaptcha-alternative-libraries-tp5459895p5459895.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Kaptcha - alternative libraries

2012-02-06 Thread Thiago H. de Paula Figueiredo
Why don't you just use another captcha component instead? A quick Google  
search provides some.


On Mon, 06 Feb 2012 09:36:56 -0200, captain_rhino  
graeme.kitc...@axa-travel-insurance.com wrote:



I have used the standard kaptcha and I'm happy with it.

The problem is the end users (and the boss) don't think it is easily  
read..

I explained to him this is kind of how they are but he's seen others that
look easier to read and have functionality such as a refresh icon (to  
change

the text of the captcha image).

My question such is:

1.  Is it easy to change the google captcha librray behind the scenes to  
use

a different one.  And can anyone suggest another one that is easy to plug
in?

2.  Can the existing tapestry captcha be easily changed to have a refresh
button?

thx in advance.

--
View this message in context:  
http://tapestry.1045711.n5.nabble.com/Kaptcha-alternative-libraries-tp5459895p5459895.html

Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org




--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Kaptcha - alternative libraries

2012-02-06 Thread Taha Hafeez Siddiqi

Here is one example

http://tawus.wordpress.com/2011/10/14/tapestry-using-recaptcha/

Tapestry mailing list is so good that people first ask a question then do a 
google search :). But I don't think that is the right way :-(

regards
Taha

On Feb 6, 2012, at 6:12 PM, Thiago H. de Paula Figueiredo wrote:

 Why don't you just use another captcha component instead? A quick Google 
 search provides some.
 
 On Mon, 06 Feb 2012 09:36:56 -0200, captain_rhino 
 graeme.kitc...@axa-travel-insurance.com wrote:
 
 I have used the standard kaptcha and I'm happy with it.
 
 The problem is the end users (and the boss) don't think it is easily read..
 I explained to him this is kind of how they are but he's seen others that
 look easier to read and have functionality such as a refresh icon (to change
 the text of the captcha image).
 
 My question such is:
 
 1.  Is it easy to change the google captcha librray behind the scenes to use
 a different one.  And can anyone suggest another one that is easy to plug
 in?
 
 2.  Can the existing tapestry captcha be easily changed to have a refresh
 button?
 
 thx in advance.
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Kaptcha-alternative-libraries-tp5459895p5459895.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
 
 -- 
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and 
 instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
 http://www.arsmachina.com.br
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 



Re: Overriding input type = password for T5 Kaptcha component

2012-01-24 Thread Igor Drobiazko
Not yet, but you can fill a JIRA issue.

On Mon, Jan 23, 2012 at 10:49 PM, Julien Martin bal...@gmail.com wrote:

 Hello,
 I noticed that the input type of the kaptcha field is *of type password*.
 Is there a way to make it of type input* type=text instead*?
 Regards,
 Julien.




-- 
Best regards,

Igor Drobiazko
http://tapestry5.de
http://twitter.com/drobiazko


Re: Overriding input type = password for T5 Kaptcha component

2012-01-24 Thread Julien Martin
done!

2012/1/24 Igor Drobiazko igor.drobia...@gmail.com

 Not yet, but you can fill a JIRA issue.

 On Mon, Jan 23, 2012 at 10:49 PM, Julien Martin bal...@gmail.com wrote:

  Hello,
  I noticed that the input type of the kaptcha field is *of type password*.
  Is there a way to make it of type input* type=text instead*?
  Regards,
  Julien.
 



 --
 Best regards,

 Igor Drobiazko
 http://tapestry5.de
 http://twitter.com/drobiazko



Customizing T5 Kaptcha...

2012-01-23 Thread Julien Martin
Hello,
I would like to add a T5 Kaptcha to my website but I also need to customize
it (background color, font color, size, readability).
Is this possible with t:kaptcha? If so how?
Regards,
J.


Re: Customizing T5 Kaptcha...

2012-01-23 Thread Thiago H. de Paula Figueiredo

On Mon, 23 Jan 2012 09:49:07 -0200, Julien Martin bal...@gmail.com wrote:


Hello,
I would like to add a T5 Kaptcha to my website but I also need to  
customize

it (background color, font color, size, readability).
Is this possible with t:kaptcha? If so how?


Have you tried CSS?

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Customizing T5 Kaptcha...

2012-01-23 Thread Julien Martin
Thiago,
Isn't the image a gif or a jpeg?
J.

2012/1/23 Thiago H. de Paula Figueiredo thiag...@gmail.com

 On Mon, 23 Jan 2012 09:49:07 -0200, Julien Martin bal...@gmail.com
 wrote:

  Hello,
 I would like to add a T5 Kaptcha to my website but I also need to
 customize
 it (background color, font color, size, readability).
 Is this possible with t:kaptcha? If so how?


 Have you tried CSS?

 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br



Re: Customizing T5 Kaptcha...

2012-01-23 Thread Thiago H. de Paula Figueiredo

On Mon, 23 Jan 2012 11:25:47 -0200, Julien Martin bal...@gmail.com wrote:


Thiago,
Isn't the image a gif or a jpeg?


Oops, I mesread your question. I'm sorry.

Tapestry-Kaptcha is just a Tapestry wrapper around this package:  
http://code.google.com/p/kaptcha/, so you should check its documentation:  
http://code.google.com/p/kaptcha/wiki/ConfigParameters


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Customizing T5 Kaptcha...

2012-01-23 Thread Julien Martin
I see. The config param you are pointing to are interesting. How then would
I specify them with T5 Kaptcha? Is it what
@SupportsInformalParametershttp://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/SupportsInformalParameters.html
are
for?
Regards,
J.

2012/1/23 Thiago H. de Paula Figueiredo thiag...@gmail.com

 On Mon, 23 Jan 2012 11:25:47 -0200, Julien Martin bal...@gmail.com
 wrote:

  Thiago,
 Isn't the image a gif or a jpeg?


 Oops, I mesread your question. I'm sorry.

 Tapestry-Kaptcha is just a Tapestry wrapper around this package:
 http://code.google.com/p/**kaptcha/ http://code.google.com/p/kaptcha/,
 so you should check its documentation: http://code.google.com/p/**
 kaptcha/wiki/ConfigParametershttp://code.google.com/p/kaptcha/wiki/ConfigParameters


 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br



Re: Customizing T5 Kaptcha...

2012-01-23 Thread Julien Martin
Thiago,
I meant are the web.xml init params the only way of specifying the config
params for the Kaptcha?
J.

2012/1/23 Julien Martin bal...@gmail.com

 I see. The config param you are pointing to are interesting. How then
 would I specify them with T5 Kaptcha? Is it what
 @SupportsInformalParametershttp://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/SupportsInformalParameters.html
  are
 for?
 Regards,
 J.

 2012/1/23 Thiago H. de Paula Figueiredo thiag...@gmail.com

 On Mon, 23 Jan 2012 11:25:47 -0200, Julien Martin bal...@gmail.com
 wrote:

  Thiago,
 Isn't the image a gif or a jpeg?


 Oops, I mesread your question. I'm sorry.

 Tapestry-Kaptcha is just a Tapestry wrapper around this package:
 http://code.google.com/p/**kaptcha/ http://code.google.com/p/kaptcha/,
 so you should check its documentation: http://code.google.com/p/**
 kaptcha/wiki/ConfigParametershttp://code.google.com/p/kaptcha/wiki/ConfigParameters


 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br





Re: Customizing T5 Kaptcha...

2012-01-23 Thread Thiago H. de Paula Figueiredo

On Mon, 23 Jan 2012 15:40:40 -0200, Julien Martin bal...@gmail.com wrote:


Thiago,
I meant are the web.xml init params the only way of specifying the config
params for the Kaptcha?


From reading the documentation, that seems to be correct.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Customizing T5 Kaptcha...

2012-01-23 Thread Julien Martin
After looking at the source code for the T5 Kaptcha implementation, I found
a T5-friendlier way of configuring the Kaptcha.
Just add the following lines to the services.AppModule class and play with
the values and constants:

* @Contribute(KaptchaProducer.class)*
* public static void configureKaptchaProducer(MappedConfigurationString,
String configuration) {*
* configuration.add(Constants.KAPTCHA_IMAGE_WIDTH, 200);*
* configuration.add(Constants.KAPTCHA_BACKGROUND_CLR_FROM, 255,255,255);*
* configuration.add(Constants.KAPTCHA_BACKGROUND_CLR_TO, 255,255,255);*
* }*

It is cleaner than polluting the web.xml.
Regards,
J.

2012/1/23 Thiago H. de Paula Figueiredo thiag...@gmail.com

 On Mon, 23 Jan 2012 15:40:40 -0200, Julien Martin bal...@gmail.com
 wrote:

  Thiago,

 I meant are the web.xml init params the only way of specifying the config
 params for the Kaptcha?


 From reading the documentation, that seems to be correct.


 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br



Overriding input type = password for T5 Kaptcha component

2012-01-23 Thread Julien Martin
Hello,
I noticed that the input type of the kaptcha field is *of type password*.
Is there a way to make it of type input* type=text instead*?
Regards,
Julien.


T5.3 : Kaptcha

2011-12-14 Thread angelochen
got some questions regarding kaptcha:

1. since validation is off, but it shows a red 'X' in addition to error
Enter the text displayed in the image., i'd prefer to have no red 'X'.

2. t:height and t:width has no effort, height and width same, how to resize
the image?

Thanks,

Angelo



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/T5-3-Kaptcha-tp5074344p5074344.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



kaptcha

2011-11-22 Thread captain_rhino
I might be going mad but how do I use the 

org.apache.tapestry5.kaptcha.components.KaptchaField
org.apache.tapestry5.kaptcha.components.KaptchaImage

component.  I can see the API docs but is there an example and none of the
compenents aoppear in my project?  Any examples would be appreciated?

I do have the tapx component available in my project.  But the validation of
the input always fails? 

Tml
form t:id=kaptchaForm
t:errors/
div t:id=kaptchaImage/
div t:id=kaptchaComponent image=kaptchaImage/
input type=submit/
/form

Page
import com.howardlewisship.tapx.core.components.KaptchaField;
import com.howardlewisship.tapx.core.components.KaptchaImage;

public class TestKap {

@Persist
@Property
private boolean inputValue;

@Component
private Form kaptchaForm;

@Component 
private KaptchaImage kaptchaImage;

@Component(parameters = {value=inputValue,image=kaptchaImage})
private KaptchaField kaptchaComponent;

public boolean onValidateForm()
{
boolean goodValidation = true;

if (!inputValue)
{
kaptchaForm.recordError(kaptcha value not equals the 
user input!);
goodValidation = false;
}

return goodValidation;
}

}

Any help/examples would be much appreciated.

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/kaptcha-tp5013118p5013118.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



kaptcha

2011-11-22 Thread captain_rhino
I might be going mad but how do I use the 

org.apache.tapestry5.kaptcha.components.KaptchaField
org.apache.tapestry5.kaptcha.components.KaptchaImage

component.  I can see the API docs but is there an example and none of the
compenents aoppear in my project?  Any examples would be appreciated?

I do have the tapx component available in my project.  But the validation of
the input always fails? 

Tml
form t:id=kaptchaForm
t:errors/
div t:id=kaptchaImage/
div t:id=kaptchaComponent image=kaptchaImage/
input type=submit/
/form

Page
import com.howardlewisship.tapx.core.components.KaptchaField;
import com.howardlewisship.tapx.core.components.KaptchaImage;

public class TestKap {

@Persist
@Property
private boolean inputValue;

@Component
private Form kaptchaForm;

@Component 
private KaptchaImage kaptchaImage;

@Component(parameters = {value=inputValue,image=kaptchaImage})
private KaptchaField kaptchaComponent;

public boolean onValidateForm()
{
boolean goodValidation = true;

if (!inputValue)
{
kaptchaForm.recordError(kaptcha value not equals the 
user input!);
goodValidation = false;
}

return goodValidation;
}

}

Any help/examples would be much appreciated.

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/kaptcha-tp5013121p5013121.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha

2011-11-22 Thread Taha Hafeez Siddiqi
Hi

Are you including tapestry-kaptcha as a separate dependency. Kaptcha is not 
available in tapestry-core

regards
Taha

On Nov 22, 2011, at 3:25 PM, captain_rhino wrote:

 I might be going mad but how do I use the 
 
 org.apache.tapestry5.kaptcha.components.KaptchaField
 org.apache.tapestry5.kaptcha.components.KaptchaImage
 
 component.  I can see the API docs but is there an example and none of the
 compenents aoppear in my project?  Any examples would be appreciated?
 
 I do have the tapx component available in my project.  But the validation of
 the input always fails? 
 
 Tml
 form t:id=kaptchaForm
   t:errors/
   div t:id=kaptchaImage/
   div t:id=kaptchaComponent image=kaptchaImage/
   input type=submit/
 /form
 
 Page
 import com.howardlewisship.tapx.core.components.KaptchaField;
 import com.howardlewisship.tapx.core.components.KaptchaImage;
 
 public class TestKap {
 
   @Persist
   @Property
   private boolean inputValue;
 
   @Component
   private Form kaptchaForm;
 
   @Component 
   private KaptchaImage kaptchaImage;
   
   @Component(parameters = {value=inputValue,image=kaptchaImage})
   private KaptchaField kaptchaComponent;
 
   public boolean onValidateForm()
   {
   boolean goodValidation = true;
 
   if (!inputValue)
   {
   kaptchaForm.recordError(kaptcha value not equals the 
 user input!);
   goodValidation = false;
   }
 
   return goodValidation;
   }
   
 }
 
 Any help/examples would be much appreciated.
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/kaptcha-tp5013121p5013121.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha

2011-11-22 Thread Geoff Callender
This works. I used tapestry-kaptcha module from T5.3 and the kaptcha jar from 
com.google.code.kaptcha in the classpath…

form t:type=Form
Type the code shown below 
t:KaptchaField t:image=kaptchaImage/ 
input type=submit/
br/br/
t:KaptchaImage t:id=kaptchaImage/
/form


import org.apache.tapestry5.annotations.InjectPage;

public class Page1 {

// Other pages

@InjectPage
private Page2 page2;

// The code

Object onSuccess() {
return page2;
}
}

HTH,

Geoff

On 22/11/2011, at 11:09 PM, Taha Hafeez Siddiqi wrote:

 Hi
 
 Are you including tapestry-kaptcha as a separate dependency. Kaptcha is not 
 available in tapestry-core
 
 regards
 Taha
 
 On Nov 22, 2011, at 3:25 PM, captain_rhino wrote:
 
 I might be going mad but how do I use the 
 
 org.apache.tapestry5.kaptcha.components.KaptchaField
 org.apache.tapestry5.kaptcha.components.KaptchaImage
 
 component.  I can see the API docs but is there an example and none of the
 compenents aoppear in my project?  Any examples would be appreciated?
 
 I do have the tapx component available in my project.  But the validation of
 the input always fails? 
 
 Tml
 form t:id=kaptchaForm
  t:errors/
  div t:id=kaptchaImage/
  div t:id=kaptchaComponent image=kaptchaImage/
  input type=submit/
 /form
 
 Page
 import com.howardlewisship.tapx.core.components.KaptchaField;
 import com.howardlewisship.tapx.core.components.KaptchaImage;
 
 public class TestKap {
 
  @Persist
  @Property
  private boolean inputValue;
 
  @Component
  private Form kaptchaForm;
 
  @Component 
  private KaptchaImage kaptchaImage;
  
  @Component(parameters = {value=inputValue,image=kaptchaImage})
  private KaptchaField kaptchaComponent;
 
  public boolean onValidateForm()
  {
  boolean goodValidation = true;
 
  if (!inputValue)
  {
  kaptchaForm.recordError(kaptcha value not equals the 
 user input!);
  goodValidation = false;
  }
 
  return goodValidation;
  }
  
 }
 
 Any help/examples would be much appreciated.
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/kaptcha-tp5013121p5013121.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 



Re: kaptcha

2011-11-22 Thread Geoff Callender
The kaptcha-2.3.jar is only required at runtime:

http://tapestry.formos.com/maven-repository/com/google/code/kaptcha/kaptcha/2.3/kaptcha-2.3.jar

On 22/11/2011, at 11:44 PM, Geoff Callender wrote:

 This works. I used tapestry-kaptcha module from T5.3 and the kaptcha jar from 
 com.google.code.kaptcha in the classpath…
 
   form t:type=Form
   Type the code shown below 
   t:KaptchaField t:image=kaptchaImage/ 
   input type=submit/
   br/br/
   t:KaptchaImage t:id=kaptchaImage/
   /form
 
 
 import org.apache.tapestry5.annotations.InjectPage;
 
 public class Page1 {
 
   // Other pages
 
   @InjectPage
   private Page2 page2;
 
   // The code
 
   Object onSuccess() {
   return page2;
   }
 }
 
 HTH,
 
 Geoff
 
 On 22/11/2011, at 11:09 PM, Taha Hafeez Siddiqi wrote:
 
 Hi
 
 Are you including tapestry-kaptcha as a separate dependency. Kaptcha is not 
 available in tapestry-core
 
 regards
 Taha
 
 On Nov 22, 2011, at 3:25 PM, captain_rhino wrote:
 
 I might be going mad but how do I use the 
 
 org.apache.tapestry5.kaptcha.components.KaptchaField
 org.apache.tapestry5.kaptcha.components.KaptchaImage
 
 component.  I can see the API docs but is there an example and none of the
 compenents aoppear in my project?  Any examples would be appreciated?
 
 I do have the tapx component available in my project.  But the validation of
 the input always fails? 
 
 Tml
 form t:id=kaptchaForm
 t:errors/
 div t:id=kaptchaImage/
 div t:id=kaptchaComponent image=kaptchaImage/
 input type=submit/
 /form
 
 Page
 import com.howardlewisship.tapx.core.components.KaptchaField;
 import com.howardlewisship.tapx.core.components.KaptchaImage;
 
 public class TestKap {
 
 @Persist
 @Property
 private boolean inputValue;
 
 @Component
 private Form kaptchaForm;
 
 @Component 
 private KaptchaImage kaptchaImage;
 
 @Component(parameters = {value=inputValue,image=kaptchaImage})
 private KaptchaField kaptchaComponent;
 
 public boolean onValidateForm()
 {
 boolean goodValidation = true;
 
 if (!inputValue)
 {
 kaptchaForm.recordError(kaptcha value not equals the 
 user input!);
 goodValidation = false;
 }
 
 return goodValidation;
 }
 
 }
 
 Any help/examples would be much appreciated.
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/kaptcha-tp5013121p5013121.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 
 



Re: kaptcha

2011-11-22 Thread captain_rhino
Where do i get the tapestry-kaptcha module  from?

Is there a maven repository.

Thanks for all help so far.

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/kaptcha-tp5013121p5013697.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha

2011-11-22 Thread captain_rhino
Is there a maven dependency for tapestry-kaptcha module or is there some
other way I can build it?

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/kaptcha-tp5013121p5014170.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha

2011-11-22 Thread Geoff Callender
http://repo1.maven.org/maven2/org/apache/tapestry/tapestry-kaptcha/5.3/tapestry-kaptcha-5.3.jar

I've been assuming you're using T5.3. I don't know whether the above jar would 
work with an earlier version of Tapestry.


On 23/11/2011, at 1:35 AM, captain_rhino wrote:

 Where do i get the tapestry-kaptcha module  from?
 
 Is there a maven repository.
 
 Thanks for all help so far.
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/kaptcha-tp5013121p5013697.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 



[T5.3-beta-9] Using tapestry-beanvalidator and tapestry-kaptcha together results in circular dependency

2011-09-19 Thread nillehammer
Hi List,
I don't know whether this belongs here. I have recently introduced
tapestry-kaptcha into one of my forms using tapestry-beanvalidator as well.
Loading the page containing that form I get a circular depenency warning:
WARN services.TapestryModule.MarkupRenderer Unable to add 'KaptchaAssets' as
a dependency of 'BeanValidatorScript', as that forms a dependency cycle
('BeanValidatorScript' depends on itself via 'KaptchaAssets'). The
dependency has been ignored.

The validation seems to work anyway. As long as I input invalid values, the
correct messages are displayed. But when finally inputting valid values I
get an Exception after submit:
ERROR tapestry5.ioc.Registry A JSONArray text must start with '[' at
character 0 of

I do not know, whether this culd be my fault. So I thought I'd ask here
before filing a JIRA.

Thanks nillehammer



-
http://www.winfonet.eu
--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/T5-3-beta-9-Using-tapestry-beanvalidator-and-tapestry-kaptcha-together-results-in-circular-dependency-tp4820243p4820243.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha + tapestry5

2010-01-28 Thread Geoff Callender
Alternatively, use Chenillekit's Kaptcha component.  It works for me.

myPage.tml:

t:chenillekit.Kaptcha t:id=kaptcha t:value=kaptchaCorrect/

myPage.java:

import org.chenillekit.tapestry.core.components.Kaptcha;
...

@Property
private boolean _kaptchaCorrect;
...
@Component(id = kaptcha)
private Kaptcha _kaptchaField;
...
void onValidateForm() {
...
if (!_kaptchaCorrect) {
_form.recordError(_kaptchaField, 
getMessages().format(Kaptcha_incorrect));
return;
}
...
}

app.properties:

Kaptcha_incorrect=The code has not been entered correctly. Please try 
again.

See 
http://chenillekit.codehaus.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/components/Kaptcha.html
 .

If you're using Ant, then here's how to get the jars, where ${maven.repo.root} 
is typically http://repo1.maven.org/maven2:

get dest=${lib.compile.dir}/chenillekit-core-1.2.0.jar usetimestamp=true 
src=${maven.repo.root}/org/chenillekit/chenillekit-core/1.2.0/chenillekit-core-1.2.0.jar
 /
get dest=${lib.compile.dir}/chenillekit-image-1.2.0.jar usetimestamp=true 
src=${maven.repo.root}/org/chenillekit/chenillekit-image/1.2.0/chenillekit-image-1.2.0.jar
 /
get dest=${lib.compile.dir}/chenillekit-tapestry-1.2.0.jar 
usetimestamp=true 
src=${maven.repo.root}/org/chenillekit/chenillekit-tapestry/1.2.0/chenillekit-tapestry-1.2.0.jar
 /

Cheers,

Geoff
http://jumpstart.doublenegative.com.au:8080/jumpstart/


On 28/01/2010, at 3:39 AM, Rafa88 wrote:

 
 
 
 Thiago H. de Paula Figueiredo wrote:
 
 On Wed, 27 Jan 2010 14:14:22 -0200, Rafa88 geli...@hotmail.com wrote:
 
 HEllo,
 
 Hi!
 
 I´m trying to insert kaptcha with tapestry with rcaptcha.net but I don´t
 know how to do... Some help?
 
 Take a look at  
 http://tapestryjava.blogspot.com/2009/12/tapestry-and-kaptcha.html.
 
 
 Ok, thanks, I´m trying this example but I don´t understand because it
 doesn´t work.
 I have include the jar file, I have created the two classes but it doesn´t
 work when I call to
 
 t:kaptchaimage t:id=kaptcha/
  br/
  t:kaptchafield image=kaptcha/
 
 in my file.tml, how the file.java would be??
 
 Thanks
 
 
 
 -- 
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
 and instructor
 Owner, software architect and developer, Ars Machina Tecnologia da  
 Informação Ltda.
 http://www.arsmachina.com.br
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
 
 
 -- 
 View this message in context: 
 http://old.nabble.com/kaptcha-%2B-tapestry5-tp27342207p27342668.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 



kaptcha + tapestry5

2010-01-27 Thread Rafa88

HEllo,
I´m trying to insert kaptcha with tapestry with rcaptcha.net but I don´t
know how to do...
Some help?

Thanks
-- 
View this message in context: 
http://old.nabble.com/kaptcha-%2B-tapestry5-tp27342207p27342207.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha + tapestry5

2010-01-27 Thread Thiago H. de Paula Figueiredo

On Wed, 27 Jan 2010 14:14:22 -0200, Rafa88 geli...@hotmail.com wrote:


HEllo,


Hi!


I´m trying to insert kaptcha with tapestry with rcaptcha.net but I don´t
know how to do... Some help?


Take a look at  
http://tapestryjava.blogspot.com/2009/12/tapestry-and-kaptcha.html.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: kaptcha + tapestry5

2010-01-27 Thread Rafa88



Thiago H. de Paula Figueiredo wrote:
 
 On Wed, 27 Jan 2010 14:14:22 -0200, Rafa88 geli...@hotmail.com wrote:
 
 HEllo,
 
 Hi!
 
 I´m trying to insert kaptcha with tapestry with rcaptcha.net but I don´t
 know how to do... Some help?
 
 Take a look at  
 http://tapestryjava.blogspot.com/2009/12/tapestry-and-kaptcha.html.
 
 
 Ok, thanks, I´m trying this example but I don´t understand because it
 doesn´t work.
 I have include the jar file, I have created the two classes but it doesn´t
 work when I call to
 
  t:kaptchaimage t:id=kaptcha/
   br/
   t:kaptchafield image=kaptcha/
 
 in my file.tml, how the file.java would be??
 
 Thanks
 
 
 
 -- 
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
 and instructor
 Owner, software architect and developer, Ars Machina Tecnologia da  
 Informação Ltda.
 http://www.arsmachina.com.br
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
 

-- 
View this message in context: 
http://old.nabble.com/kaptcha-%2B-tapestry5-tp27342207p27342668.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



[Tapestry Central] Tapestry and Kaptcha

2009-12-03 Thread Howard
Another bit of interesting work I did, for another client, was to
implement a CAPTCHA system. I chose the library Kaptcha and built
services and components around it.
If you follow the documentation for Katpcha, you'll see that you're
supposed to configure it inside web.xml and add a servlet. That's not
the Tapestry way, especially for something that will likely be split
off into its own library at some point and there's no reason that all
the necessary plumbing can't occur within the context of Tapestry's
APIs.
The essence of a CAPTCHA is two fold: first, a secret string is
generated on the server side. On the client-side, an image and a text
field are displayed. The image is a distorted version of the secret
text. The user must type the text ... humans being better able to pull
meaning out of the distortion than any typical program.
Back on the server side, we compare what the user entered against the
secret string.
I broke the implementation up into three pieces:
- A Tapestry service to handle generating the secret string and the
image
- A Tapestry component to display the image
- A second component to handle the text field
In practice, all it takes to use this is the following:
t:kaptchaimage t:id=kaptcha/ br/ t:kaptchafield image=kaptcha/

The two components work together to select the secret word, display the
image, and validate that the user has entered the expected value.
Let's look at how this all comes together. KaptchaProducer Service
Kaptcha includes an interface, Producer, that has most of what I want:
package com.google.code.kaptcha; import
java.awt.image.BufferedImage; /** * Responsible for creating captcha
image with a text drawn on it. */ public interface Producer { /** *
Create an image which will have written a distorted text. * * @param
text * the distorted characters * @return image with the text */
BufferedImage createImage(String text); /** * @return the text to be
drawn */ String createText(); }

I extended this to add methods for determining the width and height of
the captcha image:
package com.myclient.services.kaptcha; import
com.google.code.kaptcha.Producer; /** * Extension of KatpchaProducer
that exposes the images width and height (in * pixels). * */ public
interface KaptchaProducer extends Producer { int getWidth(); int
getHeight(); }

My implementation is largely a wrapper around Kaptcha's default
implementation:
package com.myclient.services.kaptcha; import
java.awt.image.BufferedImage; import java.util.Map; import
java.util.Properties; import
com.google.code.kaptcha.impl.DefaultKaptcha; import
com.google.code.kaptcha.util.Config; public class KaptchaProducerImpl
implements KaptchaProducer { private final DefaultKaptcha producer;
private final int height; private final int width; public
KaptchaProducerImpl(MapString, String configuration) { producer = new
DefaultKaptcha(); Config config = new
Config(toProperties(configuration)); producer.setConfig(config); height
= config.getHeight(); width = config.getWidth(); } public int
getHeight() { return height; } public int getWidth() { return width; }
public BufferedImage createImage(String text) { return
producer.createImage(text); } public String createText() { return
producer.createText(); } private static Properties
toProperties(MapString, String map) { Properties result = new
Properties(); for (String key : map.keySet()) { result.put(key,
map.get(key)); } return result; } }

What's all the business with the MapString, String configuration?
That's a Tapestry IoC mapped configuration, that allows us to extend
the configuration of the Kaptcha Producer ... say, to change the width
or height or color scheme.
Note that this way my choice, to have a centralized text and image
producer, so that all CAPTCHAs in the application would have a uniform
look and feel. Another alterntiave would have been to have the
KaptchaImage component (described shortly) have its own instance of
DefaultKaptcha, with parameters to control its configuration.
KaptchaImage Component
So with this service in place, how do we generate the image? This is
done in three steps:
- Selecting a secret word and storing it persistently in the session
- Rendering an img element, including a src attribute
- Providing an image byte stream when asked by the browser
package com.myclient.components; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.OutputStream; import
javax.imageio.ImageIO; import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.Link; import
org.apache.tapestry5.MarkupWriter; import
org.apache.tapestry5.annotations.Persist; import
org.apache.tapestry5.annotations.SupportsInformalParameters; import
org.apache.tapestry5.ioc.annotations.Inject; import
org.apache.tapestry5.services.Response; import
com.myclient.services.kaptcha.KaptchaProducer; /** * Part of a Captcha
based authentication scheme; a KaptchaImage generates a new * text
image whenever it renders and can provide the previously * rendred text