Vrai pagination d'un rich:datatable avec un rich:datascroller
Salut.
J'ai eut une belle surprise avec richfaces:
J' utilisais la pagination avec richfaces en utilisant les composants datatable et datascroller simplement (ou betement je sais pas).
un truc qui simplifié donne genre:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
@Entity
public class MyLog implements Serializable{
private static final long serialVersionUID = -4235759150267631L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID", unique = true)
private Long id;
private int httpStatus;
private boolean checkStringStatus;
private String url;
// getter and setter
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
<rich:dataTable value="#{myLogList.resultList}" var="log" rows="20" id="simpletable">
<f:facet name="header">
<rich:columnGroup>
<rich:column >
<h:outputText value="ID" />
</rich:column>
<rich:column>
<h:outputText value="Http Status" />
</rich:column>
<rich:column>
<h:outputText value="Is Checked" />
</rich:column>
<rich:column>
<h:outputText value="URL" />
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:column>
<h:outputText value="#{log.id}" />
</rich:column>
<rich:column>
<h:outputText value="#{log.httpStatus}" />
</rich:column>
<rich:column>
<h:outputText value="#{log.checkStringStatus}" />
</rich:column>
<rich:column>
<h:outputText value="#{log.url}" />
</rich:column>
</rich:dataTable>
<rich:spacer height="10" />
<rich:datascroller for="simpletable" maxPages="10" renderIfSinglePage="false" /> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
@Name("myLogList")
public class MyLogList extends EntityQuery<MyLog> {
private static final long serialVersionUID = 3565361771593939734L;
private static final String EJBQL = "SELECT l FROM MyLog l";
public MyLogList() {
setEjbql(EJBQL);
}
} |
bien en faite ca fait de la fausse pagination.
Il fait un select de toute la table :aie: et la ramene dans son backingbean et fait le trie apres...