4 Replies Latest reply on May 16, 2014 7:20 AM by mosesemm

    Captcha: customized message for incorrect response

    accless

      Hi folks,


      is there a better way of defining a customized message for incorrect responses than extending the superclass org.jboss.seam.captcha.Captcha and overwriting the getResponse()-Method?


      So far this works for me, but is not the most elegant solution:



      @CaptchaResponse(message="stupid, that was the wrong answer!")
          @Override 
          public String getResponse()
          {
                  
             return super.getResponse();
             
          }   
      


        • 1. Re: Captcha: customized message for incorrect response

          Not at the moment.  Vote for  JBSEAM-2929

          • 2. Re: Captcha: customized message for incorrect response
            bemar

            Hi,


            thx for that hint. I made a MyCaptcha class extending captcha with the above posted code. But where do I have do configure to take my class instead of the superclass?
            Currently only the superclass with the standard text is taken by seam.



            Thats my xhtml code


            <s:decorate id="captchaField" template="layout/edit.xhtml">
                                <ui:define name="label">#{messages.text_captcha}</ui:define>                         
                                     <h:graphicImage value="/seam/resource/captcha" />                         
                                     <h:inputText id="verifyCaptcha" value="#{captcha.response}" size="7"
                                          required="true" styleClass="text" label ="#{messages.text_captcha}">
                                          <s:validate />
                                     </h:inputText>
                                </s:decorate>



            Thx


            Ben

            • 3. Re: Captcha: customized message for incorrect response
              bemar
              • 4. Re: Captcha: customized message for incorrect response
                mosesemm

                Hi,

                 

                I couldnt get this to work on seam 2.3.

                Even after i have the message there it still show:org.jboss.seam.captcha.error

                the debug log message below does show, confirming somehow it does hit my class...So ur help will be appreciated, i am ok with the std captcha algorith the problem is just the message.

                 

                @Name("org.jboss.seam.captcha.captcha")

                @Scope(ScopeType.EVENT)

                @Install(precedence = 40) 

                @BypassInterceptors 

                public class CaptchaHelper extends Captcha {

                 

                    /**

                     *

                     */

                    private static final long serialVersionUID = 1L;

                   

                    @Logger

                    Log log;

                 

                    @CaptchaResponse(message = "Wrong answer..")

                    @Override

                    public String getResponse() {

                        log.debug("i was here");

                        return super.getResponse();

                    }

                 

                }