Package org.richfaces.component

Examples of org.richfaces.component.UIColumn


                boolean filtering = false;

                boolean isGroupingOn = table.isGroupingOn();
                boolean sortByGroupingColumn = false;
                // String groupingColumnId = null;
                UIColumn groupingColumn = null;
                if (isGroupingOn) {
                    groupingColumn = table.getGroupByColumn();
                    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.setGroupByColumn(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) {
//                          //set focus on changed field
//                          AjaxContext.getCurrentInstance().getResponseDataMap().put(AjaxActionComponent.FOCUS_DATA_ID, filterValueInput.getClientId(context));
//                        }
                        filtering = (filtering || filterChanged);
                    }
                }
          if (AjaxRendererUtils.isAjaxRequest(context)) {
            AjaxRendererUtils.addRegionsFromComponent(table, context);
          }
                // 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.setGroupByColumn(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.isRendered()) {
        String menuId = menuRenderer.renderMenu(context, table, col);
        ajaxContext.addRenderedArea(menuId);
      }
        }// for
        table.setRowKey(key);
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);
                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);

                String imageUrl = null;
                if (sortableColumn) {
                    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);
                        }
                    }
                }
                else{
                  //set empty image
                  imageUrl = getResource("/org/richfaces/renderkit/html/images/s.gif").getUri(context, null);
                }
                if (imageUrl != null) {
                    writer.startElement(HTML.IMG_ELEMENT, column);
                    writer.writeAttribute(HTML.src_ATTRIBUTE, imageUrl,
                            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

    public void encodeColumns(FacesContext context,
            UIExtendedDataTable table) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        Iterator<UIColumn> cols = table.getSortedColumns();
        while (cols.hasNext()) {
            UIColumn col = cols.next();
            if (col.isRendered()) {
                writer.startElement("col", table);
                String colWidth = table.getColumnSize(col);
                writer.writeAttribute("width", colWidth, null);
                writer.endElement("col");
            }
View Full Code Here

     */
    private boolean filteringEnabled(UIExtendedDataTable table) {
        Iterator<UIColumn> columns = table.getSortedColumns();
        boolean enabled = false;
        while (columns.hasNext()) {
            UIColumn col = columns.next();
            if ((internalFilterEnabledColumn(col) || (col.getFacet("filter") != null)) &&
                col.isRendered()
        ) {
        enabled = true;
        break;
      }
        }
View Full Code Here

            ResponseWriter writer, UIDataTable table,
            Iterator<UIColumn> headers, String skinCellClass,
            String headerClass, String facetName, String element)
            throws IOException {
        while (headers.hasNext()) {
            UIColumn column = headers.next();
            if (column instanceof UIColumn) {
                if (column.isRendered()) {
                    writer.startElement(element, table);
                    String classAttribute = facetName + "Class";
                    String columnHeaderClass = (String) column.getAttributes()
                            .get(classAttribute);
                    encodeStyleClass(writer, null, skinCellClass, headerClass,
                            columnHeaderClass);
                    UIColumn dataColumn = (UIColumn) column;
                    if (internalFilterEnabledColumn(dataColumn)) {
                        writer.startElement(HTML.DIV_ELEM, column);
                        addInplaceInput(context, column);
                        writer.endElement(HTML.DIV_ELEM);
                    }
                    else if (dataColumn.getFacet("filter") != null) {
                      writer.startElement(HTML.DIV_ELEM, column);
                      dataColumn.getFacet("filter").encodeAll(context);
                      writer.endElement(HTML.DIV_ELEM);
                    }
                    else {
                      encodeNBSP(writer);
                    }
View Full Code Here

        // RichHeaderEncodeStrategy();
        // HeaderEncodeStrategy simpleEncodeStrategy = new
        // SimpleHeaderEncodeStrategy();

        while (headers.hasNext()) {
            UIColumn column = headers.next();
            if (isColumnRendered(column)) {
                if ((Integer) column.getAttributes().get("colspan") != null) {
                    t_colCount = t_colCount
                            + ((Integer) column.getAttributes().get("colspan"))
                                    .intValue();
                } else {
                    t_colCount++;
                }
                if (t_colCount > colCount) {
                    break;
                }

                String classAttribute = facetName + "Class";
                String columnHeaderClass = (String) column.getAttributes().get(
                        classAttribute);

                writer.startElement(element, column);
                encodeStyleClass(writer, null, skinCellClass, headerClass,
                        columnHeaderClass);
                writer.writeAttribute("scope", "col", null);
                getUtils().encodeAttribute(context, column, "colspan");

                boolean sortableColumn = column
                        .getValueExpression("comparator") != null
                        || column.getValueExpression("sortBy") != null;
                column.getAttributes().put("sortable",
                        Boolean.valueOf(sortableColumn));

                HeaderEncodeStrategy strategy = (column instanceof UIColumn && "header"
                        .equals(facetName)) ? new G3HeaderEncodeStrategy()
                        : new SimpleHeaderEncodeStrategy();

                strategy.encodeBegin(context, writer, column, facetName,
                        sortableColumn);

                UIComponent facet = column.getFacet(facetName);
                if (facet != null && isColumnRendered(facet)) {
                    renderChild(context, facet);
                }

                strategy.encodeEnd(context, writer, column, facetName,
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.