-1

The following code in my .xhtml works fine:

<h:commandButton id="btnConsultar" 
                 action="#cadastrarProponenteBean.consultarCnpj}" 
                 value="#{messages.tx_consultar}"
                 styleClass="btnAcao" />

But, when I add a4j:support:

<h:commandButton id="btnConsultar"
                 action="#{cadastrarProponenteBean.consultarCnpj}" 
                 value="#{messages.tx_consultar}"
                 styleClass="btnAcao">

    <a4j:support event="onclick" />
</h:commandButton>

the application breaks, I get strange errors, and my validation messages('getFacesContext().addMessage') are not shown.

Since I'm using a4j:support just to show a loading gif when user clicks, any advice on how to fix this problem?

I'm using JSF and RichFaces.

PS: already tried a4j:commandButton instead of h:commandButton but same problems...

Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
  • *"I get strange errors"* Good errors already represent answers in its entirety. Being unable to interpret them doesn't mean that you should ignore them and skip them from the question. Instead, copypaste them unmodified in the question. We are able to translate errors into layman's terms so you finally undestand them and can fix the cause. Of course, you can also copypaste errors in a search engine. More than often they are already explained elsewhere. Please edit your question to include the errors. – BalusC Nov 18 '15 at 07:18
  • God point, what I called strange errors: **Caused by: org.jboss.seam.core.LockTimeoutException: could not acquire lock on @Synchronized component: cadastrarProponenteBean** – Marcio Ribeiro Nov 18 '15 at 17:08

1 Answers1

1

You should use <a4j:status> similar to:

    <a4j:status id="ajaxstatus" rendered="true">
        <f:facet name="start">
            <h:panelGroup>
                <h:graphicImage value="/images/loading.gif" />
            </h:panelGroup>
        </f:facet>
        <f:facet name="stop">
        </f:facet>
    </a4j:status>

I have it in template. Loading image is displayed during any long action.

Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
  • I've tried your solution and got the following error: ` ... 47 more Caused by: java.lang.IllegalStateException: duplicate Id for a component _viewRoot:status at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:68) at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)` – Marcio Ribeiro Nov 18 '15 at 16:42
  • `duplicate Id` clearly identified that problem is with id. It looks like you already have UI component with id _ajaxstatus_ on the page. Check it and rename some if needed or fix content of `a4j:status` if it exists. In general it is not related to your problem with loading image. – Vasil Lukach Nov 18 '15 at 18:44
  • Solved with `forcedId="true"`, still doesn't work. What am I missing? ` ` – Marcio Ribeiro Nov 19 '15 at 14:10
  • It should not be part of commandButton. It usually sitting in view (I have it in template for all pages in application as part of title in one app or as independent line between menu and page content in second app) – Vasil Lukach Nov 19 '15 at 14:43