0
votes

We are upgrading from jsf 1.2 to jsf 2. We are using apache myfaces 2.1 and rich faces 4.3.

The issue is , it seems that <a4j:commandButton> tag AJAX feature is broken. Below is the xhtml file.

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">


    <h:form prependId="false" id="questionsForm">   

        <!-- other form fields are not shown -->
        <a4j:commandButton  id="questions" value="Clear" action="#{bean.clearAction}"/> 
    </h:form>

</html> 

When the "clear" button is clicked , back end code executes but an entire page reload happens (page refreshes again). Pre-migration code works perfectly fine with no page reload.

Can anyone please help in how to get this AJAX work in rich faces tags ?

1

1 Answers

2
votes

As given attributes you have to tell a4j:commandButton,

  • which parts you want to have executed (e.g. which input fields of the current page shall be updated)
  • which parts of the page you want to have re-rendered

The first is done with the attribute execute, the last is done with the attribute render. If none of both is given, the button behaves like a traditional h:commandButton (which explains the described behaviour)

Update: Also check that the <head> and <body> tag have to be like <h:head> and <h:body> so JSF has a chance to add mandatory javascript- and css libraries.

Update: Have you double-checked your action returns void/""/null and not any forwards? (see also "a4j:commandButton makes a full page reload RichFaces 3.3.3 CR1")