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 Object getWrappedData(DataModel out, javax.faces.model.DataModel wrapper) { return wrapper.getWrappedData(); }
public Object getWrappedData() { // TODO Auto-generated method stub return wrappedModel.getWrappedData(); }
public Object getWrappedData() { return wrappedModel.getWrappedData(); }
public Object getWrappedData() { return wrappedModel.getWrappedData(); }
public Object getWrappedData() { return wrappedModel.getWrappedData(); }
public Object getWrappedData() { return wrappedModel.getWrappedData(); }
@SuppressWarnings("unchecked") public static Iterator unwrapIterator(Object value) { if (value instanceof Iterable) { return ((Iterable) value).iterator(); } else if (value instanceof DataModel && ((DataModel) value).getWrappedData() instanceof Iterable) { return ((Iterable) ((DataModel) value).getWrappedData()).iterator(); } else if (value instanceof Map) { return ((Map) value).entrySet().iterator(); } else if (value instanceof Query) { return (((Query) value).getResultList()).iterator(); } else if (value != null && value.getClass().isArray()) { return arrayAsList(value).iterator(); } else { throw new ExcelWorkbookException("A worksheet's value must be an Iterable, DataModel or Query"); } }
else if (originalValue instanceof DataModel && ((DataModel) originalValue).getWrappedData() instanceof Iterable) selectItems.addAll(asSelectItems((Iterable) ((DataModel) originalValue).getWrappedData()));
public Object getRowData(String rowKey) { boolean hasRowKeyVe = this.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 = this.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(this.getRowKey()).equals(rowKey)) { return object; } } } return null; } else { if(!(model instanceof SelectableDataModel)) { throw new FacesException("DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled or you need to define rowKey attribute"); } return ((SelectableDataModel) model).getRowData(rowKey); } }
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(); } }
@SuppressWarnings("unchecked") public void testConvertListToDataModel() throws Exception { List<Object> sourceList = new ArrayList<>(); DataModel<Object> resultModel = (DataModel<Object>) this.converter.convertSourceToTargetClass(sourceList, DataModel.class); assertNotNull(resultModel); assertSame(sourceList, resultModel.getWrappedData()); }
@SuppressWarnings("unchecked") public void testConvertListToListDataModel() throws Exception { List<Object> sourceList = new ArrayList<>(); DataModel<Object> resultModel = (DataModel<Object>) this.converter.convertSourceToTargetClass(sourceList, ListDataModel.class); assertNotNull(resultModel); assertSame(sourceList, resultModel.getWrappedData()); }
@SuppressWarnings("unchecked") public void testConvertListToSerializableListDataModel() throws Exception { List<Object> sourceList = new ArrayList<>(); DataModel<Object> resultModel = (DataModel<Object>) this.converter.convertSourceToTargetClass(sourceList, SerializableListDataModel.class); assertNotNull(resultModel); assertSame(sourceList, resultModel.getWrappedData()); assertTrue(resultModel instanceof Serializable); }