Package org.openfaces.component.table

Examples of org.openfaces.component.table.AbstractTable


    }

    private String getSubHeaderRowStyle(TableStyles tableStyles) {
        if (!(tableStyles instanceof AbstractTable))
            return null;
        AbstractTable table = ((AbstractTable) tableStyles);
        return table.getSubHeaderRowStyle();
    }
View Full Code Here


    private static UIComponent componentById(UIComponent parent, String id, boolean isLastComponentInPath,
                                             boolean preProcessDecodesOnTables, boolean preRenderResponseOnTables,
                                             List<Runnable> restoreDataPointerRunnables) {
        FacesContext context = FacesContext.getCurrentInstance();
        if (id.length() > 0 && (isNumberBasedId(id) || id.startsWith(":")) && parent instanceof AbstractTable) {
            final AbstractTable table = ((AbstractTable) parent);
            if (!isLastComponentInPath) {
                if (preProcessDecodesOnTables)
                    table.invokeBeforeProcessDecodes(context);
                if (preRenderResponseOnTables) {
                    table.invokeBeforeRenderResponse(context);
                    table.setRowIndex(-1); // make the succeeding setRowIndex call provide the just-read actual row data through request-scope variables
                }

                int rowIndex = table.getRowIndexByClientSuffix(id);
                final int prevRowIndex = table.getRowIndex();
                if (prevRowIndex == rowIndex) {
                    // ensure row index setting will be run anew to ensure proper request-scope variable values
                    table.setRowIndex(-1);
                }
                table.setRowIndex(rowIndex);
                if (!table.isRowAvailable()) {
                    table.setRowIndex(-1);
                    String tableClientId = table.getClientId(context);
                    table.setRowIndex(prevRowIndex);
                    throw new IllegalStateException("Couldn't find table row for this Ajax request (row data for the requested row is missing). Table's clientId=" + tableClientId + "; rowIndex=" + rowIndex);
                }
                if (restoreDataPointerRunnables != null)
                    restoreDataPointerRunnables.add(new Runnable() {
                        public void run() {
                            table.setRowIndex(prevRowIndex);
                        }
                    });
            } else {
                int rowIndex = table.getRowIndexByClientSuffix(id);
                final int prevRowIndex = table.getRowIndex();
                if (prevRowIndex == rowIndex) {
                    // ensure row index setting will be run anew to ensure proper request-scope variable values
                    table.setRowIndex(-1);
                }
                table.setRowIndex(rowIndex);
                if (!table.isRowAvailable()) {
                    table.setRowIndex(-1);
                    String tableClientId = table.getClientId(context);
                    table.setRowIndex(prevRowIndex);
                    throw new IllegalStateException("Couldn't find table row for this Ajax request (row data for the requested row is missing). Table's clientId=" + tableClientId + "; rowIndex=" + rowIndex);
                }
                if (restoreDataPointerRunnables != null)
                    restoreDataPointerRunnables.add(new Runnable() {
                        public void run() {
                            table.setRowIndex(prevRowIndex);
                        }
                    });
            }
            return table;
        } else if (isNumberBasedId(id) && parent instanceof UIData) {
View Full Code Here

                else {
                    BaseColumn column = (BaseColumn) parent;
                    if (expression instanceof ValueExpression) {
                        BaseColumn.ExpressionData data = column.getExpressionData((ValueExpression) expression);
                        if (data == null) {
                            AbstractTable table = column.getTable();
                            String var = table.getVar();
                            throw new FacesException(
                                    "Can't find column output component (UIOutput component with a value expression containing variable \"" +
                                            var + "\") for column with id: \"" + column.getId() + "\"; table id: \"" + table.getId() +
                                            "\" ; consider declaring the filter expression explicitly if you're using a filter component in this column.");
                        }
                        Class type = data.getValueType();

                        if (String.class.equals(type))
View Full Code Here

            JSONObject stylesObj,
            AnonymousFunction onchangeFunction,
            boolean triStateAllowed) throws IOException {
        super.renderInitScript(facesContext, checkbox, imagesObj, stylesObj, onchangeFunction, triStateAllowed);

        AbstractTable table = getTable(checkbox);
        if (table == null)
            throw new IllegalStateException("SelectionColumn must be nested inside a table");
        BaseColumn col = getColumn(checkbox);

        FacesContext context = FacesContext.getCurrentInstance();
        ScriptBuilder buf = new ScriptBuilder();
        Integer checkboxColIndex = col instanceof CheckboxColumn ? table.getRenderedColumns().indexOf(col) : null;
        buf.initScript(context, checkbox, "O$.Table._initSelectAllCheckbox", table, checkboxColIndex).semicolon();

        Rendering.renderInitScript(context, buf,
                Resources.utilJsURL(context),
                TableUtil.getTableUtilJsURL(context),
View Full Code Here

*/
public class SelectAllCheckboxRenderer extends SelectBooleanCheckboxRenderer {

    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        AbstractTable table = getTable(component);
        if (table == null)
            throw new IllegalStateException("SelectionColumn must be nested inside a table");
        BaseColumn col = getColumn(component);
        boolean checkBoxColHeader = col instanceof CheckboxColumn;
        AbstractTableSelection selection;
        if (!checkBoxColHeader) {
            selection = table.getSelection();
            if (selection == null)
                throw new IllegalStateException("<o:selectAllCheckbox> can only be inserted into a DataTable or TreeTable with multiple selection. clientId = " + component.getClientId(context));
            boolean multipleRowSelection = selection.isMultipleSelectionAllowed();
            if (!multipleRowSelection)
                throw new IllegalStateException("<o:selectAllCheckbox> can only be inserted into a DataTable or TreeTable with multiple selection. clientId = " + component.getClientId(context));
View Full Code Here

            return;

        UIComponent parent = component.getParent();
        if (!(parent instanceof AbstractTable))
            throw new IllegalStateException("<o:columnResizing> can only be placed as a child component inside of <o:dataTable> or <o:treeTable> components. Though the following parent component has been encountered: " + parent.getClass().getName());
        AbstractTable table = (AbstractTable) component.getParent();

        JSONObject columnParams = new JSONObject();
        List<BaseColumn> columns = table.getRenderedColumns();
        for (int i = 0; i < columns.size(); i++) {
            BaseColumn column = columns.get(i);
            boolean resizable = column.isResizable();
            String minResizingWidth = column.getMinResizingWidth();
            if (!resizable || minResizingWidth != null) {
View Full Code Here

    @Override
    public void decode(FacesContext context, UIComponent component) {
        super.decode(context, component);
        Map requestParams = context.getExternalContext().getRequestParameterMap();
        AbstractTable table = (AbstractTable) component.getParent();
        String colWidthsFieldName = getColumnWidthsFieldName(context, table);
        String params = (String) requestParams.get(colWidthsFieldName);

        String columnOrderFieldName = getColumnOrderFieldName(context, table);
        String colOrder = (String) requestParams.get(columnOrderFieldName);
        Iterable<String> submittedColumnsOrder = null;
        if (colOrder != null) {
            colOrder += ",";
            submittedColumnsOrder = Arrays.asList(colOrder.split(","));
            if (submittedColumnsOrder != null) {
                table.setColumnsOrder(submittedColumnsOrder);
            }
        }
        if (params == null || params.length() == 0)
            return;
        String[] splitParameters = params.split(":");
        String tableWidth = splitParameters[0];
        String colWidthsArray = splitParameters[1];
        if (tableWidth.length() == 0)
            tableWidth = null;
        JSONArray widthsArray;
        try {
            widthsArray = new JSONArray(colWidthsArray);
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
        List<BaseColumn> columns = table.getRenderedColumns();
        if (columns.size() != widthsArray.length())
            throw new IllegalStateException("columns.size() != widthsArray.length(): " + columns.size() + " != " + widthsArray.length());

        ColumnResizing columnResizing = (ColumnResizing) component;
        ColumnResizingState resizingState = columnResizing.getResizingState();
        if (resizingState == null)
            resizingState = new ColumnResizingState();

        resizingState.setTableWidth(tableWidth);

        for (int i = 0, count = columns.size(); i < count; i++) {
            BaseColumn column = columns.get(i);
            String newWidth;
            try {
                newWidth = widthsArray.getString(i);
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }

            resizingState.setColumnWidth(column.getId(), newWidth);
        }

        if (submittedColumnsOrder != null) {
            if (table.getColumnsOrder() != null && ValueBindings.set(table, "columnsOrder", table.getColumnsOrder())) {
                table.setColumnsOrder(null);
            }
        }
        columnResizing.setResizingState(resizingState);
    }
View Full Code Here

*/
public class ColumnReorderingRenderer extends RendererBase {
    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        ColumnReordering cr = (ColumnReordering) component;
        AbstractTable table = cr.getTable();
        StyleParam draggedCellStyle = new StyleParam(cr, "draggedCell", "o_table_draggedColumn");
        StyleParam autoScrollAreaStyle = new StyleParam(cr, "autoScrollArea", "o_headerAutoScrollArea");
        StyleParam dropTargetStyle = new StyleParam(cr, "dropTarget", "o_table_columnDropTarget");
        Styles.renderStyleClasses(context, cr);
        // important: style rendering is made earlier than init function deliberately to allow script to
View Full Code Here

    @Override
    public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
        TreeColumn treeColumn = ((TreeColumn) component);
        ResponseWriter writer = context.getResponseWriter();
        AbstractTable table = getTable(treeColumn);
        if (!treeColumn.getShowAsTree()) {
            super.encodeChildren(context, component);
            return;
        }

        int level = table.getNodeLevel();

        String indentStyle = null;
        String levelIndent = treeColumn.getLevelIndent();
        if (!Rendering.isNullOrEmpty(levelIndent)) {
            indentStyle = "width: " + levelIndent;
        }
        String indentClass = Styles.getCSSClass(context, table, indentStyle, DEFAULT_INDENT_CLASS);

        writer.startElement("table", treeColumn);
        writer.writeAttribute("cellspacing", "0", null);
        writer.writeAttribute("cellpadding", "0", null);
        writer.writeAttribute("class", "o_cellWrapper", null);
        writer.startElement("tr", treeColumn);
        writer.startElement("td", treeColumn);
        for (int i = 0; i < level; i++) {
            writer.writeAttribute("class", indentClass, null);
            if (Environment.isOpera() && indentStyle != null)
                writer.writeAttribute("style", indentStyle, null);
            writer.startElement("div", treeColumn);
            writer.writeAttribute("class", indentClass, null);
            if ((Environment.isOpera() || Environment.isMozilla()) && indentStyle != null)
                writer.writeAttribute("style", indentStyle, null);
            writer.endElement("div");

            writer.endElement("td");
            writer.startElement("td", treeColumn);
        }

        boolean showTreeStructure = false;
        String treeStructureStyle = showTreeStructure
                ? "background: url('" + Resources.internalURL(context, "table/treeStructureSolid.png") +
                "') no-repeat left center;"
                : null;

        if (Environment.isOpera() && indentStyle != null)
            writer.writeAttribute("style", indentStyle + (treeStructureStyle != null ? treeStructureStyle : ""), null);
        else if (treeStructureStyle != null) {
            writer.writeAttribute("style", treeStructureStyle, null);
        }


        boolean nodeHasChildren = table.getNodeHasChildren();
        if (nodeHasChildren) {
            String expansionToggleCellClass = Styles.getCSSClass(
                    context, table, treeColumn.getExpansionToggleCellStyle(),
                    DEFAULT_EXPANSION_TOGGLE_CELL_CLASS, treeColumn.getExpansionToggleCellClass());
            expansionToggleCellClass = Styles.mergeClassNames(expansionToggleCellClass, indentClass);
View Full Code Here

TOP

Related Classes of org.openfaces.component.table.AbstractTable

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.