Package org.primefaces.component.column

Examples of org.primefaces.component.column.Column


   
    for (Iterator<UIComponent> iterator = dataTable.getChildren().iterator(); iterator.hasNext();) {
      UIComponent kid = iterator.next();
     
      if(kid.isRendered() && kid instanceof Column) {
        Column column = (Column) kid;
       
        if(column.getSelectionMode() == null) {
          writer.startElement("th", column);
          if(column.getFacet("header") != null) {
            renderChild(facesContext, column.getFacet("header"));
          }
          writer.endElement("th");
        }
      }
    }
View Full Code Here


     
      for(Iterator<UIComponent> iterator = dataTable.getChildren().iterator(); iterator.hasNext();) {
        UIComponent kid = iterator.next();
       
        if(kid.isRendered() && kid instanceof Column) {
          Column column = (Column) kid;
          if(column.getSelectionMode() == null) {
            writer.startElement("td", null);
         
            renderChildren(facesContext, column);
         
            writer.endElement("td");
View Full Code Here

        TableConfig config = cfg.getTable(tableName);
        Application app = FacesContext.getCurrentInstance().getApplication();

        for (ColumnConfig col : config.getColumns()) {
            Column cl = (Column) app.createComponent(Column.COMPONENT_TYPE);

            if (col.getFilter() != null && !col.getFilter().isEmpty())
                cl.setValueExpression("filterBy", JsfUtil.getExpression(col.getFilter()));

            if (col.getSort() != null && !col.getSort().isEmpty())
                cl.setValueExpression("sortBy", JsfUtil.getExpression(col.getSort()));

            if (col.getFilterEvent() != null && !col.getFilterEvent().isEmpty())
                cl.setValueExpression("filterEvent", JsfUtil.getExpression(col.getFilterEvent()));

            if (col.getFilterOptions() != null && !col.getFilterOptions().isEmpty())
                cl.setValueExpression("filterOptions", JsfUtil.getExpression(col.getFilterOptions()));

            if (col.getSortFunction() != null && !col.getSortFunction().isEmpty())
                cl.setSortFunction(col.getSortFunctionExp());

            if (col.getColspan() != null && !col.getColspan().isEmpty())
                cl.setValueExpression("colspan", JsfUtil.getExpression(col.getColspan()));

            if (col.getFilterStyle() != null && !col.getFilterStyle().isEmpty())
                cl.setValueExpression("filterStyle", JsfUtil.getExpression(col.getFilterStyle()));

            if (col.getStyle() != null && !col.getStyle().isEmpty())
                cl.setValueExpression("style", JsfUtil.getExpression(col.getStyle()));

            if (col.getName() != null && !col.getName().isEmpty())
                cl.setValueExpression("headerText", JsfUtil.getExpression(col.getName()));

            /*
             * Output text
             */
            HtmlOutputText text = (HtmlOutputText)FacesContext.getCurrentInstance().getApplication().createComponent(HtmlOutputText.COMPONENT_TYPE);
            text.setValueExpression("value", JsfUtil.getExpression (col.getValue()));
            text.setValueExpression("style", JsfUtil.getExpression (col.getTextStyle()));

            if (col.getConverter() != null && !col.getConverter().isEmpty()) {
                try {
                    text.setConverter((Converter)Class.forName(col.getConverter()).newInstance());
                }
                catch (Exception ex) {
                    Logger.getLogger(JsfUtil.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            cl.getChildren().add(text);
            table.getChildren().add(cl);
//            table.getColumns().add(cl);
        }
    }
View Full Code Here

        String clientId = table.getClientId(context);
        Map<String, String> params = context.getExternalContext().getRequestParameterMap();

        String sortKey = params.get(clientId + "_sortKey");
        boolean asc = Boolean.valueOf(params.get(clientId + "_sortDir"));
        Column sortColumn = null;

        ColumnGroup group = table.getColumnGroup("header");
        if (group != null) {
            outer:
            for (UIComponent child : group.getChildren()) {
                Row headerRow = (Row) child;
                for (UIComponent headerRowChild : headerRow.getChildren()) {
                    Column column = (Column) headerRowChild;
                    if (column.getClientId(context).equals(sortKey)) {
                        sortColumn = column;
                        break outer;
                    }
                }
            }
        }
        else {
            //single header row
            for (Column column : table.getColumns()) {
                if (column.getClientId(context).equals(sortKey)) {
                    sortColumn = column;
                    break;
                }
            }
        }
View Full Code Here

        if (table.isLazy()) {
            Map<String, String> filters = new HashMap<String, String>();
            Map<String, Column> filterMap = table.getFilterMap();

            for (String filterName : filterMap.keySet()) {
                Column column = filterMap.get(filterName);
                String filterValue = params.get(filterName);

                if (!isValueBlank(filterValue)) {
                    String filterField = resolveField(column.getValueExpression("filterBy"));
                    filters.put(filterField, filterValue);
                }
            }

            table.setFilters(filters);

            //Metadata for callback
            if (table.isPaginator()) {
                RequestContext.getCurrentInstance().addCallbackParam("totalRecords", table.getRowCount());
            }
        }
        else {
            Map<String, Column> filterMap = table.getFilterMap();
            List filteredData = new ArrayList();

            String globalFilter = params.get(clientId + UINamingContainer.getSeparatorChar(context) + "globalFilter");
            boolean hasGlobalFilter = !isValueBlank(globalFilter);
            if (hasGlobalFilter) {
                globalFilter = globalFilter.toLowerCase();
            }

            for (int i = 0; i < table.getRowCount(); i++) {
                table.setRowIndex(i);
                boolean localMatch = true;
                boolean globalMatch = false;

                for (String filterName : filterMap.keySet()) {
                    Column column = filterMap.get(filterName);
                    String columnFilter = params.get(filterName);
                    if (columnFilter != null)
                        columnFilter = columnFilter.toLowerCase();
                   
                    /*
                     * TODO replace with getValueExpression
                     */
                    String columnValue = String.valueOf(column.getValueExpression("filterBy").getValue(context.getELContext()));
                    columnValue = String.valueOf (JsfUtil.getExpressionValue("#{" + columnValue + "}"));
                    if (columnValue != null)
                        columnValue = columnValue.toLowerCase();

                    if (hasGlobalFilter && !globalMatch) {
                        if (columnValue != null && columnValue.toLowerCase().contains(globalFilter)) {
                            globalMatch = true;
                        }
                    }

                    if (isValueBlank(columnFilter)) {
                        localMatch = true;
                    }
                    else if (columnValue == null || !column.getFilterConstraint().applies(columnValue.toLowerCase(), columnFilter)) {
                        localMatch = false;
                        break;
                    }
                }

View Full Code Here

            for(UIComponent child : group.getChildren()) {
                Row headerRow = (Row) child;

                if(headerRow.isRendered()) {
                    for(UIComponent headerRowChild : headerRow.getChildren()) {
                        Column column = (Column) headerRowChild;

                        if(column.isRendered()) {
                            ValueExpression columnFilterByVE = column.getValueExpression("filterBy");
                            Object filterByProperty = column.getFilterBy();
                           
                            if(columnFilterByVE != null || filterByProperty != null) {
                                ValueExpression filterByVE = (columnFilterByVE != null) ? columnFilterByVE : createFilterByVE(context, var, filterByProperty);
                                UIComponent filterFacet = column.getFacet("filter");
                                Object filterValue;
                               
                                if(filterFacet == null)
                                    filterValue = params.get(column.getClientId(context) + separator + "filter");
                                else
                                    filterValue = ((ValueHolder) filterFacet).getLocalValue();

                                filterMetadata.add(new FilterMeta(column, filterByVE, filterValue));
                            }
                        }
                    }
                }
            }
        }
        else {
            for(UIColumn column : table.getColumns()) {
                ValueExpression columnFilterByVE = column.getValueExpression("filterBy");
                Object filterByProperty = column.getFilterBy();
               
                if (columnFilterByVE != null || filterByProperty != null) {
                    UIComponent filterFacet = column.getFacet("filter");
                    Object filterValue = null;
                    ValueExpression filterByVE = null;
                    String filterId = null;
                   
                    if(column instanceof Column) {
                        filterByVE = (columnFilterByVE != null) ? columnFilterByVE : createFilterByVE(context, var, filterByProperty);
                        filterId = column.getClientId(context) + separator + "filter";
                    }
                    else if(column instanceof DynamicColumn) {
                        DynamicColumn dynamicColumn = (DynamicColumn) column;
                        dynamicColumn.applyStatelessModel();
                        filterByProperty = column.getFilterBy();
                        filterByVE = (filterByProperty == null) ? columnFilterByVE : createFilterByVE(context, var, filterByProperty);
                        filterId = dynamicColumn.getContainerClientId(context) + separator + "filter";
                        dynamicColumn.cleanStatelessModel();
                    }
                   
View Full Code Here

        writer.writeAttribute("class", rowClass, null);
        writer.writeAttribute("role", "row", null);
       
        for(UIComponent child : row.getChildren()) {
            if(child instanceof Column && child.isRendered()) {
                Column column = (Column) child;
                String userStyleClass = column.getStyleClass();
                String styleClass = (userStyleClass == null) ? columnClass : columnClass + " " + userStyleClass;
                               
                writer.startElement("td", null);
                if(shouldWriteId(column)) {
                    writer.writeAttribute("id", column.getClientId(context), null);
                }
                writer.writeAttribute("role", columnRole, null);
                writer.writeAttribute("class", styleClass, null);
               
                if(column.getStyle() != null) writer.writeAttribute("style", column.getStyle(), null);
                if(column.getColspan() > 1) writer.writeAttribute("colspan", column.getColspan(), null);
                if(column.getRowspan() > 1) writer.writeAttribute("rowspan", column.getRowspan(), null);
               
                renderChildren(context, column);
               
                writer.endElement("td");
            }
View Full Code Here

                    writer.endElement("td");
                }
                       
                for(UIComponent kid : pickList.getChildren()) {
                    if(kid instanceof Column && kid.isRendered()) {
                        Column column = (Column) kid;

                        writer.startElement("td", null);
                        if(column.getStyle() != null) writer.writeAttribute("style", column.getStyle(), null);
                        if(column.getStyleClass() != null) writer.writeAttribute("class", column.getStyleClass(), null);

                        renderChildren(context, column);
                        writer.endElement("td");
                    }
                }
View Full Code Here

   
    writer.write("{key:'rowIndex', hidden:true}");
   
    for(UIComponent kid : dataTable.getChildren()) {
      if(kid.isRendered() && kid instanceof Column) {
        Column column = (Column) kid;
       
        writer.write(",");
       
        writer.write("{key:'" + column.getClientId(facesContext+ "'");
       
        //header
        UIComponent header = column.getFacet("header");
        writer.write(",label:'");
        if(header != null) {
          if(header.getClass().getName().equals("com.sun.facelets.compiler.UIInstructions")) {
            String instructionsValue = header.toString();
            if(instructionsValue != null) {
              writer.write(instructionsValue.trim());
            }
          } else {           
            renderChild(facesContext, column.getFacet("header"));
          }
         
          if(column.getValueExpression("filterBy") != null) {
            encodeColumnFilter(facesContext, column, datatableVar);
          }
        }
        writer.write("'");
       
        if(column.isResizable()) writer.write(",resizeable:true");
        if(column.getWidth() != Integer.MIN_VALUE) writer.write(",width:" + column.getWidth());
        if(column.getStyleClass() != null) writer.write(",className:'" + column.getStyleClass() + "'");
       
        //sorting
        if(column.getValueExpression("sortBy") != null) {
          writer.write(",sortable:true");
         
          if(!dataTable.isDynamic()) {
            writer.write(",sortOptions:{field:'" + column.getClientId(facesContext) + "'");
            if(column.getSortFunction() != null) {
              writer.write(",sortFunction:" + column.getSortFunction().getExpressionString());
            }
            writer.write("}");
           
            if(column.getParser() != null) writer.write(",parser:'" + column.getParser() + "'");
          }
        }
       
        writer.write("}");
      }
View Full Code Here

     
      for(Iterator<UIComponent> iterator = dataTable.getChildren().iterator(); iterator.hasNext();) {
        UIComponent kid = iterator.next();
       
        if(kid.isRendered() && kid instanceof Column) {
          Column column = (Column) kid;
         
          writer.startElement("td", null);
          renderChildren(facesContext, column);
          writer.endElement("td");
        }
View Full Code Here

TOP

Related Classes of org.primefaces.component.column.Column

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.