/** * <p>Return the value of the <code>rows</code> property.</p> */ public int getRows() { return getUIData().getRows(); }
/** * @return int */ public int getRows() { return getUIData().getRows(); }
/** * Update the column of the given {@link UIData} component at the given zero-based column index. This will basically * update all direct children of the {@link UIColumn} component at the given column index in all rows. The column * index is the physical column index and does not depend on whether one or more columns is rendered or not (i.e. it * is not necessarily the same column index as the enduser sees in the UI). * <p> * Note that the to-be-updated direct child of {@link UIColumn} must be a fullworthy JSF UI component which renders * a concrete HTML element to the output, so that JS/ajax can update it. So if you have due to design restrictions * for example a <code><h:panelGroup rendered="..."></code> without an ID, then you should give it an ID. * This way it will render a <code><span id="..."></code> which is updateable by JS/ajax. * @param table The {@link UIData} component. * @param index The zero-based index of the column to be updated. * @since 1.3 */ public static void updateColumn(UIData table, int index) { if (index < 0 || table.getRowCount() < 1 || index > table.getChildCount()) { return; } int rowCount = (table.getRows() == 0) ? table.getRowCount() : table.getRows(); if (rowCount == 0) { return; } updateColumnCells(table, index, rowCount); }
/** * Update the column of the given {@link UIData} component at the given zero-based column index. This will basically * update all direct children of the {@link UIColumn} component at the given column index in all rows. The column * index is the physical column index and does not depend on whether one or more columns is rendered or not (i.e. it * is not necessarily the same column index as the enduser sees in the UI). * <p> * Note that the to-be-updated direct child of {@link UIColumn} must be a fullworthy JSF UI component which renders * a concrete HTML element to the output, so that JS/ajax can update it. So if you have due to design restrictions * for example a <code><h:panelGroup rendered="..."></code> without an ID, then you should give it an ID. * This way it will render a <code><span id="..."></code> which is updateable by JS/ajax. * @param table The {@link UIData} component. * @param index The zero-based index of the column to be updated. * @since 1.3 */ public static void updateColumn(UIData table, int index) { if (index < 0 || table.getRowCount() < 1 || index > table.getChildCount()) { return; } int rowCount = (table.getRows() == 0) ? table.getRowCount() : table.getRows(); if (rowCount == 0) { return; } updateColumnCells(table, index, rowCount); }
/** * <p>Return the value of the <code>pageCount</code> property.</p> */ public int getPageCount() { UIData uiData = getUIData(); int rows = uiData.getRows(); int pageCount; if (rows > 0) { pageCount = rows <= 0 ? 1 : uiData.getRowCount() / rows; if (uiData.getRowCount() % rows > 0) { pageCount++; } } else { rows = 1; pageCount = 1; } return pageCount; }
protected void encodeLastPageListItem(FacesContext facesContext, ResponseWriter responseWriter, Paginator paginator, UIData uiData, String clientId, String namingContainerId) throws IOException { boolean enabled = ((uiData.getFirst() + uiData.getRows()) < uiData.getRowCount()); String lastPageLabel = paginator.getLastPageLabel(); encodeUnorderedListItem(facesContext, responseWriter, paginator, clientId, namingContainerId, "lastPage", lastPageLabel, enabled, false); }
protected void encodeLastPageListItem(FacesContext facesContext, ResponseWriter responseWriter, Paginator paginator, UIData uiData, String clientId) throws IOException { boolean enabled = ((uiData.getFirst() + uiData.getRows()) < uiData.getRowCount()); String lastPageLabel = paginator.getLastPageLabel(); encodeUnorderedListItem(facesContext, responseWriter, paginator, clientId, "lastPage", lastPageLabel, enabled, false); }
protected void encodeNextPageListItem(FacesContext facesContext, ResponseWriter responseWriter, Paginator paginator, UIData uiData, String clientId, String namingContainerId) throws IOException { boolean enabled = ((uiData.getFirst() + uiData.getRows()) < uiData.getRowCount()); String nextPageLabel = paginator.getNextPageLabel(); encodeUnorderedListItem(facesContext, responseWriter, paginator, clientId, namingContainerId, "nextPage", nextPageLabel, enabled, false); }
protected void encodeNextPageListItem(FacesContext facesContext, ResponseWriter responseWriter, Paginator paginator, UIData uiData, String clientId, String namingContainerId) throws IOException { boolean enabled = ((uiData.getFirst() + uiData.getRows()) < uiData.getRowCount()); String nextPageLabel = paginator.getNextPageLabel(); encodeUnorderedListItem(facesContext, responseWriter, paginator, clientId, namingContainerId, "nextPage", nextPageLabel, enabled, false); }
protected void encodeNextPageListItem(FacesContext facesContext, ResponseWriter responseWriter, Paginator paginator, UIData uiData, String clientId) throws IOException { boolean enabled = ((uiData.getFirst() + uiData.getRows()) < uiData.getRowCount()); String nextPageLabel = paginator.getNextPageLabel(); encodeUnorderedListItem(facesContext, responseWriter, paginator, clientId, "nextPage", nextPageLabel, enabled, false); }
protected void encodeLastPageListItem(FacesContext facesContext, ResponseWriter responseWriter, Paginator paginator, UIData uiData, String clientId, String namingContainerId) throws IOException { boolean enabled = ((uiData.getFirst() + uiData.getRows()) < uiData.getRowCount()); String lastPageLabel = paginator.getLastPageLabel(); encodeUnorderedListItem(facesContext, responseWriter, paginator, clientId, namingContainerId, "lastPage", lastPageLabel, enabled, false); }
/** * @return the page count of the uidata */ public int getPageCount() { UIData uiData = getUIData(); int rows = uiData.getRows(); int pageCount; if (rows > 0) { pageCount = rows <= 0 ? 1 : uiData.getRowCount() / rows; if (uiData.getRowCount() % rows > 0) { pageCount++; } } else { rows = 1; pageCount = 1; } return pageCount; }
/** * Sets the dataPaginator to the (n) number of pages forward, defined by the * fastStep property */ public void gotoFastForward() { int fastStep = getFastStep(); if (fastStep <= 0) { fastStep = 1; } int next = getUIData().getFirst() + getUIData().getRows() * fastStep; int rowcount = getUIData().getRowCount(); if (next >= rowcount) { next = (rowcount - 1) - ((rowcount - 1) % getUIData().getRows()); } getUIData().setFirst(next); }
/** * @return the page index of the uidata */ public int getPageIndex() { UIData uiData = getUIData(); int rows = uiData.getRows(); if (0 == rows) { throw new FacesException("You need to set a value to the 'rows' attribute of component '" + uiData.getClientId(getFacesContext()) + "'" ); } int pageIndex; if (rows > 0) { pageIndex = uiData.getFirst() / rows + 1; } else { log.warn("DataTable " + uiData.getClientId(FacesContext.getCurrentInstance()) + " has invalid rows attribute."); pageIndex = 0; } if (uiData.getFirst() % rows > 0) { pageIndex++; } return pageIndex; }
/** * Sets the dataPaginator to the (n) number of pages back, defined by the * fastStep property */ public void gotoFastRewind() { int fastStep = getFastStep(); if (fastStep <= 0) { fastStep = 1; } int previous = getUIData().getFirst() - getUIData().getRows() * fastStep; if (previous < 0) { previous = 0; } getUIData().setFirst(previous); }
private void processRows(FacesContext context, int processAction) { UIData parentUIData = getParentUIData(); int first = parentUIData.getFirst(); int rows = parentUIData.getRows(); int last; if (rows == 0) { last = parentUIData.getRowCount(); } else { last = first + rows; } for (int rowIndex = first; rowIndex < last; rowIndex++) { parentUIData.setRowIndex(rowIndex); if (parentUIData.isRowAvailable()) { processColumns(context, processAction); } } }
/** * Sets the dataPaginator to the previous page */ public void gotoPreviousPage() { if (isModelResultSet()) { int first = getUIData().getFirst() - getUIData().getRows(); if (first < 0) { first = 0; } getUIData().setFirst(first); } else { int previous = getUIData().getFirst() - getUIData().getRows(); int rowCount = getRowCount(); if (previous >= 0) { if (previous > rowCount) { previous = rowCount; } getUIData().setFirst(previous); } } }
/** * Sets the dataPaginator to the last page */ public void gotoLastPage() { if (isModelResultSet()) { int first = getUIData().getFirst(); while (true) { getUIData().setRowIndex(first + 1); if (getUIData().isRowAvailable()) { first++; } else { break; } } getUIData().setFirst(first - (first % getUIData().getRows())); } else { int rowcount = getUIData().getRowCount(); int rows = getUIData().getRows(); int delta = rowcount % rows; int first = delta > 0 && delta < rows ? rowcount - delta : rowcount - rows; if (first >= 0) { getUIData().setFirst(first); } else { getUIData().setFirst(0); } } }
/** * Sets the dataPaginator to the next page */ public void gotoNextPage() { int next = getUIData().getFirst() + getUIData().getRows(); if (isModelResultSet()) { getUIData().setRowIndex(next); if (getUIData().isRowAvailable()) { getUIData().setFirst(next); } } else { if (next < getUIData().getRowCount()) { getUIData().setFirst(next); } } }
/** * When this tag is not disabled, the input value is changed, the input component is valid and the input component's * local value is not null, then check for a duplicate value by visiting all rows of the parent {@link UIData} * component. */ @Override public void processValueChange(ValueChangeEvent event) { if (isDisabled()) { return; } UIInput input = (UIInput) event.getComponent(); if (!input.isValid() || input.getLocalValue() == null) { return; } UIData table = getClosestParent(input, UIData.class); int originalRows = table.getRows(); table.setRows(0); // We want to visit all rows. FacesContext context = FacesContext.getCurrentInstance(); UniqueColumnValueChecker checker = new UniqueColumnValueChecker(table, input); table.visitTree(VisitContext.createVisitContext(context), checker); table.setRows(originalRows); if (checker.isDuplicate()) { input.setValid(false); context.validationFailed(); addError(input.getClientId(context), getMessage(), getLabel(input), checker.getDuplicateIndex() + 1); } }