Refine search
resetDataModel(); int prevIndex = index; FacesContext ctx = FacesContext.getCurrentInstance(); FacesEvent target = idxEvent.getTarget(); UIComponent source = target.getComponent(); UIComponent compositeParent = null; try { int rowCount = getDataModel().getRowCount(); int idx = idxEvent.getIndex(); setIndex(ctx, idx); step)); if (isIndexAvailable()) { if (!UIComponent.isCompositeComponent(source)) { compositeParent = UIComponent .getCompositeComponentParent(source); compositeParent.pushComponentToEL(ctx, null); source.pushComponentToEL(ctx, null);
private void setIndex(FacesContext ctx, int index) { DataModel localModel = getDataModel(); if (index == -1 && initialChildState == null) { saveInitialChildState(ctx); } // save child state if (this.index != -1 && localModel.isRowAvailable()) { saveChildState(ctx); } else if (this.index >= 0 && childState != null) { removeChildState(ctx); } this.index = index; localModel.setRowIndex(index); if (this.index != -1 && var != null && localModel.isRowAvailable()) { Map<String, Object> attrs = ctx.getExternalContext().getRequestMap(); attrs.put(var, localModel.getRowData()); } // restore child state if (this.index != -1 && localModel.isRowAvailable()) { restoreChildState(ctx); } }
oldRowIndex = getDataModel().getRowIndex(); setIndex(facesContext, -1); if (kid.visitTree(context, callback)) { return true;
/** * Returns the rowCount of the underlying DataModel. * * @return */ public Object getIndexData() { if (!getDataModel().isRowAvailable()) { return null; } return getDataModel().getRowData(); }
public void broadcast(FacesEvent event) throws AbortProcessingException { final int actualNoRows = getDataModel().getRowCount(); final Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap(); final String var = getVar(); final String varStatus = getVarStatus(); populateVar(requestMap, var, varStatus, getValidatedFirst(actualNoRows), getValidatedLast(actualNoRows), getRowIndex()); super.broadcast(event); unpopulateVar(requestMap, var, varStatus); }
public void setRowModel(int rowIndex) { getDataModel().setRowIndex(rowIndex); if (var != null) { String rowIndexVar = getRowIndexVar(); Map<String, Object> requestMap = getFacesContext().getExternalContext().getRequestMap();
public Object getRowData(String rowKey) { boolean hasRowKeyVe = getValueExpression(PropertyKeys.rowKey.toString()) != null; DataModel model = getDataModel(); // use rowKey if available and if != lazy // lazy must implement #getRowData if (hasRowKeyVe && !(model instanceof LazyDataModel)) { Map<String, Object> requestMap = getFacesContext().getExternalContext().getRequestMap(); String var = getVar(); Collection data = (Collection) getDataModel().getWrappedData(); if (data != null) { for (Iterator it = data.iterator(); it.hasNext(); ) { Object object = it.next(); requestMap.put(var, object); if (String.valueOf(getRowKey()).equals(rowKey)) { return object; } } } return null; } else { if (!(model instanceof SelectableDataModel)) { throw new FacesException("DataModel must implement " + SelectableDataModel.class.getName() + " when selection is enabled or you need to define rowKey attribute"); } return ((SelectableDataModel) model).getRowData(rowKey); } }
public void setRowIndex(int rowIndex) { saveDescendantState(); this.rowIndex = rowIndex; DataModel model = getDataModel(); model.setRowIndex(rowIndex); String var = getVar(); if (var != null) { Map requestMap = getFacesContext().getExternalContext() .getRequestMap(); if (rowIndex == -1) { requestMap.remove(var); } else if (isRowAvailable()) { requestMap.put(var, getRowData()); } else { requestMap.remove(var); } } restoreDescendantState(); }
public void perform(final AbstractUISheet sheet) { final FacesContext facesContext = FacesContext.getCurrentInstance(); Object data = sheet.getValue(); if (data instanceof DataModel) { data = ((DataModel) data).getWrappedData(); } final SheetState sheetState = sheet.getSheetState(facesContext); final String sortedColumnId = sheetState.getSortedColumnId(); if (LOG.isDebugEnabled()) { LOG.debug("sorterId = '{}'", sortedColumnId); } boolean success = false; if (sortedColumnId != null) { final UIColumn column = (UIColumn) sheet.findComponent(sortedColumnId); if (column != null) { success = perform(facesContext, sheet, data, column, sheetState); } else { LOG.error("No column to sort found, sorterId = '{}'!", sortedColumnId); addNotSortableMessage(facesContext, null); } } else { LOG.error("No sorterId!"); addNotSortableMessage(facesContext, null); } if (!success) { sheetState.resetSortState(); } }
int rowCount = getDataModel().getRowCount(); int i = ((begin != null) ? begin : 0); int e = ((end != null) ? end : rowCount); c = (UIComponent) itr.next(); if (PhaseId.APPLY_REQUEST_VALUES.equals(phase)) { c.processDecodes(faces); c.processValidators(faces); c.processUpdates(faces);
/** * @see java.util.Iterator#next() */ @Override public T next() { if (!model.isRowAvailable()) { throw new NoSuchElementException(); } Object o = model.getRowData(); model.setRowIndex(++index); return (T) o; }
Integer step = getStep(); int rowCount = getDataModel().getRowCount(); int i = ((begin != null) ? begin : 0); int e = ((end != null) ? end : rowCount); step)); for (UIComponent kid : getChildren()) { if (kid.visitTree(context, callback)) { return true;
public void walk(FacesContext context, DataVisitor visitor) throws IOException { int rowCount = wrappedModel.getRowCount(); int currentRow = 0; while (rowCount < 0 || currentRow < rowCount) { wrappedModel.setRowIndex(currentRow); if (!wrappedModel.isRowAvailable() || DataVisitResult.STOP.equals(visitor.process(context, currentRow))) { break; } currentRow++; } }
/** * <p>Return the number of rows in the underlying data model. If the number * of available rows is unknown, return -1.</p> * * @throws FacesException if an error occurs getting the row count */ public int getRowCount() { return (getDataModel().getRowCount()); }
public Object getSelection(DataModelSelectionIndex in, DataModel wrapper) { if ( wrapper.getRowCount()==0 || wrapper.getRowIndex()<0 ) { return null; } else { Object rowData = wrapper.getRowData(); if (rowData instanceof Map.Entry) { return ( (Map.Entry) rowData ).getKey(); } else { return wrapper.getRowIndex(); } } }
/** * <p>Return a flag indicating whether there is <code>rowData</code> * available at the current <code>rowIndex</code>. If no * <code>wrappedData</code> is available, return <code>false</code>.</p> * * @throws FacesException if an error occurs getting the row availability */ public boolean isRowAvailable() { return (getDataModel().isRowAvailable()); }
Object current = getValue(); if (current == null) { setDataModel(new ListDataModel(Collections.EMPTY_LIST)); } else if (current instanceof DataModel) { setDataModel((DataModel) current); } else if (current instanceof List) { setDataModel(new ListDataModel((List) current)); DataModel<?> dataModel = createDataModel(current.getClass()); if (dataModel != null) { dataModel.setWrappedData(current); setDataModel(dataModel); } else {
/** * <p>Return the data object representing the data for the currently * selected row index, if any.</p> * * @throws FacesException if an error occurs getting the row data * @throws IllegalArgumentException if now row data is available at the * currently specified row index */ public Object getRowData() { return (getDataModel().getRowData()); }
/** * Returns the rowCount of the underlying DataModel. * * @return */ public int getRowCount() { return getDataModel().getRowCount(); }
public void setWrappedData(Object data) { wrappedModel.setWrappedData(data); } }