Package org.openfaces.component.filter

Examples of org.openfaces.component.filter.ExpressionFilterCriterion


        if (parts.length == 2) {
            if (!parts[0].equals("not"))
                throw new FacesException("Improper 'condition' attribute value: \"" + value + "\". It should be of \"<condition>\" or \"not <condition>\", where <condition> is one of: " + possibleConditionsStr +"; but it was: " + value);
            inverse = true;
        }
        ExpressionFilterCriterion filterCriterion = new ExpressionFilterCriterion(condition, inverse);
        filter.setCondition(filterCriterion);
    }
View Full Code Here


    private List<TestBean> filterCollection(List<TestBean> sortedList, CompositeFilterCriterion filterCriteria) {
        List<TestBean> result = new ArrayList<TestBean>();
        for (TestBean record : sortedList) {
            boolean recordAccepted = true;
            for (FilterCriterion c : filterCriteria.getCriteria()) {
                ExpressionFilterCriterion criterion = (ExpressionFilterCriterion) c;
                String fieldName = criterion.getExpressionStr();

                if (!filterAcceptsRecord(fieldName, criterion, record)) {
                    recordAccepted = false;
                    break;
                }
View Full Code Here

    private String getFilterCriteriaQueryText(CompositeFilterCriterion filterCriteria) {
        StringBuffer buf = new StringBuffer();
        for (Iterator<FilterCriterion> it = filterCriteria.getCriteria().iterator(); it.hasNext();) {
            FilterCriterion c = it.next();
            ExpressionFilterCriterion criterion = (ExpressionFilterCriterion) c;
            String filterId = criterion.getExpressionStr();

            String text = criterion.getArg1().toString();
            String criterionText = filterId + " CONTAINS \"" + text + "\"";
            buf.append(criterionText);
            if (it.hasNext())
                buf.append(" AND ");
        }
View Full Code Here

        }
        List<Color> filtered = new ArrayList<Color>();
        for (Color tempColor : colorsToFilter) {
            boolean colorAccepted = true;
            for (FilterCriterion c: criteria.getCriteria()) {
                ExpressionFilterCriterion criterion = (ExpressionFilterCriterion) c;
                String criterionUC = criterion.getArg1().toString().toUpperCase();
                String colorNameUC = tempColor.getName().toUpperCase();
                if (colorNameUC.indexOf(criterionUC) == -1) {
                    colorAccepted = false;
                }
            }
View Full Code Here

    }

    private CitiesDB.CitySelectionCriteria calculateFilterConditions(CompositeFilterCriterion filterCriteria) {
        CitiesDB.CitySelectionCriteria filterConditions = new CitiesDB.CitySelectionCriteria();
        for (FilterCriterion entry : filterCriteria.getCriteria()) {
            ExpressionFilterCriterion criterion = (ExpressionFilterCriterion) entry;
            String columnId = criterion.getExpressionStr();
            String searchString = criterion.getArg1().toString();
            if (columnId.equals("name")) {
                filterConditions.setCityNameSearchString(searchString);
            } else if (columnId.equals("population")) {
                String[] result = searchString.split(" \u2013 ");
View Full Code Here

            FacesContext context = FacesContext.getCurrentInstance();
            if (facesMessage == null)
                facesMessage = new FacesMessage("Conversion error");
            context.addMessage(filter.getClientId(context), facesMessage);
        }
        ExpressionFilterCriterion oldCriterion = (ExpressionFilterCriterion) filter.getValue();
        ExpressionFilterCriterion newCriterion;
        if (oldCriterion != null &&
                !oldCriterion.getCondition().equals(FilterCondition.EMPTY) &&
                !oldCriterion.getCondition().equals(FilterCondition.CONTAINS)) {
            newCriterion = new ExpressionFilterCriterion(oldCriterion);
            newCriterion.setArg1(argAsObject);
        } else
            newCriterion = createDefaultCriterion(filter, argAsObject);
        setDecodedCriterion(filter, newCriterion);
    }
View Full Code Here

        Object expression = filter.getExpression();
        PropertyLocator propertyLocator = filter.getPropertyLocator();
        FilterCondition condition;

        boolean inverse = false;
        ExpressionFilterCriterion defaultCriterion = filter.getCondition();
        if (defaultCriterion != null) {
            condition = defaultCriterion.getCondition();
            inverse = defaultCriterion.isInverse();
        } else {
            FilterCondition forcedCondition = getForceDefaultCondition(filter);
            if (forcedCondition != null)
                condition = forcedCondition;
            else {
                UIComponent parent = filter.getParent();
                if (parent == null || !(parent instanceof BaseColumn))
                    condition = FilterCondition.CONTAINS;
                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))
                            condition = FilterCondition.CONTAINS;
                        else
                            condition = FilterCondition.CONTAINS;
                    } else {
                        // it is allowed to specify expression as a string, e.g. in case of custom data providing,
                        // in which case the actual filtering is performed by the application code so the condition
                        // specified in the ValueExpression object doesn't matter
                        condition = FilterCondition.CONTAINS;
                    }
                }
            }
        }

        ExpressionFilterCriterion criterion = new ExpressionFilterCriterion(
                propertyLocator,
                condition,
                specifiedValue);
        criterion.setInverse(inverse);
        criterion.setCaseSensitive(filter.isCaseSensitive());
        return criterion;
    }
View Full Code Here

        if (operation == null || parametersEditor == null) {
            parametersEditor = null;
            return null;
        }
        parametersEditor.update(context, compositeFilter, this, parametersEditorContainer);
        ExpressionFilterCriterion result = parametersEditor.getCriterion();
        result.setInverse(inverse);
        if (operationModified) {
            parametersEditor = null;
        }
        return result;
    }
View Full Code Here

        Resources.renderJSLinkIfNeeded(context, Resources.filtersJsURL(context));
        TextSearchFilter filter = (TextSearchFilter) component;

        UIInput inputComponent = (UIInput) filter.getSearchComponent();
        inputComponent.setConverter(filter.getConverter());
        ExpressionFilterCriterion filterCriterion = (ExpressionFilterCriterion) filter.getValue();
        inputComponent.setValue(filterCriterion != null ? filterCriterion.getArg1() : null);
        configureInputComponent(context, filter, inputComponent);
        configureInputFromFilter(filter, inputComponent);

        inputComponent.encodeAll(context);
View Full Code Here

    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        super.encodeBegin(context, component);
        ComboBoxFilter filter = ((ComboBoxFilter) component);

        ExpressionFilterCriterion currentCriterion = (ExpressionFilterCriterion) filter.getValue();

        ResponseWriter writer = context.getResponseWriter();
        writer.startElement("select", component);
        String clientId = writeIdAttribute(context, component);
        writeNameAttribute(context, component);
        writer.writeAttribute("size", "1", null);
        Rendering.writeStyleAndClassAttributes(writer, filter.getStyle(), filter.getStyleClass(), "o_fullWidth");
        writer.writeAttribute("onchange", getFilterSubmissionScript(filter), null);
        writer.writeAttribute("onclick", "event.cancelBubble = true;", null);
        writer.writeAttribute("onkeydown", "O$.stopEvent(event);", null);
        writer.writeAttribute("dir", filter.getDir(), "dir");
        writer.writeAttribute("lang", filter.getLang(), "lang");

        boolean thereAreEmptyItems = false;
        Collection<Object> criterionNamesCollection = filter.calculateAllCriterionNames(context);
        for (Iterator<Object> criterionIterator = criterionNamesCollection.iterator(); criterionIterator.hasNext();) {
            Object criterionObj = criterionIterator.next();
            if (isEmptyItem(criterionObj)) {
                thereAreEmptyItems = true;
                criterionIterator.remove();
            }
        }
        List<Object> criterionNames = new ArrayList<Object>(criterionNamesCollection);

        String allRecordsCriterionName = filter.getAllRecordsText();

        String predefinedCriterionsClass = getPredefinedCriterionClass(context, filter);
        writeOption(writer, component, PREDEFINED_CRITERION_PREFIX + ALL, allRecordsCriterionName,
                currentCriterion == null,
                predefinedCriterionsClass);
        FilterCondition condition = currentCriterion != null ? currentCriterion.getCondition() : null;
        if (thereAreEmptyItems) {
            String emptyRecordsCriterionName = filter.getEmptyRecordsText();
            writeOption(writer, component, PREDEFINED_CRITERION_PREFIX + EMPTY, emptyRecordsCriterionName,
                    condition != null && condition.equals(FilterCondition.EMPTY) && !currentCriterion.isInverse(),
                    predefinedCriterionsClass);

            String nonEmptyRecordsCriterionName = filter.getNonEmptyRecordsText();
            writeOption(writer, component, PREDEFINED_CRITERION_PREFIX + NON_EMPTY,
                    nonEmptyRecordsCriterionName,
                    condition != null && condition.equals(FilterCondition.EMPTY) && currentCriterion.isInverse(),
                    predefinedCriterionsClass);
        }

        Converter converter = getConverter(filter);
        Object currentCriterionArg = currentCriterion != null ? currentCriterion.getArg1() : null;
        String currentCriterionStr = converter.getAsString(context, filter, currentCriterionArg);
        boolean textCriterionSelected = false;
        for (Object criterionObj : criterionNames) {
            String criterionName = converter.getAsString(context, filter, criterionObj);
            boolean selected = currentCriterion instanceof ExpressionFilterCriterion &&
View Full Code Here

TOP

Related Classes of org.openfaces.component.filter.ExpressionFilterCriterion

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.