public boolean removeChild(Component child) { if (_paging == child && _pgi == child && inPagingMold()) throw new IllegalStateException( "The paging component cannot be removed manually. It is removed automatically when changing the mold"); //Feature 1906110: prevent developers from removing it accidently if (!super.removeChild(child)) return false; if (_rows == child) _rows = null; else if (_cols == child) _cols = null; else if (_frozen == child) _frozen = null; else if (_foot == child) _foot = null; else if (_paging == child) { _paging = null; if (_pgi == child) _pgi = null; } return true; }
/** Checks whether to invalidate, when a child has been added or * or will be removed. * @param bRemove if child will be removed */ private void checkInvalidateForMoved(Component child, boolean bRemove) { //No need to invalidate if //1) act == last and child in act //2) act != last and child after act //Except removing last element which in act and act has only one element final Grid grid = getGrid(); if (grid != null && grid.inPagingMold() && !isInvalidated()) { final List<Component> children = getChildren(); final int sz = children.size(), pgsz = grid.getPageSize(); int n = sz - (grid.getActivePage() + 1) * pgsz; if (n <= 0) { //must be last page n += pgsz; //check in-act (otherwise, check after-act) if (bRemove && n <= 1) { //last element, in act and remove invalidate(); return; } } else if (n > 50) n = 50; //check at most 50 items (for better performance) for (ListIterator<Component> it = children.listIterator(sz); --n >= 0 && it.hasPrevious();) if (it.previous() == child) return; //no need to invalidate invalidate(); } }
if (cmd.equals("onDataLoading")) { Events.postEvent(DataLoadingEvent.getDataLoadingEvent(request, preloadSize())); } else if (inPagingMold() && cmd.equals(ZulEvents.ON_PAGE_SIZE)) { final Map<String, Object> data = request.getData(); final int oldsize = getPageSize();
public void beforeChildAdded(Component newChild, Component refChild) { if (newChild instanceof Rows) { if (_rows != null && _rows != newChild) throw new UiException("Only one rows child is allowed: " + this + "\nNote: rows is created automatically if live data"); } else if (newChild instanceof Columns) { if (_cols != null && _cols != newChild) throw new UiException("Only one columns child is allowed: " + this); } else if (newChild instanceof Frozen) { if (_frozen != null && _frozen != newChild) throw new UiException("Only one frozen child is allowed: " + this); } else if (newChild instanceof Paging) { if (_pgi != null) throw new UiException("External paging cannot coexist with child paging"); if (_paging != null && _paging != newChild) throw new UiException("Only one paging is allowed: " + this); if (!inPagingMold()) throw new UiException("The child paging is allowed only in the paging mold"); } else if (newChild instanceof Foot) { if (_foot != null && _foot != newChild) throw new UiException("Only one foot child is allowed: " + this); } else if (!(newChild instanceof Auxhead)) { throw new UiException("Unsupported child for grid: " + newChild); } super.beforeChildAdded(newChild, refChild); }
public void onAfterRender() { if (inPagingMold() && _model instanceof Pageable) { Pageable m = (Pageable) _model; if (m.getPageSize() > 0) { //min page size is 1 _pgi.setPageSize(m.getPageSize()); } else { m.setPageSize(_pgi.getPageSize()); } _pgi.setTotalSize(getDataLoader().getTotalSize()); if (m.getActivePage() >= 0) { //min page index is 0 _pgi.setActivePage(m.getActivePage()); } else { m.setActivePage(_pgi.getActivePage()); } } }
public void onEvent(Event event) { if (_rows != null && _model != null && inPagingMold()) { //theoretically, _rows shall not be null if _model is not null when //this method is called. But, just in case -- if sent manually final Paginal pgi = getPaginal(); int pgsz = pgi.getPageSize(); int ofs = pgi.getActivePage() * pgsz; if (event instanceof PagingEvent) { // Bug ZK-1696: PagingEvent have the newest paging information pgsz = ((PagingEvent) event).getPageable().getPageSize(); ofs = ((PagingEvent) event).getActivePage() * pgsz; } if (_model instanceof Pageable) { ((Pageable) _model).setPageSize(pgsz); ((Pageable) _model).setActivePage(pgi.getActivePage()); } if (_rod) { getDataLoader().syncModel(ofs, pgsz); } postOnPagingInitRender(); } if (getModel() != null || getPagingPosition().equals("both")) invalidate(); // just in case. else if (_rows != null) { _rows.invalidate(); // Bug 3218078 if (_frozen != null) _frozen.invalidate(); } }
try { int pgsz, ofs; if (inPagingMold()) { pgsz = _pgi.getPageSize(); ofs = _pgi.getActivePage() * pgsz;
try { final ListModel<?> model = grid.getModel(); boolean isPagingMold = grid.inPagingMold(); int activePg = isPagingMold ? grid.getPaginal().getActivePage() : 0; if (model != null) { //live data
} else if (inPagingMold()) { //change to paging if (_pgi != null) addPagingListener(_pgi);
if (inPagingMold()) { if (old != null) removePagingListener(old);
final Grid grid = getGrid(); if (grid != null) { if (grid.inPagingMold()) { final Paginal pgi = grid.getPaginal(); int newTotalSize = grid.getDataLoader().getTotalSize();
setAttribute(Attributes.BEFORE_MODEL_ITEMS_RENDERED, Boolean.TRUE); if (inPagingMold()) {
if (grid != null && grid.inPagingMold()) { int newTotalSize = grid.getDataLoader().getTotalSize();