Examples of ComboBoxFilter


Examples of org.openfaces.component.filter.ComboBoxFilter

    }

    @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 &&
                    currentCriterionStr.equals(criterionName);
            writeOption(writer, component,
                    USER_CRITERION_PREFIX + criterionName,
                    criterionName,
                    selected, null);
            if (selected)
                textCriterionSelected = true;
        }
        boolean noRecordsWithSelectedCriterion = currentCriterion != null && condition != FilterCondition.EMPTY && !textCriterionSelected;
        if (noRecordsWithSelectedCriterion) {
            writeOption(writer, component,
                    USER_CRITERION_PREFIX + currentCriterionStr,
                    currentCriterionStr,
                    true, null);
        }

        UIComponent filteredComponent = (UIComponent) filter.getFilteredComponent();

        Rendering.renderInitScript(context,
                new ScriptBuilder().functionCall("O$.Filters._showFilter",
                        filteredComponent, clientId).semicolon(),
                Resources.utilJsURL(context),
View Full Code Here

Examples of org.openfaces.component.filter.ComboBoxFilter

        super.decode(context, component);
        Map<String, String> requestParameterMap = context.getExternalContext().getRequestParameterMap();
        String selectedCriterion = requestParameterMap.get(component.getClientId(context));
        if (selectedCriterion == null)
            return;
        ComboBoxFilter filter = ((ComboBoxFilter) component);
        if (selectedCriterion.startsWith(USER_CRITERION_PREFIX)) {
            String searchString = selectedCriterion.substring(USER_CRITERION_PREFIX.length());
            setDecodedString(filter, searchString);
        } else if (selectedCriterion.startsWith(PREDEFINED_CRITERION_PREFIX)) {
            String criterion = selectedCriterion.substring(PREDEFINED_CRITERION_PREFIX.length());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.