There is a registration form and a modal window in which the user enters a captcha, all in one HTML form. The problem is that after updating the page, the button in the window only works the second time

I tried to assign an id to the form and render it, like here http://balusc.omnifaces.org/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichContainsAnotherForm , does not work

<h:form> <h:inputText value="#{Controller.email}" /> <h:inputText value="#{Controller.password}" /> <ui:fragment rendered="#{!(Controller.needValidateCaptcha) }"> <a4j:commandButton action="#{Controller.doRegistration}" value="Зарегистрироваться"> </a4j:commandButton> </ui:fragment> <ui:fragment rendered="#{(registrationController.needValidateCaptcha) }"> <button type="button" data-toggle="modal" data-target="#Captcha" action="$('#Captcha').modal('show');">Зарегистрироваться</button> </ui:fragment> <!-- Попап --> <div class="modal" id="Captcha"> <a4j:outputPanel id="Panel"> <div class="row"> <div class="col-md-6"> <h:inputText id="regcap" value="#{Controller.captcha}"/> <ui:fragment rendered="#{Controller.captchaError}"> <h:outputText value="#{registrationController.captchaErrorMsg}" /> </ui:fragment> </div> </div> </a4j:outputPanel> <a4j:commandButton action="#{Controller.doRegistration}" value="Ok" render="registrationPanel"> </a4j:commandButton> </div> </h:form> 

    1 answer 1

    Try updating the parent element for the form. The fact that you are describing a fairly common problem and Balus wrote hundreds of answers on this topic, for example, here

    • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky