2

I would like to understand the behaviour behind a4j on Richfaces.

I have a h:form with a h:inputText and a a4j:commandButton. The button action call a method in my bean, and the oncomplete shows Richfaces.showModal with some content.

<h:form id="i_form">
    <h:inputText value="#{ordemManagedBean.formEntity.emissor.cpf}" required="true" />
    <a4j:commandButton value="#{msg.labelbtn}" reRender="f_FormordemEmissorModal" oncomplete="Richfaces.showModalPanel('ordemEmissorModal');" action="#{ordemManagedBean.consultarCadastroEmissor}" />
</h:form>

Outside h:form I have an ui:decorate that imports my Modal, which have a form around.

<ui:decorate template="/templates/ordemEmissorModal.xhtml">
        <ui:param
            name="beanForm"
            value="#{ordemManagedBean}"
/>

The problem: When I submit my form on button click, the method is fired and the modal is shown, but it works only at the first time. When I close my Modal, change the input value and submit, the method is not called and my modal is shown with the old content. What's happening in my second form submission?

Thank you in advance!

rodrigocprates
  • 498
  • 6
  • 22

1 Answers1

1

To check for validation error you can use <h:message> or <h:messages> and supply the id of your <h:inputText> on the for attribute and reRender the <h:message> when the request is fired, and since you are using richfaces there is also <rich:message> or <rich:messages>, the functionality is the same but the the later has more additional features.

<h:form id="i_form">
    <h:inputText id="input" value="#{ordemManagedBean.formEntity.emissor.cpf}" required="true" />
     <rich:message for="input" id="error" />
    <a4j:commandButton value="#{msg.labelbtn}" reRender="f_FormordemEmissorModal, error" oncomplete="Richfaces.showModalPanel('ordemEmissorModal');" action="#{ordemManagedBean.consultarCadastroEmissor}" />
</h:form>

You can also check this thread. Jsf Validation

Community
  • 1
  • 1
Ellie Fabrero
  • 791
  • 2
  • 16
  • 41