4 Replies Latest reply on Apr 27, 2009 4:59 PM by jbuechel

    Captcha and Ajax forms

    demetrio812

      Hi,
      I tried the example of the captcha and it worked very well in a normal form, now I have 2 problems:


      First
      I'm implementing it in an ajax way using a:commandButton to submit the form and it seems it is not working after a lot of tries, here there is the code:


           <h:form id="nuovoCommentoFrm">
                          <h:panelGrid columns="3">
                          ...
                               <h:outputText value="Control code*" />
                               <h:panelGrid id="pgCaptcha" columns="1">
                                    <h:graphicImage value="/seam/resource/captcha?f=#{currentDate.time}" />
                                    <h:inputText id="verifyCaptcha" value="#{captcha.response}" required="true">
                                         <s:validate />
                                    </h:inputText>
                               </h:panelGrid>
                               <rich:message for="verifyCaptcha" errorClass="errorMessage"/>
                          </h:panelGrid> 
                          <a:commandButton value="Add comment" action="#{articoloHelper.inserisciNuovoCommento}" reRender="pgCaptcha,nuovoCommentoFrm,frmCommenti"></a:commandButton>
                </h:form>



      Am I wronging something?


      Second
      Even with the normal form, when the form submit is done all fields are cleared but the captcha.response one. I have seen it is a session object but I would like to clear it every time the submit is done (even from inside the submit method), is it possible?


      Thanks


      Demetrio