@Override public void setRowIndex(int rowIndex) { if (rowIndex < -1) { throw new IllegalArgumentException("illegal rowIndex " + rowIndex); } int oldRowIndex = _rowIndex; _rowIndex = rowIndex; if (_data != null && oldRowIndex != _rowIndex) { E data = isRowAvailable() ? getRowData() : null; DataModelEvent event = new DataModelEvent(this, _rowIndex, data); DataModelListener[] listeners = getDataModelListeners(); for (int i = 0; i < listeners.length; i++) { listeners[i].rowSelected(event); } } }
@Override public void setWrappedData(Object data) { if (data == null) { setRowIndex(-1); _data = null; _dataArray = null; } else { _data = (Collection<E>)data; _dataArray = _data.toArray((E[]) new Object[_data.size()]); _rowIndex = -1; setRowIndex(0); } }
/** * <p>Construct a new {@link CollectionDataModel} wrapping the specified * list.</p> * * @param collection Collection to be wrapped. */ public CollectionDataModel(Collection<E> collection) { super(); setWrappedData(collection); }
return new CollectionDataModel((Collection) value);
@Override public E getRowData() { if (_data == null) { return null; } if (!isRowAvailable()) { throw new IllegalArgumentException("row is unavailable"); } return _dataArray[_rowIndex]; }
return new CollectionDataModel((Collection) value);
/** * <p>If row data is available, return the array element at the index * specified by <code>rowIndex</code>. If no wrapped data is available, * return <code>null</code>.</p> * * @throws javax.faces.FacesException if an error occurs getting the row data * @throws IllegalArgumentException if now row data is available * at the currently specified row index */ public E getRowData() { if (arrayFromInner == null) { return (null); } else if (!isRowAvailable()) { throw new NoRowAvailableException(); } else { return (arrayFromInner[index]); } }
/** * @throws javax.faces.FacesException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ public void setRowIndex(int rowIndex) { if (rowIndex < -1) { throw new IllegalArgumentException(); } int old = index; index = rowIndex; if (arrayFromInner == null) { return; } DataModelListener [] listeners = getDataModelListeners(); if ((old != index) && (listeners != null)) { Object rowData = null; if (isRowAvailable()) { rowData = getRowData(); } DataModelEvent event = new DataModelEvent(this, index, rowData); int n = listeners.length; for (int i = 0; i < n; i++) { if (null != listeners[i]) { listeners[i].rowSelected(event); } } } }
setDataModel(new ResultDataModel((Result) current)); } else if (current instanceof Collection) { setDataModel(new CollectionDataModel((Collection) current)); } else { setDataModel(new ScalarDataModel(current));
/** * <p>Construct a new {@link CollectionDataModel} wrapping the specified * list.</p> * * @param collection Collection to be wrapped. */ public CollectionDataModel(Collection<E> collection) { super(); setWrappedData(collection); }
/** * <p>If row data is available, return the array element at the index * specified by <code>rowIndex</code>. If no wrapped data is available, * return <code>null</code>.</p> * * @throws javax.faces.FacesException if an error occurs getting the row data * @throws IllegalArgumentException if now row data is available * at the currently specified row index */ @Override public E getRowData() { if (arrayFromInner == null) { return (null); } else if (!isRowAvailable()) { throw new NoRowAvailableException(); } else { return (arrayFromInner[index]); } }
/** * Set the wrapped data. * * @param data the wrapped data. * @throws ClassCastException if <code>data</code> is * non-<code>null</code> and is not a <code>Collection</code> */ public void setWrappedData(Object data) { if (data == null) { inner = null; arrayFromInner = null; setRowIndex(-1); } else { inner = (Collection<E>) data; arrayFromInner = (E[]) new Object[inner.size()]; inner.toArray(arrayFromInner); setRowIndex(0); } } }
return; DataModelListener [] listeners = getDataModelListeners(); if ((old != index) && (listeners != null)) { Object rowData = null; if (isRowAvailable()) { rowData = getRowData();
setDataModel(new ResultDataModel((Result) current)); } else if (current instanceof Collection) { setDataModel(new CollectionDataModel((Collection) current)); } else if (current instanceof Iterable) { setDataModel(new IterableDataModel<>((Iterable<?>) current));
/** * <p>Construct a new {@link CollectionDataModel} wrapping the specified * list.</p> * * @param collection Collection to be wrapped. */ public CollectionDataModel(Collection<E> collection) { super(); setWrappedData(collection); }
/** * <p>If row data is available, return the array element at the index * specified by <code>rowIndex</code>. If no wrapped data is available, * return <code>null</code>.</p> * * @throws javax.faces.FacesException if an error occurs getting the row data * @throws IllegalArgumentException if now row data is available * at the currently specified row index */ @Override public E getRowData() { if (arrayFromInner == null) { return (null); } else if (!isRowAvailable()) { throw new NoRowAvailableException(); } else { return (arrayFromInner[index]); } }
/** * Set the wrapped data. * * @param data the wrapped data. * @throws ClassCastException if <code>data</code> is * non-<code>null</code> and is not a <code>Collection</code> */ @Override public void setWrappedData(Object data) { if (data == null) { inner = null; arrayFromInner = null; setRowIndex(-1); } else { inner = (Collection<E>) data; arrayFromInner = (E[]) new Object[inner.size()]; inner.toArray(arrayFromInner); setRowIndex(0); } } }
return; DataModelListener [] listeners = getDataModelListeners(); if ((old != index) && (listeners != null)) { Object rowData = null; if (isRowAvailable()) { rowData = getRowData();
setDataModel(new ResultDataModel((Result) current)); } else if (current instanceof Collection) { setDataModel(new CollectionDataModel((Collection) current)); } else if (current instanceof Iterable) { setDataModel(new IterableDataModel<>((Iterable<?>) current));
/** * <p>Construct a new {@link CollectionDataModel} wrapping the specified * list.</p> * * @param collection Collection to be wrapped. */ public CollectionDataModel(Collection<E> collection) { super(); setWrappedData(collection); }