What's missing with this code?
benjes Jun 11, 2008 11:06 AMHi,
I have a rich:dataTable which I want to scroll via a javascript function (a4j:jsFunction).
<a4j:jsFunction name="nextPage" reRender="tableID" action="#{backBean.scrollPage()}"> <a4j:actionparam name="FieldID" /> <a4j:actionparam name="pageDirection" /> </a4j:jsFunction> <a4j:commandButton value=">" onclick="nextPage('tableID','next')"/>
On the server side I have the following code:
public void scrollPage(){ log.info("FacesContext "+facesContext); Map<String, String>parameters = facesContext.getExternalContext().getRequestParameterMap(); Iterator<String> iter = parameters.keySet().iterator(); Iterator<String> iter2 = parameters.values().iterator(); while(iter.hasNext()){ log.info(iter.next()+"="+iter2.next()); } UIViewRoot root = facesContext.getViewRoot(); if(parameters.containsKey("FieldID")){ log.info("ID is "+parameters.get("FieldID")); String request = parameters.get("pageDirection"); log.info("Direction "+request); UIComponent comp = root.findComponent(parameters.get("FieldID")); if(comp instanceof UIData){ UIData data= (UIData)comp; log.info(comp.toString()); int first = data.getFirst(); int itemcount = data.getRowCount(); int pagesize = data.getRows(); log.info("first "+first+" itemcount "+itemcount); if(pagesize <=0) pagesize = itemcount; if(request.equals("next")){ first += pagesize; }else if(request.equals("prev")){ first -= pagesize; } if(first+pagesize > itemcount) first = itemcount-pagesize; if(first <0) first = 0; log.info("Setting new first "+first); data.setFirst(first); log.info("New first "+data.getFirst()); }else{ log.warn("Component not found"); } } }
That all works fine. It finds the org.richfaces.component.html.HtmlDataTable sets first to first+pagesize
but still the actual table on the client doesn't get updated. Have I missed something here.
I have checked the Ajax response and it still contains the table elements
from the first page.
Thanks
Immo