5 Replies Latest reply on Jun 7, 2008 10:30 AM by Damian Harvey

    Richfaces, a4j:include and the "refresh" button

    Maykell Frometa Newbie

      Hi, all i have a little Myfaces application that uses richfaces and a4j:include intensively. I have several pages which are included in one principal page through the a4j:include component, and the navigation between those pages is specified in the faces-config file.

      Everything works fine but when i press the "refresh" button of the browser.
      When i press the "refresh" button the application load the first page that was showed by the a4j:include component and not the actual page that is loaded by the a4j:include component. Even more when you press several times the "refresh" button the included page that is rendered by the a4j:include component change randomly between the previous pages that were loaded by a4j:include component.

      This behavior is very strange, even more because this same application previusly had the ajax4jsf jar instead of richfaces jar and everything worked ok, when i pressed the "refresh" button the a4j:include rendered the actual page it was loaded.

      There are some specific configuration i'm missing related to richfaces?
      Richfaces and Myfaces have some kind of problem related to incompatibilities between versions? (i'm using myfaces 1.1.4 and richfaces 3.1.0 or 3.1.2)

      Every suggestion will be very appreciated.
      Maykell

        • 1. Re: Richfaces, a4j:include and the
          Maykell Frometa Newbie

           

          "maykellff" wrote:
          Hi, all i have a little Myfaces application that uses richfaces and a4j:include intensively. I have several pages which are included in one principal page through the a4j:include component, and the navigation between those pages is specified in the faces-config file.

          Everything works fine but when i press the "refresh" button of the browser.
          When i press the "refresh" button the application load the first page that was showed by the a4j:include component and not the actual page that is loaded by the a4j:include component. Even more when you press several times the "refresh" button the included page that is rendered by the a4j:include component change randomly between the previous pages that were loaded by a4j:include component.

          This behavior is very strange, even more because this same application previusly had the ajax4jsf jar instead of richfaces jar and everything worked ok, when i pressed the "refresh" button the a4j:include rendered the actual page it was loaded.

          There are some specific configuration i'm missing related to richfaces?
          Richfaces and Myfaces have some kind of problem related to incompatibilities between versions? (i'm using myfaces 1.1.4 and richfaces 3.1.0 or 3.1.2)

          Every suggestion will be very appreciated.
          Maykell



          Hi all, please i really need your collaboration in this issue. Any suggestion will be very apprechiated.

          • 2. Re: Richfaces, a4j:include and the
            Pankaj Ghosh Newbie

            Is refresh button an a4j button or h:commandbutton?
            If a4j, try reRendering the include tag.

            Please paste the required code.

            Pankaj

            • 3. Re: Richfaces, a4j:include and the
              Maykell Frometa Newbie

               

              Is refresh button an a4j button or h:commandbutton?

              No,no, it is the browser's refresh button.

              Please paste the required code.



              When i try to navigate from gestionarExpedientes.xhtml to turnarExpediente.xhtml then i get the error, the application perform the navigation but underground the server rise the error, you never notice it if you don't monitor the server logs constantly.

              Here is the code:

              faces-navigation.xml
              [qoute]

              <?xml version="1.0"?>
              <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
              "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
              <faces-config>
              <navigation-rule>
              <from-view-id>/views/gestionarExpedientes.xhtml</from-view-id>
              <navigation-case>
              <from-outcome>turnarExp</from-outcome>
              <to-view-id>/views/turnarExpediente.xhtml</to-view-id>
              </navigation-case>
              </navigation-rule>
              <navigation-rule>
              <from-view-id>/views/turnarExpediente.xhtml</from-view-id>
              <navigation-case>
              <from-outcome>atrasGestExp</from-outcome>
              <to-view-id>/views/gestionarExpedientes.xhtml</to-view-id>
              </navigation-case>
              </navigation-rule>
              <navigation-rule>
              <from-view-id>/includes/content.xhtml</from-view-id>
              <navigation-case>
              <from-outcome>next</from-outcome>
              <to-view-id>/views/gestionarExpedientes.xhtml</to-view-id>
              </navigation-case>
              </navigation-rule>
              </faces-config>

              [/qoute]


              layout.xhtml

              <!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:a4j="http://richfaces.org/a4j">
              <head>
              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

              </head>
              <body>
              <div id="header">
              <ui:insert name="header">
              <ui:include src="includes/header.xhtml"/>
              </ui:insert>
              </div>
              <table border="1">
              <tr>
              <td width="200">
              <div id="left">
              <ui:insert name="navigation" >
              <ui:include src="includes/navigation.xhtml"/>
              </ui:insert>
              </div>
              </td>
              <td valign="top" width="100%">
              <div id="center">
              <ui:insert name="content">
              <!--
              <ui:include src="includes/content.xhtml"/>
              -->
              </ui:insert>
              </div>
              </td>
              </tr>
              </table>

              <div id="footer">
              <ui:insert name="footer">
              <ui:include src="includes/footer.xhtml"/>
              </ui:insert>
              </div>
              </body>
              </html>


              marcoGeneral.xhtml

              <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:a4j="http://richfaces.org/a4j"
              template="layout.xhtml">

              <ui:define name="content">
              <a4j:outputPanel id="wizard" ajaxRendered="true">
              <a4j:include id="idinclude" viewId="/views/gestionarExpedientes.xhtml"/>
              </a4j:outputPanel>
              </ui:define>
              </ui:composition>


              gestionarExpedientes.xhtml
              [qoute]
              <!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:a4j="http://richfaces.org/a4j"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core">


              <h:form>
              <a4j:commandLink id="clTurnarExp" action="turnarExp" value="Turnar Expediente" />
              </h:form>


              [/qoute]

              turnarExpediente.xhtml
              [qoute]
              <!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:a4j="http://richfaces.org/a4j"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core">

              <f:subview id="kk" >
              <h:form id="turnarExpForm">
              <h:outputLabel value="Esta es la pagina de Registro" />
              <h:panelGrid columns="2" border="2" >
              <h:outputLabel value="Numero de Expediente" for="lblNroExpediente"/>
              <h:inputText value="#{expediente.nroExpediente}" id="lblNroExpediente"></h:inputText>
              <h:outputLabel value="Tipo de acusado"/>
              <h:selectOneMenu value="#{expediente.tipoAcusado}" converter="genericselectarrayconvertidor">
              <f:selectItems value="#{expedienteFacade.tipoAcusadoRs}"/>
              </h:selectOneMenu>
              <h:outputLabel value="Fecha de turnado" rendered=""/>
              <h:inputText value="#{expediente.fechaTurnado}" id="lblFechaTurnado" rendered=""/>
              </h:panelGrid>

              <a4j:commandButton action="#{expedienteFacade.turnarExpediente}" value="Ir a ...." />
              </h:form>
              </f:subview>






              • 4. Re: Richfaces, a4j:include and the
                Maykell Frometa Newbie

                Hi all, please can you help me with this issue..?

                • 5. Re: Richfaces, a4j:include and the
                  Damian Harvey Master

                  I had a similar issue in that I wanted to navigate away from my 'wizard' and come back to the same step.

                  I solved this by using a Seam conversation scoped bean (you could use session scoped if you're not using Seam), and setting a property currentWizardView which I used to set the view-id of the wizard. Note that I had to wrap the a4j:include in an outputPanel.

                  <a:outputPanel ajaxRendered="true">
                   <a:include viewId="#{myBean.currentWizardView}"/>
                  </a:outputPanel>
                  


                  Cheers,

                  Damian.