ajax - Conflict when pagination between clientRows and rows -


i have developed extendeddatamodel supports pagination on server side (by querying db). works expected, pagination occurs , works fine. but, @ same time, want load data of each page in client side ajax, set clientrows property extendeddatatable, , not rows attribute divides each logical page. in general, want able set clientrows < rows, pagination + ajax loading in each page. but, @ moment works when set clientrows=rows isn´t need.

what happening right if set clientrows attribute, walk method recieves range goes clientrows rows, , ignores row attribute completely. if dont set clientrows, row attribute passed (ok!) range limit (totalrows). don´t know if helps.

i post relevant code below.

the paginationdatamodel follows:

public abstract class paginationdatamodel<t> extends extendeddatamodel<t> {  private sequencerange cachedrange; private integer cachedrowcount; private list<t> cachedlist; private object rowkey;  /**  *   * @param firstrow  * @param numrows  * @return  */ public abstract list<t> getdatalist(int firstrow, int numrows); public abstract object getkey(t t); public abstract int gettotalcount();  @override public void walk(facescontext ctx, datavisitor dv, range range, object argument) {      sequencerange sr = (sequencerange) range;      if (cachedlist == null || !equalranges(cachedrange, sr)) {         cachedlist = getdatalist(sr.getfirstrow(), sr.getrows());         cachedrange = sr;     }      (t t : cachedlist) {         if (getkey(t) == null) {             /*             * 2nd param used build client id of table             * row, i.e. mytable:234:inputname, don't let null.             */             throw new illegalstateexception("found null key");         }         dv.process(ctx, getkey(t), argument);     }  }  /* * rowkey id getkey, presumably obtained * dv.process(...). */ @override public void setrowkey(object rowkey) {     this.rowkey = rowkey; }  @override public object getrowkey() {     return rowkey; }  @override public boolean isrowavailable() {     return (getrowdata() != null); }  @override public int getrowcount() {     if (cachedrowcount == null) {         cachedrowcount = gettotalcount();     }     return cachedrowcount; }  @override public t getrowdata() {     (t t : cachedlist) {         if (getkey(t).equals(this.getrowkey())) {             return t;         }     }     return null; }  protected static boolean equalranges(sequencerange range1, sequencerange range2) {     if (range1 == null || range2 == null) {         return range1 == null && range2 == null;     } else {         return range1.getfirstrow() == range2.getfirstrow() && range1.getrows() == range2.getrows();     } }  /* * get/setrowindex used when doing multiple select in * extendeddatatable, apparently. not tested. actually, method * used when using iterationstatusvar="it" & #{it.index}. */ @override public int getrowindex() {     if (cachedlist != null) {         listiterator<t> = cachedlist.listiterator();         while (it.hasnext()) {             t t = it.next();             if (getkey(t).equals(this.getrowkey())) {                 return it.previousindex() + cachedrange.getfirstrow();             }         }     }     return -1; }  @override public void setrowindex(int rowindex) {     int upperbound = cachedrange.getfirstrow() + cachedrange.getrows();     if (rowindex >= cachedrange.getfirstrow() && rowindex < upperbound) {         int index = rowindex % cachedrange.getrows();         t t = cachedlist.get(index);         setrowkey(getkey(t));     } }  @override public object getwrappeddata() {     throw new unsupportedoperationexception("not supported yet."); }  @override public void setwrappeddata(object data) {     throw new unsupportedoperationexception("not supported yet.");  }  public list<t> getcachedlist() {     return cachedlist; } } 

and extendeddatatable datascroller:

<rich:panel id="idpanel"> <rich:extendeddatatable value="#{somebean.somemodel}" id="tableid"    selectionmode="#{somebean.selectionmode}" selection="#{somebean.selection}"  rows = "20" clientrows="#{somebean.clientrows}" var="someitem" style="height:300px;">    <a4j:ajax execute="idpanel" event="selectionchange" listener="# {somebean.selectionlistener}" render="@none" />   columns , more columns...    <f:facet name="footer"><rich:datascroller for="tableid" page="#{somebean.currentpage}"  /></f:facet>  </rich:extendeddatatable> </rich:panel> 

thank , excuse english! :)


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -