2 Replies Latest reply on Mar 26, 2007 1:07 PM by demetrio812

    refresh problems (reRender and datascroller)

    demetrio812

      Hi, I have a table with a datascroller inside a tab:

       <rich:tab label="Sito">
       <h:form>
       <h:panelGrid columns="1">
       <h:panelGroup>
       <h:outputText value="Sezione: "></h:outputText>
       <h:selectOneMenu value="#{daoGestione.tipologiaArticoloSelezionata}">
       <f:selectItems value="#{daoGestione.tipologieArticoliText}"/>
       <a4j:support event="onchange" action="#{daoGestione.cambiaTipologia}" oncomplete="submit();" ></a4j:support>
       </h:selectOneMenu>
       </h:panelGroup>
       </h:panelGrid>
       </h:form>
       <a4j:form ajaxSubmit="true">
       <h:panelGrid id="rapg" columns="1" width="100%">
       <a4j:commandLink reRender="rapg,articoli" action="#{daoGestione.addArticolo}" rendered="#{daoGestione.tipologiaArticoloSelezionata!='1'}">
       <h:graphicImage alt="Aggiungi" title="Aggiungi" value="/templates/images/icons/insert.gif" border="0" style="vertical-align: middle"></h:graphicImage>
       <h:outputText value=" Aggiungi"></h:outputText>
       </a4j:commandLink>
       <rich:dataTable id="articoli" var="row" style="width: 100%;"
       rows="10" value="#{daoGestione.articoli}">
       <f:facet name="header">
       <h:outputText value="#{daoGestione.tipologiaArticoloSelezionataDescrizione}"></h:outputText>
       </f:facet>
       <h:column>
       <f:facet name="header">
       <h:outputText value="Oggetto"></h:outputText>
       </f:facet>
       <h:inputTextarea id="oggetto" value="#{row.oggetto}" required="true" requiredMessage="Campo obbligatorio"></h:inputTextarea>
       <br/><h:message for="oggetto" errorClass="errorMessage"></h:message>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="Data"></h:outputText>
       </f:facet>
       <h:inputText id="data" value="#{row.data}" required="true" requiredMessage="Campo obbligatorio" style="width: 80px;" converterMessage="Errore: la data è inserita in un formato scorretto. Formato corretto: gg/mm/yyyy">
       <f:convertDateTime type="date" pattern="dd/MM/yyyy" timeZone="Europe/Rome" />
       </h:inputText>
       <br/><h:message for="data" errorClass="errorMessage"></h:message>
       </h:column>
       <h:column rendered="#{daoGestione.tipologiaArticoloSelezionata=='5' or daoGestione.tipologiaArticoloSelezionata=='8'}">
       <f:facet name="header">
       <h:outputText value="Ora"></h:outputText>
       </f:facet>
       <h:inputText id="ora" value="#{row.ora}" style="width: 80px;" required="true" requiredMessage="Campo obbligatorio" converterMessage="Errore: l'ora è inserita in un formato scorretto. Formato corretto: hh:mm:ss">
      
       </h:inputText>
       <br/><h:message for="ora" errorClass="errorMessage"></h:message>
       </h:column>
       <h:column rendered="#{daoGestione.tipologiaArticoloSelezionata=='4'}">
       <f:facet name="header">
       <h:outputText value="Testata"></h:outputText>
       </f:facet>
       <h:inputText id="testata" value="#{row.libero1}" style="width: 80px;">
      
       </h:inputText>
       <br/><h:message for="testata" errorClass="errorMessage"></h:message>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="Testo"></h:outputText>
       </f:facet>
       <h:inputTextarea value="#{row.testo}" rows="10" style="width: 300px;"></h:inputTextarea>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="Parole chiave"></h:outputText>
       </f:facet>
       <h:inputText id="pchiave" value="#{row.paroleChiave}"></h:inputText>
       <br/><h:message for="pchiave" errorClass="errorMessage"></h:message>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="URL foto"></h:outputText>
       </f:facet>
       <h:inputText id="urlf" value="#{row.fileImmagine}"></h:inputText>
       <br/><h:message for="urlf" errorClass="errorMessage"></h:message>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="URL articolo"></h:outputText>
       </f:facet>
       <h:inputText id="urla" value="#{row.urlArticolo}"></h:inputText>
       <br/><h:message for="urla" errorClass="errorMessage"></h:message>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="URL video"></h:outputText>
       </f:facet>
       <h:inputText id="urlv" value="#{row.urlVideo}"></h:inputText>
       <br/><h:message for="urlv" errorClass="errorMessage"></h:message>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value=""></h:outputText>
       </f:facet>
       <a4j:commandLink reRender="rapg,articoli" action="#{daoGestione.inviaNewsletter}">
       <h:graphicImage alt="Invia newsletter" title="Invia newsletter" value="/templates/images/icons/insert.gif" border="0" style="vertical-align: middle"></h:graphicImage>
       <f:setPropertyActionListener value="#{row}" target="#{daoGestione.articolo}" />
       </a4j:commandLink>
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value=""></h:outputText>
       </f:facet>
       <a4j:commandLink reRender="rapg,articoli" action="#{daoGestione.salvaArticolo}">
       <h:graphicImage alt="Salva" title="Salva" value="/templates/images/icons/save.gif" border="0" style="vertical-align: middle"></h:graphicImage>
       <f:setPropertyActionListener value="#{row}" target="#{daoGestione.articolo}" />
       </a4j:commandLink>
       </h:column>
       <h:column rendered="#{daoGestione.tipologiaArticoloSelezionata!='1'}">
       <f:facet name="header">
       <h:outputText value=""></h:outputText>
       </f:facet>
       <a4j:commandLink reRender="rapg,articoli" onclick="if (!confirm('Sei sicuro?')) return false;" action="#{daoGestione.delArticolo}">
       <h:graphicImage alt="Elimina" title="Elimina" value="/templates/images/icons/delete.gif" border="0" style="vertical-align: middle"></h:graphicImage>
       <f:setPropertyActionListener value="#{row}" target="#{daoGestione.articolo}" />
       </a4j:commandLink>
       </h:column>
       </rich:dataTable>
       <rich:datascroller for="articoli" renderIfSinglePage="false" reRender="articoli"/>
       </h:panelGrid>
       </a4j:form>
       </rich:tab>
      


      There is a selectOneMenu on top that change the kind of data the table is showing, and the datascroller scrooling the data. I use managed bean in the session.

      I had 2 refresh problems: the first made me put the selectOneMenu inside to another form and make the whole page reload using:
      oncomplete="submit();"
      


      in a4j:support (I know I can to that with standard jsf without a4j but this is a temporary solution to make it works, I want to know why it doesn work).

      Imagine there is a reRender instead of oncomplet="submit();" and it is in the same form with an ajaxSingle="true".

      That's the problem: if I do not click on a button (like Aggiungi, or Salva) they (selectOneMenu and datascroller) works, but from the time I call the action they doesn't work anymore.

      The tabbedPane as the switch variable set to ajax.

      What can it be?

      that's an example of the action I use:

       public String salvaArticolo() {
       if (getArticolo()!=null) {
       try {
       PersistentTransaction t = LambertiPersistentManager.instance().getSession().beginTransaction();
      
       try {
       LambertiPersistentManager.instance().getSession().update(getArticolo());
      
       t.commit();
       } catch (Exception e1) {
       e1.printStackTrace();
       t.rollback();
       }
       } catch (PersistentException e1) {
       e1.printStackTrace();
       }
       }
      
       return null;
       }
      


      Hope you can help me...

      Demetrio