5 Replies Latest reply on Sep 30, 2008 2:32 PM by aparij

    Page is refreshed after each Ajax call

    aparij

      I have <rich:dataTable> and for each row I have a checkbox <h:selectBooleanCheckbox> , when I click on the checkbox it creates new Ajax request with <a4j:support> and afterwards refreshes the page, it is really annoying and for example any a4j:log I have is immediately cleared. disableDefault=true is not helping .
      How can I prevent this effect ?I know that this part of code causes it ....

      <h:selectBooleanCheckbox id="checkBoxEach" value="# {accountListController.checkedUsernames[account.username]}" immidiate="false" >
       <a4j:support event="onchange" disableDefault="true" ajaxSingle="true" >
       <a4j:actionparam name="username" value="#{account.username}" assignTo="#{accountListController.username}"/>
      </a4j:support>
      </h:selectBooleanCheckbox>


        • 1. Re: Page is refreshed after each Ajax call
          aparij

          I have also noticed a difference in how the browsers behave ,
          IE7 will not execute the first Ajax call , only when I check on second checkbox it will start executing , and it will execute for the first checked row only and then refresh the whole page.
          FF3 it will execute as expected with each "onchange" event and then refresh the page.

          • 2. Re: Page is refreshed after each Ajax call
            aparij

            I wrote a simple echo xhtml from the developer guide and it still refreshes the page..
            Is it a problem with my bean configuration ? navigation case ?

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html
             xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:c="http://java.sun.com/jstl/core"
             xmlns:a4j="http://richfaces.org/a4j"
             xmlns:rich="http://richfaces.org/rich"
             xmlns:jawr="https://jawr.dev.java.net/jsf/facelets"
            
             <ui:composition template="/account/accountLayout.xhtml">
             <ui:define name="workspace">
             <h:form id="accountsForm">
             <rich:panel header="Simple Echo" mode="ajax">
            
             <h:inputText size="50" value="#{accountBean.username}" >
            
             <a4j:support event="onkeyup" reRender="rep" disableDefault="true"/>
            
             </h:inputText>
            
             <h:outputText value="#{accountBean.username}" id="rep"/>
            
             </rich:panel>
             </h:form>
             <a4j:log id="logger2" popup="false" level="ALL" style="width: 1200px; height: 700px;"></a4j:log>
             </ui:define>
            
            
             </ui:composition>
            </html>


            • 3. Re: Page is refreshed after each Ajax call
              aparij

              Using Live Http Headers I can see that my POST header contains parameters
              that trigger the redirect to itself hence the refresh of the page.
              But why the richfaces library puts this values ?

              Ajax-Response: redirect
              Location: /account/view.jsf

              • 4. Re: Page is refreshed after each Ajax call

                Try to figure out why the session cannot be restored.

                • 5. Re: Page is refreshed after each Ajax call
                  aparij

                  Sorry , but it was problem on our side.
                  We were redirecting every POST request ( PRG pattern - Post/Redirect/Get)
                  but if before it was just fine for the JSF pages navigation , for the Ajax Post requests it caused the redirection to self...
                  Sorry again :)