Package org.openfaces.component.table.impl

Examples of org.openfaces.component.table.impl.TableDataModel


    }

    @Override
    protected void beforeProcessDecodes(FacesContext context) {
        super.beforeProcessDecodes(context);
        TableDataModel model = getModel();
        model.prepareForRestoringRowIndexes();
        restoreRows(false);
    }
View Full Code Here


    }

    @Override
    protected void restoreRows(boolean forceDecoding) {
        FacesContext context = getFacesContext();
        TableDataModel model = getModel();
        boolean readFreshData =
                TreeTableRenderer.isAjaxFoldingInProgress(context) ||
                        TreeTableRenderer.isAjaxRowLoadingInProgress(context) ||
                        isRowsDecodingRequired();
        prepareModelFromTreeStructure(readFreshData);

        TableDataModel.RestoredRowIndexes rri = model.restoreRowIndexes();
        Set<Integer> unavailableRowIndexes = rri.getUnavailableRowIndexes();
        setUnavailableRowIndexes(unavailableRowIndexes);

        int[] oldIndexes = rri.getOldIndexes();
        List<NodeInfoForRow> newNodeInfoForRows = new ArrayList<NodeInfoForRow>(oldIndexes.length);
View Full Code Here

            return null;
        return getModel().getRowData();
    }

    protected Object getRowKeyByRowData(Object data) {
        TableDataModel model = getModel();
        model.setRowData(data);
        if (!model.isRowAvailable()) {
            Object rowKey = model.requestRowKeyByRowData(getFacesContext(), null, null, data, -1, -1);
            if (rowKey instanceof DefaultRowKey && ((DefaultRowKey) rowKey).getRowIndex() == -1) {
                return null;
            }
            return rowKey;
        }
        return model.getRowKey();
    }
View Full Code Here

    private Boolean unDisplayedSelectionAllowed;


    public AbstractTable() {
        super.setUiDataValue(new TableDataModel(this));
    }
View Full Code Here

    }

    @Override
    public Object processSaveState(FacesContext context) {
        AbstractTableSelection selection = getSelection();
        TableDataModel model = getModel();
        if (selection != null && selection.getModel() == null) {
            // Fix for JSFC-2945 (selection's model can be null if table is not rendered and selection's rowData is declared as constant)
            selection.setModel(model);
        }

        Object result = super.processSaveState(context);

        // Model instance is saved as is in the "server" state saving mode. The table reference is unnecessary in the
        // state and it contains references to the entire view state tree, so we're just cutting this reference to
        // prevent excessive memory consumption (see OF-196)
        model.setTable(null);

        return result;
    }
View Full Code Here

        beforeUpdateValuesPhase = true;
        incomingSortingRules = null;
    }

    protected void afterRestoreState(FacesContext context) {
        TableDataModel model = (TableDataModel) getUiDataValue();
        model.setTable(this);

        AbstractTableSelection selection = getSelection();
        if (selection != null)
            selection.setModel(model);
View Full Code Here

        super.processRestoreState(context, ajaxState != null ? ajaxState : state);
        afterRestoreState(context);
    }

    protected TableDataModel getModel() {
        TableDataModel uiDataValue = (TableDataModel) getUiDataValue();
        AbstractTable table = uiDataValue.getTable();
        if (table == null) {
            // The model's table reference is normally cleared before the state is saved
            // (see AbstractTable.processSaveState), and then initialized again after restoring state
            // (see AbstractTable.afterRestoreState). It is possible that the same instance of a table component gets
            // through the state saving phase and then rerendered without restoring the state though. It is the case
            // when the table component is bound to a session-scoped value, where it is created explicitly, and the same
            // page is opened with the HTTP GET request for the second time (for an application that has a "server"
            // state saving mode). Hence we have this check that guards against such a situation when there's an attempt
            // to use a model without the table reference in the beginning of a lifecycle. E.g. this fix is important
            // for DataTable.testPagination test to work properly.
            uiDataValue.setTable(this);
        }

        return uiDataValue;
    }
View Full Code Here

            filter.updateValueFromBinding(context);
        }

        AbstractTableSelection selection = getSelection();
        if (selection != null) {
            TableDataModel model = getModel();
            if (selection.getModel() == null)
                selection.setModel(model);
            if (model.getWrappedData() != null) // don't do it on the first rendering
                selection.rememberByKeys(); // for selection to be retained by id if data changes in the setWrappedData call
            selection.beforeEncode();
        }
        setUnavailableRowIndexes(null);
View Full Code Here

    public void setColumnIndexVar(String columnIndexVar) {
        this.columnIndexVar = columnIndexVar;
    }

    protected void updateSortingFromBindings() {
        TableDataModel model = getModel();
        model.startUpdate();
        try {
            FacesContext facesContext = getFacesContext();
            ValueExpression sortAscendingExpression = getValueExpression("sortAscending");
            ELContext elContext = facesContext.getELContext();
            if (sortAscendingExpression != null) {
                Object sortAscendingObj = sortAscendingExpression.getValue(elContext);
                if (!(sortAscendingObj instanceof Boolean))
                    throw new IllegalArgumentException("Illegal value returned from the 'sortAscending' attribute binding of DataTable orTreeTable with client-id (" + getClientId(facesContext) + "). " +
                            "It should be an instance of java.lang.Boolean, but was: " + (sortAscendingObj != null ? sortAscendingObj.getClass().getName() : "null"));
                boolean newSortAscending = (Boolean) sortAscendingObj;
                if (isSortAscending() != newSortAscending)
                    setSortAscending(newSortAscending);
            }
            ValueExpression sortColumnIdExpression = getValueExpression("sortColumnId");
            if (sortColumnIdExpression != null) {
                Object sortColumnIdObj = sortColumnIdExpression.getValue(elContext);
                if (sortColumnIdObj != null && !(sortColumnIdObj instanceof String))
                    throw new IllegalArgumentException("Illegal value returned from the 'sortColumnId' attribute binding of DataTable or TreeTable with client-id (" + getClientId(facesContext) + "). " +
                            "It should be an instance of java.lang.String, but was: " + sortColumnIdObj.getClass().getName());
                String newSortColumnId = (String) sortColumnIdObj;
                String oldSortColumnId = getSortColumnId();
                if (((newSortColumnId == null) != (oldSortColumnId == null)) ||
                        (newSortColumnId != null && !newSortColumnId.equals(oldSortColumnId)))
                    setSortColumnId(newSortColumnId);
            }
        } finally {
            model.endUpdate();
        }
    }
View Full Code Here

        }

    }

    private Collection<Object> getFilteredRowDatas() {
        TableDataModel model = getModel();
        int savedPageIndex = model.getPageIndex();
        int savedRowIndex = model.getRowIndex();
        List<Object> allRows = new ArrayList<Object>();
        try {
            for (int pageIndex = 0, pageCount = model.getPageCount(); pageIndex < pageCount; pageIndex++) {
                model.setPageIndex(pageIndex);
                for (int rowIndex = 0, rowCount = model.getRowCount(); rowIndex < rowCount || rowCount == -1; rowIndex++) {
                    model.setRowIndex(rowIndex);
                    if (!model.isRowAvailable()) break;
                    Object rowData = model.getRowData();
                    allRows.add(rowData);
                }
            }
        } finally {
            model.setPageIndex(savedPageIndex);
            model.setRowIndex(savedRowIndex);
        }
        return allRows;
    }
View Full Code Here

TOP

Related Classes of org.openfaces.component.table.impl.TableDataModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.