0

Edited

I want to display a scrollable table with 40 columns and 1000 rows.

I used rich:extendedDataTable (I'm using richfaces 4) with clientRows="20", but I get a table with 20 rows and when I scroll, just this rows are updated and I didn't get new rows!

enter image description here

xHTML

            <rich:extendedDataTable id="idList"
                value="#{declarationReglementaireModel.detailCurrentDecReg.decReg.listLigneTa3SDTO}"
                var="ligneTA3" frozenColumns="2" style="height:300px; width:800px;"
                selectionMode="none" clientRows="15">

                <rich:column width="35px">
                    <h:panelGrid columns="1" cellpadding="2">
                        <h:commandLink action="#{rechercheDecRgltCtrl.afficherDetail}"
                            class="lien_detail">
                            <span class="icone icone-edit icone-align-center" />
                            <f:setPropertyActionListener
                                target="#{declarationReglementaireModel.detailCurrentDecReg.decReg.listLigneTa3SDTO}"
                                value="#{ligneTA3}" />
                        </h:commandLink>
                    </h:panelGrid>
                </rich:column>
                <rich:column width="150px" sortBy="#{ligneTA3.idTitre}"
                    sortOrder="ascending">
                    <f:facet name="header">Référence Titre</f:facet>
                    <h:outputText value="#{ligneTA3.idTitre}">
                    </h:outputText>
                </rich:column>
                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="a" />
                    </f:facet>
                    <h:outputText value="#{ligneTA3.vlColA}">
                    </h:outputText>
                </rich:column>
...
</rich:extendedDataTable>

Model DeclarationReglementaireModel

@ManagedBean(name="declarationReglementaireModel")
@SessionScoped
public class DeclarationReglementaireModel implements Serializable {
private static final long serialVersionUID = 1L;


private long test ;
private LigneDecRegSortieDTO currentDecReg ;
private List<LigneDecRegSortieDTO> listDecReg ;
private DetailDecRegModel detailCurrentDecReg ;
private Integer selectedPage; 


public LigneDecRegSortieDTO getCurrentDecReg() {
    return currentDecReg;
}

public void setCurrentDecReg(LigneDecRegSortieDTO currentDecReg) {
    this.currentDecReg = currentDecReg;
}

public List<LigneDecRegSortieDTO> getListDecReg() {
    if(this.listDecReg == null){
        this.listDecReg = new ArrayList<LigneDecRegSortieDTO>() ;
    }
    return listDecReg;
}

public void setListDecReg(List<LigneDecRegSortieDTO> listDecReg) {
    this.listDecReg = listDecReg;
}

public long getTest() {
    return test;
}

public DetailDecRegModel getDetailCurrentDecReg() {
    return detailCurrentDecReg;
}

public void setDetailCurrentDecReg(DetailDecRegModel detailCurrentDecReg) {
    this.detailCurrentDecReg = detailCurrentDecReg;
}

public void setTest(long test) {
    this.test = test;
}

public void init(){
    listDecReg = null ;
    currentDecReg = null ;
    detailCurrentDecReg = null ;
    this.selectedPage = null ;
}

public Integer getSelectedPage() {
    if (this.selectedPage == null)
        this.selectedPage =  1;
    return this.selectedPage;
}

public void setselectedPage(Integer numPage) {
    this.selectedPage = numPage;
}


}

Model DetailDecRegModel

public class DetailDecRegModel implements Serializable {
private static final long serialVersionUID = 1L;

private DecRegDTO decReg ;
private TypeDecRegDTO typeDecReg ;
private int nbreLignes ;


public static final int DIR_IRREG = 1 ;
public static final int GLD_CLA = 2 ;
public static final int GLD_PERIODE = 3 ;
public static final int TAB_A3 = 4 ;
public static final int TAB_A3_BIS = 5 ;
public static final int DIR_AUTRES = 6 ;

public DetailDecRegModel() {
    super();
}

public DetailDecRegModel(DecRegDTO detailCurrentDecReg,
        TypeDecRegDTO typeDecReg) {
    super();
    this.decReg = detailCurrentDecReg;
    this.typeDecReg = typeDecReg;
}


public DecRegDTO getDecReg() {
    return decReg;
}


public void setDecReg(DecRegDTO decReg) {
    this.decReg = decReg;
}


public TypeDecRegDTO getTypeDecReg() {
    return typeDecReg;
}
public void setTypeDecReg(TypeDecRegDTO typeDecReg) {
    this.typeDecReg = typeDecReg;
}

public int getNbreLignes() {
    switch ((int)getTypeDecReg().getIdTypeDecReg()){
    case DIR_IRREG:
        this.nbreLignes = decReg.getListLigneDipRecsDTO().size() ;
        break;
    case GLD_CLA:
        this.nbreLignes = decReg.getListLigneGldsDTO().size() ;
        break;
    case GLD_PERIODE:
        this.nbreLignes = decReg.getListLigneGldsDTO().size() ;
        break;
    case TAB_A3:
        this.nbreLignes = decReg.getListLigneTa3SDTO().size();
        break;
    case TAB_A3_BIS:
        this.nbreLignes = decReg.getListLigneTa3SDTO().size();
        break;          
    case DIR_AUTRES:
        this.nbreLignes = decReg.getListLigneDipRecsDTO().size() ;
        break;
    }

    return nbreLignes;
}

public void setNbreLignes(int nbreLignes) {
    this.nbreLignes = nbreLignes;
}

//public boolean isDecRegTypeDipRec(){
public boolean isDecRegTypeDirIrreg(){
    return typeDecReg != null && (int)typeDecReg.getIdTypeDecReg() == DIR_IRREG ;
}

public boolean isDecRegTypeDirAutres(){
    return typeDecReg != null && (int)typeDecReg.getIdTypeDecReg() == DIR_AUTRES ;
}

public boolean isDecRegTypeGldPer(){
    return typeDecReg != null && (int)typeDecReg.getIdTypeDecReg() == GLD_PERIODE ;
}

public boolean isDecRegTypeGldCla(){
    return typeDecReg != null && (int)typeDecReg.getIdTypeDecReg() == GLD_CLA ;
}

public boolean isDecRegTypeTabA3(){
    return typeDecReg != null && (int)typeDecReg.getIdTypeDecReg() == TAB_A3 ;
}
public boolean isDecRegTypeTabA3Bis(){
    return typeDecReg != null && (int)typeDecReg.getIdTypeDecReg() == TAB_A3_BIS ;
}

}
Netmaster
  • 287
  • 1
  • 10
  • 27
  • 1000 rows and no pagination? Really? – Luiggi Mendoza May 31 '13 at 14:29
  • Good luck with your bad design... – Luiggi Mendoza May 31 '13 at 14:32
  • @LuiggiMendoza do you have any suggestion? it's the client demand! – Netmaster May 31 '13 at 14:34
  • @LuiggiMendoza I can't do it with live scrolling? – Netmaster May 31 '13 at 14:35
  • Live scrolling is not related to ``. I guess you should start by defining what you really want/need. If you expect live scroll, you can check [``](http://showcase.omnifaces.org/components/componentIdParam) to load values on a form submit, and mix this with the answer provided here: [How to check if a user has scrolled to the bottom](http://stackoverflow.com/q/3898130/1065197). No rocket science. – Luiggi Mendoza May 31 '13 at 14:43
  • I nedd a data table with 40 columns and 1000 lignes to show in a view, I can use jsf/richfaces – Netmaster May 31 '13 at 14:46
  • You can use `` and build the HTML `` by yourself. Have you tried anything to begin with? No? Then do something, then come back when you have a specific solvable problem.
    – Luiggi Mendoza May 31 '13 at 14:48
  • I tried to do it with `rich:extendedDataTable` but with huge data, it doesen't work, I founded `rich:scrollableDataTable` but it's for richfaces 3.3, and now I'm doing it with html, and I hope it'll works, thank you! – Netmaster May 31 '13 at 14:51

1 Answers1

1

Set the clientRows attribute on your <rich:extendedDataTable/> to specify the initial number of rows to be loaded to the client on initial page load. Subsequent scrolls of the same data table will increment the rows available using the same number.

     <rich:extendedDataTable value="#{bean.items}" clientRows="15"/>

This usage presupposes that the entirety of the dataset has been loaded on the server side.

If you need even finer-grained control of the dataloading on the server side, you should implement an ExtendedDataModel to take control of the dataloading.

Related:

Community
  • 1
  • 1
kolossus
  • 20,559
  • 3
  • 52
  • 104
  • Thank you! I inserted the clientRows="10" attribute and I got the first 10 rowsand when I scroll I see that the values of this rows are changed! – Netmaster Jun 03 '13 at 08:14
  • @Netmaster...so it works? Please accept the answer if it does :) – kolossus Jun 03 '13 at 13:14
  • @klossus it doesn't work correctly, I have just 10 rows! Please, read the edited post – Netmaster Jun 03 '13 at 13:18
  • @Netmaster, Are you sure? You did say the rows changed a couple of hours ago. And in a sample set of 1k rows, surely there'll be repeated records. `clientRows` is a very basic attribute so I'm surprised you're having problems with it. At any rate, you'll need to post more of your code. For example, have you implemented a custom datamodel? – kolossus Jun 03 '13 at 13:41
  • I said I have only just the number of elements wich is in `clientRows`. I edited the post :) – Netmaster Jun 03 '13 at 13:50
  • @Netmaster, you're implementing a custom DAO whose logic is unknown and doesn't implement any known libraries. Also not sure how why're expecting the scrolling to return different results when it's bound to an enum that appears to always return the same thing. Sorry, you're on your own there mate. Good luck – kolossus Jun 03 '13 at 15:26
  • those are Models not DAO! ... Thank you :) – Netmaster Jun 03 '13 at 15:37