Package org.richfaces.component

Examples of org.richfaces.component.UIColumn


        UIExtendedDataTable table = holder.getTable();
        ResponseWriter writer = context.getResponseWriter();
        Iterator<UIColumn> iter = table.getSortedColumns();
        boolean first = true;
        int currentColumn = 0;
        UIColumn column = null;
        if (holder.isGroupingOn() && (rowGroupChanged(context, holder))) {
            if (holder.isFirstRow()) {
                encodeFakeIeRow(context, table, holder);
            }
            encodeGroupRow(context, table, holder);
        }
        holder.setFirstRow(false);
        while (iter.hasNext()) {
            column = iter.next();
            // Start new row for first column - expect a case of the detail
            // table, wich will be insert own row.
            boolean isRow = (column instanceof Row);
            if (first && !isRow) {
                encodeRowStart(context, getFirstRowSkinClass(), holder
                        .getRowClass(), table, holder, writer);
            }

            // TODO PKA CHANGE COLUMN RENDERER TO GET RID OF && false
            if (false && (column instanceof Column)) {
                boolean breakBefore = ((Column) column).isBreakBefore()
                        || isRow;
                if (breakBefore && !first) {
                    // close current row
                    writer.endElement(HTML.TR_ELEMENT);
                    // reset columns counter.
                    currentColumn = 0;
                    // Start new row, expect a case of the detail table, wich
                    // will be insert own row.
                    if (!isRow) {
                        holder.nextRow();
                        encodeRowStart(context, holder.getRowClass(), table,
                                holder, writer);
                    }
                }
                encodeCellChildren(context, column,
                        first ? getFirstRowSkinClass() : null,
                        getRowSkinClass(), holder.getRowClass(),
                        getCellSkinClass(), holder
                                .getColumnClass(currentColumn));
                // renderChild(context, column);
                if (isRow && iter.hasNext()) {
                    // Start new row for remained columns.
                    holder.nextRow();
                    encodeRowStart(context, holder.getRowClass(), table,
                            holder, writer);
                    // reset columns counter.
                    currentColumn = -1;
                }
            } else if (column.isRendered()) {
                // UIColumn don't have own renderer
                writer.startElement(HTML.td_ELEM, table);
                getUtils().encodeId(context, column);
                encodeStyleClass(writer, null, getCellSkinClass(), null, null);
                // TODO - encode column attributes.
View Full Code Here


    public void encodeScriptIfNecessary(FacesContext context,
            UIExtendedDataTable table) throws IOException {
        boolean shouldRender = false;
        Iterator<UIColumn> columns = table.getSortedColumns();
        while (columns.hasNext() && !shouldRender) {
            UIColumn next = columns.next();
            shouldRender = next.isSortable();
            shouldRender = true;// shouldRender || (next instanceof
            // HtmlDataColumn);
        }
        shouldRender = true;
        if (shouldRender) {
View Full Code Here

        if (component instanceof UIExtendedDataTable) {
            UIExtendedDataTable table = (UIExtendedDataTable) component;

            for (Iterator<UIColumn> columns = table.getChildColumns(); columns
                    .hasNext();) {
                UIColumn column = columns.next();
                column.setId(column.getId());
            }

            table.ensureTableStateInitialized();
        }
        super.preEncodeBegin(context, component);
View Full Code Here

                boolean filtering = false;

                boolean isGroupingOn = table.isGroupingOn();
                boolean sortByGroupingColumn = false;
                // String groupingColumnId = null;
                UIColumn groupingColumn = null;
                if (isGroupingOn) {
                    groupingColumn = table.getGroupingColumn();
                    sortByGroupingColumn = (groupingColumn == null ? false
                            : groupingColumn.getClientId(context).equals(
                                    sortColumnId));
                    // groupingColumnId = table.getGroupingColumnId();
                }
                for (Iterator<UIColumn> columns = table.getChildColumns(); columns
                        .hasNext();) {
                    UIColumn column = columns.next();
                    String id = column.getId();
                    column.setId(id);

                    if (sortColumnId != null) {
                      sorting = true;
                        boolean isGroupingColumn = (isGroupingOn && column
                                .equals(groupingColumn));
                        if (sortColumnId.equals(column.getClientId(context))) {
                            // set sort order
                            if (map.containsKey(SORT_DIR_PARAMETER)) {
                                String sortDir = (String) map
                                        .get(SORT_DIR_PARAMETER);
                                column
                                        .setSortOrder((sortDir
                                                .equals(SORT_DIR_PARAMETER_ASC) ? Ordering.ASCENDING
                                                : (sortDir
                                                        .equals(SORT_DIR_PARAMETER_DESC) ? Ordering.DESCENDING
                                                        : Ordering.UNSORTED)));
                            } else {
                                column.toggleSortOrder();
                            }

                            Collection<Object> sortPriority = table
                                    .getSortPriority();
                            // clear sort priority in case of single sort mode
                            if (isSingleSortMode) {
                                sortPriority.clear();
                            }
                            // add column to sort priority if is not added yet
                            if (!sortPriority.contains(id)) {
                                sortPriority.add(id);
                            }
                            if (isGroupingColumn) {
                                // set as grouping column to mark that grouping
                                // order has changed
                                table.setGroupingColumn(column);
                            }
                        } else if (isSingleSortMode) { // in case of single
                            // sort mode
                            if (!isGroupingColumn) { // grouping is not by
                                // this column
                                if (!sortByGroupingColumn) {// sort not by
                                    // grouping column
                                    // disable sort by this column
                                    column.setSortOrder(Ordering.UNSORTED);
                                }
                            }
                        }
                    }

                    UIInput filterValueInput = (UIInput) column
                            .getFacet(FILTER_INPUT_FACET_NAME);
                    if (null != filterValueInput) {
                        filterValueInput.decode(context);
                        String oldFilterValue = column.getFilterValue();
                        Object submittedValue = filterValueInput
                                .getSubmittedValue();
                        String newFilterValue = null;
                        if (null != submittedValue) {
                            newFilterValue = filterValueInput
                                    .getSubmittedValue().toString();
                            if ((newFilterValue != null)
                                    && (newFilterValue.length() == 0)) {
                                newFilterValue = null;
                            }
                            column.setFilterValue(newFilterValue);
                        }
                        boolean filterChanged = (newFilterValue == null ? (oldFilterValue != null)
                                : !newFilterValue.equals(oldFilterValue));
                        //if (filterChanged) {
                        //    table.resetGroupVisibilityState();
                        //}
                        filtering = (filtering || filterChanged);
                    }
                }

                // AjaxContext.getCurrentInstance().addComponentToAjaxRender(component);
                if (sorting){
                  new ExtTableSortEvent(component).queue();
                }
                if (filtering){
                  new ExtTableFilterEvent(component).queue();
                }
               
            }

            // GROUP COLUMNS
            if (GROUP_FILTER_PARAMETER.equals(map.get(clientId))) {
                String groupColumnId = map.get(GROUP_FILTER_PARAMETER);
                // turn off grouping
                table.disableGrouping();
                if (groupColumnId != null) {
                    // turn off sorting by all columns
                    table.getSortPriority().clear();
                    for (Iterator<UIColumn> columns = table.getChildColumns(); columns
                            .hasNext();) {
                        UIColumn column = columns.next();
                        // child.setId(child.getId());
                        if (groupColumnId.equals(column.getClientId(context))) { // group
                            // by
                            // this
                            // column
                            // set sort order if is not set
                            if (column.getSortOrder().equals(Ordering.UNSORTED)) {
                                column.setSortOrder(Ordering.ASCENDING);
                            }
                            // set as grouping column
                            table.setGroupingColumn(column);
                        } else { // grouping is not by this column
                            // turn off sorting by this column
                            column.setSortOrder(Ordering.UNSORTED);
                        }
                    }// for columns
                }// if

                // AjaxContext.getCurrentInstance().addComponentToAjaxRender(component);
View Full Code Here

                        context, table));
        menuRenderer.setPrepareFunction(getPreSendAjaxRequestFunction(context,
                table));
        for (Iterator<UIColumn> colums = table.getSortedColumns(); colums
                .hasNext();) {
            UIColumn col = colums.next();
            if (col instanceof UIColumn) {
                UIColumn column = (UIColumn) col;
                // if (column.isRendered()){
                String menuId = menuRenderer.renderMenu(context, table, column);
                ajaxContext.addRenderedArea(menuId);
                // }
            }
View Full Code Here

    protected class RichHeaderEncodeStrategy implements HeaderEncodeStrategy {

        public void encodeBegin(FacesContext context, ResponseWriter writer,
                UIComponent column, String facetName, boolean sortableColumn)
                throws IOException {
            UIColumn col = (UIColumn) column;
            String clientId = col.getClientId(context) + facetName;
            writer.writeAttribute("id", clientId, null);

            if (sortableColumn && col.isSelfSorted()) {
                writer.writeAttribute(HTML.onclick_ATTRIBUTE,
                        buildAjaxFunction(context, column, true, null)
                                .toString(), null);
                writer.writeAttribute(HTML.style_ATTRIBUTE, "cursor: pointer;",
                        null);
View Full Code Here

        }

        public void encodeEnd(FacesContext context, ResponseWriter writer,
                UIComponent column, String facetName, boolean sortableColumn)
                throws IOException {
            UIColumn col = (UIColumn) column;
            if (sortableColumn) {
                String imageUrl = null;
                if (Ordering.ASCENDING.equals(col.getSortOrder())) {
                    if (null != col.getSortIconAscending()) {
                        imageUrl = col.getSortIconAscending();
                    } else {
                        imageUrl = getResource(TriangleIconUp.class.getName())
                                .getUri(context, null);
                    }
                } else if (Ordering.DESCENDING.equals(col.getSortOrder())) {
                    if (null != col.getSortIconDescending()) {
                        imageUrl = col.getSortIconDescending();
                    } else {
                        imageUrl = getResource(TriangleIconDown.class.getName())
                                .getUri(context, null);
                    }
                } else if (col.isSelfSorted()) {
                    if (null != col.getSortIcon()) {
                        imageUrl = col.getSortIcon();
                    } else {
                        imageUrl = getResource(
                                DataTableIconSortNone.class.getName()).getUri(
                                context, null);
                    }
                }

                if (imageUrl != null) {
                    writer.startElement(HTML.IMG_ELEMENT, column);
                    writer.writeAttribute(HTML.src_ATTRIBUTE, imageUrl, null);
                    writer.writeAttribute(HTML.width_ATTRIBUTE, "15", null);
                    writer.writeAttribute(HTML.height_ATTRIBUTE, "15", null);
                    writer.writeAttribute(HTML.class_ATTRIBUTE,
                            "extdt-header-sort-img", null);
                    writer.endElement(HTML.IMG_ELEMENT);
                }
                writer.endElement(HTML.SPAN_ELEM);
            }

            writer.endElement(HTML.DIV_ELEM);

            if (col.getFilterMethod() == null
                    && col.getValueExpression("filterExpression") == null
                    && col.getValueExpression("filterBy") != null) {

                writer.startElement(HTML.DIV_ELEM, column);
                addInplaceInput(context, column, buildAjaxFunction(context,
                        column, false, null));
                writer.endElement(HTML.DIV_ELEM);
View Full Code Here

        public void encodeBegin(FacesContext context, ResponseWriter writer,
                UIComponent column, String facetName, boolean sortableColumn)
                throws IOException {
            if (column instanceof UIColumn) {
                UIColumn dataColumn = (UIColumn) column;
                String clientId = dataColumn.getClientId(context);// +
                // facetName;
                writer.writeAttribute("id", clientId, null);
                column.getAttributes().put("columnClientId", clientId);
                boolean sortable = sortableColumn && dataColumn.isSelfSorted();
                if (sortable) {
                    /*
                     * writer.writeAttribute(HTML.onclick_ATTRIBUTE,
                     * buildAjaxFunction( context, column, true,
                     * getOnAjaxCompleteFunction(context, (UIDataTable)
                     * column.getParent())) .toString(), null);
                     */
                    writer.writeAttribute(HTML.style_ATTRIBUTE,
                            "cursor: pointer;", null);
                }
                writer.writeAttribute("sortable", String.valueOf(sortable),
                        null);
                // column.getAttributes().put("sortable",Boolean.valueOf(sortable));
                // drag source area
                writer.startElement(HTML.DIV_ELEM, dataColumn);
                writer.writeAttribute(HTML.id_ATTRIBUTE, dataColumn.getParent()
                        .getClientId(context)
                        + "_hdrag_" + dataColumn.getId(), null);

                writer.startElement(HTML.DIV_ELEM, dataColumn);
                writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + ":sortDiv",
                        null);
                AjaxContext.getCurrentInstance().addRenderedArea(
View Full Code Here

        public void encodeEnd(FacesContext context, ResponseWriter writer,
                UIComponent column, String facetName, boolean sortableColumn)
                throws IOException {
            if (column instanceof UIColumn) {
                UIColumn dataColumn = (UIColumn) column;
                String clientId = dataColumn.getClientId(context) + facetName;
                String tableId = dataColumn.getParent().getClientId(context);

                if (sortableColumn) {
                    String imageUrl = null;
                    if (Ordering.ASCENDING.equals(dataColumn.getSortOrder())) {
                        if (null != dataColumn.getSortIconAscending()) {
                            imageUrl = dataColumn.getSortIconAscending();
                        } else {
                            imageUrl = getResource(
                                    TriangleIconUp.class.getName()).getUri(
                                    context, null);
                        }
                    } else if (Ordering.DESCENDING.equals(dataColumn
                            .getSortOrder())) {
                        if (null != dataColumn.getSortIconDescending()) {
                            imageUrl = dataColumn.getSortIconDescending();
                        } else {
                            imageUrl = getResource(
                                    TriangleIconDown.class.getName()).getUri(
                                    context, null);
                        }
                    } else if (dataColumn.isSelfSorted()) {
                        if (null != dataColumn.getSortIcon()) {
                            imageUrl = dataColumn.getSortIcon();
                        } else {
                            imageUrl = getResource(
                                    DataTableIconSortNone.class.getName())
                                    .getUri(context, null);
                        }
                    }

                    if (imageUrl != null) {
                        writer.startElement(HTML.IMG_ELEMENT, column);
                        writer.writeAttribute(HTML.src_ATTRIBUTE, imageUrl,
                                null);
                        writer.writeAttribute(HTML.width_ATTRIBUTE, "15", null);
                        writer
                                .writeAttribute(HTML.height_ATTRIBUTE, "15",
                                        null);
                        writer.writeAttribute(HTML.class_ATTRIBUTE,
                                "extdt-header-sort-img", null);
                        writer.endElement(HTML.IMG_ELEMENT);
                    }
                    writer.endElement(HTML.SPAN_ELEM);
                }

                writer.endElement(HTML.DIV_ELEM);

                // drag source area
                writer.endElement(HTML.DIV_ELEM);
                String dragSourceId = tableId + "_hdrag_" + dataColumn.getId();
                String indicatorId = tableId + ":dataTable_indicator";
                renderDragSupport(context, dataColumn, dragSourceId,
                        indicatorId, (String)dataColumn.getAttributes().get("label"));

                // separator area
                writer.startElement(HTML.SPAN_ELEM, column);
                writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + ":sepSpan",
                        null);
                writer
                        .writeAttribute(HTML.class_ATTRIBUTE, "extdt-hsep",
                                null);
                writer.endElement(HTML.SPAN_ELEM);

                // drop target area LEFT
                String spanId = tableId + "_hdrop_" + dataColumn.getId()
                        + "left";
                writer.startElement(HTML.SPAN_ELEM, column);
                writer.writeAttribute(HTML.id_ATTRIBUTE, spanId, null);
                writer.writeAttribute(HTML.class_ATTRIBUTE, "extdt-hdrop",
                        null);
                writer.writeAttribute(HTML.style_ATTRIBUTE,
                        "visibility: hidden;", null);
                writer.startElement(HTML.SPAN_ELEM, column);
                writer.writeAttribute(HTML.class_ATTRIBUTE,
                        "extdt-hdrop-top extdt-hdrop-top-left", null);
                writer.writeAttribute(HTML.style_ATTRIBUTE,
                        "visibility: hidden;", null);
                writer.endElement(HTML.SPAN_ELEM);
                writer.startElement(HTML.SPAN_ELEM, column);
                writer.writeAttribute(HTML.class_ATTRIBUTE,
                        "extdt-hdrop-bottom extdt-hdrop-bottom-left", null);
                writer.writeAttribute(HTML.style_ATTRIBUTE,
                        "visibility: hidden;", null);
                writer.endElement(HTML.SPAN_ELEM);
                writer.endElement(HTML.SPAN_ELEM);
                renderDropSupport(context, dataColumn, spanId, true);

                // drop target area RIGHT
                spanId = tableId + "_hdrop_" + dataColumn.getId() + "right";
                writer.startElement(HTML.SPAN_ELEM, column);
                writer.writeAttribute(HTML.id_ATTRIBUTE, spanId, null);
                writer.writeAttribute(HTML.class_ATTRIBUTE, "extdt-hdrop",
                        null);
                writer.writeAttribute(HTML.style_ATTRIBUTE,
View Full Code Here

     * @throws IOException
     */
    protected void buildMenuItem(UIComponent parent, UIColumn col)
            throws IOException {
        if (col instanceof UIColumn) {
            UIColumn dataColumn = (UIColumn) col;
            UIMenuItem menuItem = (UIMenuItem) context.getApplication()
                    .createComponent(UIMenuItem.COMPONENT_TYPE);

            menuItem.setSubmitMode("none");
            Boolean v = dataColumn.isVisible();
            boolean columnVisible = (v == null ? Boolean.TRUE : v);
            String actionScript = null;
            StringBuilder actionScriptBuilder = new StringBuilder();

            menuItem.setStyle("text-align: left;");

            if ((!columnVisible) || (visibleColumnsCount > 1)) {
                if (changeColumnVisibilityFunction != null) {
                    if (prepareFunction != null) {
                        actionScriptBuilder.append(prepareFunction.toScript())
                                .append("; ");
                    }
                    actionScriptBuilder.append(changeColumnVisibilityFunction
                            .toScript());
                    actionScript = actionScriptBuilder.toString();
                    if (actionScript.contains("{columnId}"))
                        actionScript = actionScript.replace("{columnId}",
                                dataColumn.getId());
                }
            }// if
            String label = (String)dataColumn.getAttributes().get("label");
            menuItem.setValue(label == null ? "" : label);
            menuItem.setIcon(columnVisible ? iconCheckedURI : iconUncheckedURI);
            if (menuItem instanceof HtmlMenuItem) {
                ((HtmlMenuItem) menuItem)
                        .setOnclick(actionScript == null ? "return false;"
View Full Code Here

TOP

Related Classes of org.richfaces.component.UIColumn

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.