RF4: rich:dataGrid - Changing Page?
khowe May 26, 2011 6:52 PMI'm using rich:dataGrid to display > 1000 of contacts.
I attempting to build a list of letters (each an a4j:commandLink) where you click on a letter and it it takes you to the page in the table at the first instance of a Contact with that letter.
So, I thought I had it working by binding the datagrid to my bean and accessing the grid's footer and calling setPage (See function ContactMgr::changepage() below), but it only appears to be working randomly? I do know my bean functions are being called with the expected data; however, I'm guessing I'm probably not calling the RichFaces function correctly (newbie-ism).
Here's the snippets of what I'm attempting... If it isn't enough of the code, I'll be happy to post more...
Note: I've simplified to only have the commandLink for the letter "A".
I'd appreciate any help! Kind regards,
Katie
directory.xhtml-----------------------------------------------
<rich:panel>
<h:form>
<a4j:commandLink id="letter_a" ajaxSingle="true" render="table_contacts" action="#{contactMgr.changepage}" >
<f:setPropertyActionListener value="1" target="#{contactMgr.contactPage}" />
<h:outputText value="A"/>
</a4j:commandLink>
</h:form>
</rich:panel>
</rich:panel>
<rich:panel>
<h:form>
<rich:dataGrid value="#{contactMgr.contacts}" var="contact" binding="#{contactMgr.datagrid}"
ajaxKeys="#{contactMgr.rowsToUpdate}" columns="#{contactMgr.gridColumns}" elements="#{contactMgr.gridElementPerPage}"
width="600px" border="0" id="table_contacts"
>
ContactMgr.java-------------------------------------------
private ArrayList<Contact> contactList = new ArrayList<Contact>();
private int gridColumns = 3;
private int gridElementPerPage = 9;
private int contactPage = 0;
private UIDataGrid datagrid;
public void changepage() {
LogWriter.INFO("Changepage: " + this.contactPage);
Map<String, UIComponent> mFacets = datagrid.getFacets();
UIDataScroller footer = (UIDataScroller) mFacets.get("footer");
if (footer != null) {
footer.setPage(this.contactPage);
}
}
public UIDataGrid getDatagrid() {
return this.datagrid;
}
public void setDatagrid(UIDataGrid grid) {
this.datagrid = grid;
}
public int getContactPage() {
return this.contactPage;
}
public void setContactPage(int contactpage) {
this.contactPage = contactpage;
//LogWriter.INFO("set contact page: " + this.contactPage);
}