2 Replies Latest reply on Jan 19, 2009 2:24 PM by ssilvert

    rich:dataTable updated with ajax is never fill with the new

    jadtn

      Hi,
      I've a problem i don't well understand.
      My page is for manage my partenaires: a table display the list detailed of my partenaires, some fields under the table to modify/add/update partenaire, buttons for modifications

      4 main components of the page:
      -a rich:dataTable wich contains all of my 'partenaires', each row is the detail of a partenaire
      -a zone with fields for partenaire modification
      -a button preview : before modify, add,delete, you must click on preview (this is for a visual check)
      - buttons add/update/delete which rendered when the button preview have been clicked

      Under browser all works, when i fill the field for create a new partenaire, i click preview, the button add appear and i click on it => the table is rerendered and the new partenaire appear as a new row, i test manual all comportement of my page and all is ok :-).

      [in firefox] Just after add a partenaire in the table I look at the page source, and the new row isn t in the source code !? I think this is because it s ajax, and when the content of a page is modified, the source in the browser isn t updated?

      In my jsfunit test, i think i have the same problem, i ve never the new row when i check on client or server side!

      Is someone have an idea?

      Thanks



      public void testAddPartenaire() throws Exception {
       //this test add a a partenaire
       //the partenaire list is empty
      
       boolean actif=true;
       boolean onIndex=true;
       short classement=5;
       short note=3;
       //String detail="bla l'aç";
       String detail="Ah";
       String email="somebody@hotmail.com";
       String url=urls[0];
       // svpartenaires:mp:t:0:edit first button edit in the table
       //set the values to add new partenaire
       setFieldsPartenairesValues(actif, onIndex, classement, note, detail,email, url);
      
       // we have to click on preview for the button add is rendered for a visual check
       client.click(FieldsAdmPartenaires.BUTTON_AJAX_PREVIEW);
       //visual check is ok, we add the new partenaire
       client.click(FieldsAdmPartenaires.BUTTON_AJAX_ADD);
      
       //a new row must appear in the table
       HtmlOutputText c = (HtmlOutputText) server.findComponent(FieldsAdmPartenaires.TABLE_PATERN+"0:url");
      
       assertEquals(url, c.getValue()+"");//-->>>> HERE ALWAYS NULL
      
       }
      
       //Fill the fields form
       private void setFieldsPartenairesValues(boolean actif, boolean onIndex,
       short classement, short note, String detail, String email,
       String url) {
       client.setValue(FieldsAdmPartenaires.F_URL, url);//FieldsAdmPartenaires.F_URL = svpartenaires:mp:url
       client.setValue(FieldsAdmPartenaires.F_CHECKBOX_ACTIF, Boolean.toString(actif));//etc..
       client.setValue(FieldsAdmPartenaires.F_EMAIL, email);
       client.setValue(FieldsAdmPartenaires.F_CHECKBOX_ON_INDEX, Boolean.toString(onIndex));
       client.setValue(FieldsAdmPartenaires.F_CLASSEMENT, String.valueOf(classement));
       client.setValue(FieldsAdmPartenaires.F_NOTE, String.valueOf(note));
       client.setValue(FieldsAdmPartenaires.F_AREA_DETAIL, detail);
       }
      




      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       >
      <f:subview id="svpartenaires">
       <rich:panel header="gestion des partenaires (page partenaire)">
       <h4></h4>
       <a4j:form id="mp"> <a4j:keepAlive beanName="ctrlAdminPartenaires" />
       <rich:dataTable id="t" value="#{ctrlAdminPartenaires.partenaires}" var="p" width="300px" columnClasses="center"
       rows="15" reRender="ds" >
       <f:facet name="header">
       <h:outputText value="Partenaires"/>
       </f:facet>
       <rich:column >
       <f:facet name="header">
       <h:outputText value="Edit" />
       </f:facet>
       <a4j:commandButton id="edit" value="Edit" action="#{ctrlAdminPartenaires.editRow}" reRender="mp">
       <f:param id="p" name="id" value="#{p.url}"/>
       </a4j:commandButton>
      
       </rich:column>
       <rich:column sortBy="#{p.url}">
       <f:facet name="header">
       <h:outputText value="url"/>
       </f:facet>
       <h:outputText id="url" value="#{p.url}" />
       </rich:column>
       <rich:column sortBy="#{p.actif}">
       <f:facet name="header">
       <h:outputText value="Actif"/>
       </f:facet>
       <h:selectBooleanCheckbox id="actif" value="#{p.actif}" disabled="true" />
      
       </rich:column>
       <rich:column sortBy="#{p.onIndex}">
       <f:facet name="header">
       <h:outputText value="Sur page index"/>
       </f:facet>
       <h:selectBooleanCheckbox id="onindex" value="#{p.onIndex}" disabled="true" />
       </rich:column>
       <rich:column sortBy="#{p.note}" >
       <f:facet name="header">
       <h:outputText value="note"/>
       </f:facet>
       <h:outputText id="note" value="#{p.note}"/>
       </rich:column>
       <rich:column sortBy="#{p.classementLorizon}">
       <f:facet name="header" sortBy="#{p.classementLorizon}">
       <h:outputText value="classement de lorizon sur leur page"/>
       </f:facet>
       <h:outputText id="classement" value="#{p.classementLorizon}"/>
       </rich:column>
       <rich:column>
       <f:facet name="header" >
       <h:outputText value="email"/>
       </f:facet>
       <h:outputText id="email" value="#{p.email}"/>
       </rich:column>
       <rich:column>
       <f:facet name="header" sortBy="#{p.detail}">
       <h:outputText value="detail"/>
       </f:facet>
       <h:outputText id="detail" value="#{p.detail}"/>
       </rich:column>
       <f:facet name="footer">
       <rich:datascroller id="ds"></rich:datascroller>
       </f:facet>
       </rich:dataTable>
      
       <h:panelGrid columns="2">
       <h:outputLabel value="URL" for="url" /> <h:inputText id="url" value="#{ctrlAdminPartenaires.url}" />
       <h:outputLabel value="Est sur la page index de lorizon" for="index" />
       <h:selectBooleanCheckbox id="index" value="#{ctrlAdminPartenaires.onIndex}"/>
       <h:outputLabel value="actif (si inactif, non visible)" for="actif" />
       <h:selectBooleanCheckbox id="actif" value="#{ctrlAdminPartenaires.actif}"/>
       <h:outputLabel value="Note" for="note" /><h:inputText id="note" value="#{ctrlAdminPartenaires.note}" />
       <h:outputLabel value="Classement lorizon " for="classementSite" /><h:inputText id="classementSite" value="#{ctrlAdminPartenaires.classementLorizon}" />
       <h:outputLabel value="Email" for="email" /><h:inputText id="email" value="#{ctrlAdminPartenaires.email}" />
       </h:panelGrid>
       <h:inputTextarea id="detail" value="#{ctrlAdminPartenaires.detail}" rows="10" cols="50"/> <br/>
       <h:messages id="errors" styleClass="error" />
       <a4j:commandButton action="#{ctrlAdminPartenaires.reset}" value="reset" reRender="mp" />
      
       <a4j:commandButton id="preview" action="#{ctrlAdminPartenaires.preview}" value="Preview" reRender="mp" />
       <a4j:commandButton id="update" action="#{ctrlAdminPartenaires.update}" rendered="#{ctrlAdminPartenaires.preview}" value="Update" reRender="mp" />
       <a4j:commandButton id="add" action="#{ctrlAdminPartenaires.add}" rendered="#{ctrlAdminPartenaires.preview}" value="Ajouter" reRender="mp" />
       <a4j:commandButton id="delete" action="#{ctrlAdminPartenaires.delete}" rendered="#{ctrlAdminPartenaires.preview}" value="Delete" reRender="mp" />
       <a4j:status startText=" Chargement en cours..." startStyle="color:orange" stopStyle="color:purple" stopText=" Chargement terminé." />
      
       <h:panelGrid columns="3" width="90%">
       <h:outputText value="#{ctrlAdminPartenaires.url}" />
       <h:graphicImage value="#{ctrlAdminPartenaires.urlScreenShot}" />
       <h:outputText value="#{ctrlAdminPartenaires.detail}"/> <h:outputText value="#{ctrlAdminPartenaires.note}"/>
       </h:panelGrid>
       </a4j:form>
       </rich:panel>
       </f:subview>
      </ui:composition>