2013-05-31 78 views
0

編輯與龐大的數據JSF滾動表

我想用40列和1000行顯示可滾動表。

我用rich:extendedDataTable(我使用richfaces 4)和clientRows="20",但是我得到一個有20行的表格,當我滾動時,只是這些行被更新,我沒有得到新的行!

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> 

型號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; 
} 


} 

型號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 ; 
} 

} 
+0

1000行和分頁沒有?真? –

+0

是的,用滾動 – Netmaster

+0

祝你好運與你的不好的設計... –

回答

1

設置clientRows屬性<rich:extendedDataTable/>指定要在初始頁面加載時加載到客戶端的初始行數。相同數據表的後續滾動將使用相同的數字增加可用的行。

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

此用法的前提是數據集的整體已加載到服務器端。

如果您需要在服務器端對數據加載進行更細粒度的控制,則應該實施ExtendedDataModel以控制數據加載。

相關:

+0

謝謝!我插入了clientRows =「10」屬性,我得到了前10行,當我滾動時,我發現這些行的值發生了變化! – Netmaster

+0

@Netmaster ...所以它的作品?請接受答案,如果它:) – kolossus

+0

@ klossus它不能正常工作,我只有10行!請閱讀已編輯的文章 – Netmaster