3 Replies Latest reply on May 8, 2007 8:14 AM by fran.fuentes

    More things and excuse the long post

    fran.fuentes

      Some things I've found working around ajax4jsf (nothing I can't live with, but...):

      * If I use a HTML table inside a a4j:region, all the cells with JSF controls render empty. The controls are piled up after the table. If the table is positioned outside the region, everything works perfect.
      * If I send an AJAX submit with a a4j:commandX inside a a4j:form, only the oncomplete event of the a4j:command is fired (nor the a4j:form only, nor both events) BUT the reRender list of the form is used joined with the the reRender list of the command [this doesn't look like an equilibrated pattern]. Even if the command hasn't oncomplete code, the oncomplete event of the form isn't fired. It's fired only with common JSF buttons o links (I know from a previous post that a4j:form is for complicated situations, nor the usual life, but I think that I have to write this).
      * The a4j:status and it's Id: the specification of JSF doesn't state (I think) which must be the way of create an id in the html rendered, but, usually, the generated one is created joined the id of the form and the id of the control. This only happens with the status control when is inside a a4j:region. If is alone inside a h:form, it's id isn't built using the name of the form. Why an a4j:stauts must be outside a a4j:region? And why not?.
      * Also, of course, when the id of the alone status control is used in the status property of a a4j:command, I get a warning "Status component not found", BUT it works showing the state of the request sent by the button.

      This is only a list of things that I think I found. Maybe my code is wrong or my use is also wrong. Don't know.
      But I have a question: always must use an a4j:region for mark where starts and ends the controls or the zones for AJAX (using ajax4jsf)?, because I think that a lot of code or computation is done around the fact that every ajax-ed control should be inside a region, but this couldn't be true in every situation. And the developer's guide doesn't state this, giving liberty of using or not regions.

      But these are only my thoughts... thanks for reading them.

      Regards,
      Fran.

        • 1. Re: More things and excuse the long post
          fran.fuentes

          Replying myself:

          * Again about the id of a status control outside a region. Working now with two forms in a page and a status control for every form (inside every form), I get an excepcion of jsp because the same id is used twice in the page. Naturally, because the ids of the status controls are built using nor the name of the form nor the id of the control that I gave it (is "_viewRoot:status"). BTW, one of the form is a a4j:form and the other is a h:form.


          Thanks again,
          F.

          • 2. Re: More things and excuse the long post
            ilya_shaikovsky

            * If I use a HTML table inside a a4j:region, all the cells with JSF controls render empty. The controls are piled up after the table. If the table is positioned outside the region, everything works perfect.

            Check that you do not lost tbody element for the table.

            This is only a list of things that I think I found. Maybe my code is wrong or my use is also wrong. Don't know.
            But I have a question: always must use an a4j:region for mark where starts and ends the controls or the zones for AJAX (using ajax4jsf)?, because I think that a lot of code or computation is done around the fact that every ajax-ed control should be inside a region, but this couldn't be true in every situation. And the developer's guide doesn't state this, giving liberty of using or not regions.


            Region is an optionally-used component. Using region - means that you cut the tree to be decoded to the subtree nested to this region.
            Also it cut the encoding area to the subtree nested to region if you use renderRegionOnly="true"

            • 3. Re: More things and excuse the long post
              fran.fuentes

               

              ilya_shaikovsky wrote:

              Check that you do not lost tbody element for the table.

              Below is my code. It renders a table in which the only cells with some content are the ones with the "Hello" text. I'll try sorround the status component with a region or delete the full row, but it still doesn't work. It only works when I move the table outside the region region3. Any idea? BTW, the tbody element isn't mandatory in the (X)HTML definition.

              And still has problems with regions and the status control. It doesn't generate a correct id unless sorround with a a4j:region. This makes the region not a optional component, obviously. With two forms and a status control for every form with diferent id's, if they are outside regions but inside the forms, get a jsp error saying that have duplicate id (the id of the status control is not generated using the form id unless it is inside a region).

              Thoughts: as said in the developer's guide, the usual region for ajax4jsf is the full view unless there were regions that divide the view. I think that the normal region must be the form which the controls are inside, going up to the full view and down to the regions. Or maybe there is an error in the guide (How to...-> Decide what to send).

              Thanks again,
              Fran.

              <h4>Segundo formulario</h4>
               <h:outputText value="#{DosP.edades}"
               binding="#{backing_indice.fueraForm}"
               id="fueraForm"
               style="font: 14px sans"/>
               <h:form id="segundoFormulario1">
               <a4j:keepAlive beanName="DosP" ajaxOnly="false"/>
               <a4j:jsFunction binding="#{backing_indice.jsFunction11}"
               id="jsFunction11" data="#{backing_indice.valorParaJS}"
               name="InvocacionSegundoFormulario" ajaxSingle="true"
               limitToList="true"/>
               <input type="file" name="ficheroDos" id="ficheroDos"/>
               <a4j:region binding="#{backing_indice.region3}" id="region3"
               renderRegionOnly="true">
               <table cellspacing="0" cellpadding="0" border="0" width="90%">
               <tr>
               <td colspan="2" align="right">
               <a4j:status binding="#{backing_indice.estadoA1}" id="estadoA1"
               title="estadoB" forceId="false">
               <f:facet name="start">
               <h:graphicImage url="/img/book_green.gif" height="83"
               width="103"
               binding="#{backing_indice.graphicImage3}"
               id="graphicImage3"/>
               </f:facet>
               <f:facet name="stop">
               <h:graphicImage url="/img/book_red.gif" height="83"
               width="103"
               binding="#{backing_indice.graphicImage4}"
               id="graphicImage4"/>
               </f:facet>
               </a4j:status>
               </td>
               </tr>
               <tr>
               <td>
               <h:outputLabel value="Ancho"
               binding="#{backing_indice.outputLabel4}"
               id="outputLabel4"/>
               </td>
               <td>
               <a4j:region binding="#{backing_indice.region1}" id="region1">
               <h:inputText binding="#{backing_indice.altoL}" id="altoL"
               value="0">
               <f:validateDoubleRange minimum="0"/>
               </h:inputText>
               <a4j:outputPanel binding="#{backing_indice.msgAlto}"
               id="msgAlto">
               <h:message for="altoL"/>
               </a4j:outputPanel>
               </a4j:region>
               </td>
               </tr>
               <tr>
               <td>
               <h:outputLabel value="Alto"
               binding="#{backing_indice.outputLabel3}"
               id="outputLabel3"/>
               </td>
               <td>
               <a4j:region binding="#{backing_indice.region2}" id="region2">
               <h:inputText binding="#{backing_indice.anchoL}" id="anchoL"
               value="0">
               <f:validateDoubleRange minimum="0"/>
               </h:inputText>
               <a4j:outputPanel binding="#{backing_indice.msgAncho}"
               id="msgAncho">
               <h:message for="anchoL"/>
               </a4j:outputPanel>
               </a4j:region>
               </td>
               </tr>
               <tr>
               <td>
               <h:outputLabel value="Valor dentro: "
               binding="#{backing_indice.outputLabel5}"
               id="outputLabel5"/>
               </td>
               <td>
               <h:outputText value="#{DosP.edades}"
               binding="#{backing_indice.dentroRegion1}"
               id="dentroRegion1" style="font: 14px sans"/>
               </td>
               </tr>
               <tr>
               <td>
               <h:outputLabel value="Valor dentro 2: "
               binding="#{backing_indice.outputLabel6}"
               id="outputLabel6"/>
               </td>
               <td>
               <h:outputText value="#{DosP.edades}"
               binding="#{backing_indice.dentroRegion2}"
               id="dentroRegion2" style="font: 14px sans"/>
               </td>
               </tr>
               <tr>
               <td>
               <h1>Hello</h1>
               </td>
               <td>
               <h2>2 Hello</h2>
               </td>
               </tr>
               </table>
               </a4j:region>
               <a4j:commandButton binding="#{backing_indice.commandButton4}"
               id="commandButton4"
               action="#{backing_indice.comprobarValores}"
               value="Envío y comprobación de datos"
               status="estadoA1" limitToList="false"
               reRender="dentroRegion2,fueraRegion"
               oncomplete='alert(\"Completa del botón\");'/>
               <h:commandButton value="Envío y comprobación de datos (sin AJAX)"
               binding="#{backing_indice.commandButton6}"
               action="#{backing_indice.comprobarValores}"
               id="commandButton6"/>
               <h:commandButton value="Ir a la otra página"
               binding="#{backing_indice.commandButton5}"
               id="commandButton5" action="llegar"/>
               <h:outputText value="#{DosP.edades}"
               binding="#{backing_indice.fueraRegion}" id="fueraRegion"
               style="font: 14px sans"/>
               </h:form>