2
votes

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!

1
can you put your codes so that it will be clear. :) - Ellie Fabrero
sorry! if you need more info please tell me :-) - rodrigocprates
are you sure there is no validation error on the second form submit? - Ellie Fabrero
Ellie, I tried using immediate=true on button and it is allways called! so im sure that is an validation error which is blocking this request. the question is: how can I list validation erros at this moment? - rodrigocprates

1 Answers

1
votes

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