Package org.openfaces.component.input

Examples of org.openfaces.component.input.Spinner


            spinner.setConverter(numberConverter);
        }
    }

    protected InitScript renderInitScript(FacesContext context, DropDownComponent dropDown) throws IOException {
        Spinner spinner = (Spinner) dropDown;
        if (spinner.getStep().doubleValue() <= 0) {
            throw new FacesException("The 'step' attribute of <o:spinner> with id " + spinner.getClientId(context) +
                    " should be greater then 0, but was " + spinner.getStep());
        }

        String buttonStyle = (String) dropDown.getAttributes().get("buttonStyle");
        String buttonClass = (String) dropDown.getAttributes().get("buttonClass");
        String buttonStyleClass = Styles.getCSSClass(context, dropDown, buttonStyle, DEFAULT_BUTTON_CLASS, buttonClass);
        String rolloverButtonStyle = (String) dropDown.getAttributes().get("rolloverButtonStyle");
        String rolloverButtonClass = (String) dropDown.getAttributes().get("rolloverButtonClass");
        String buttonRolloverStyleClass = Styles.getCSSClass(context, dropDown, rolloverButtonStyle, StyleGroup.rolloverStyleGroup(), rolloverButtonClass, DEFAULT_BUTTON_ROLLOVER_CLASS);
        String pressedButtonStyle = (String) dropDown.getAttributes().get("pressedButtonStyle");
        String pressedButtonClass = (String) dropDown.getAttributes().get("pressedButtonClass");
        String buttonPressedStyleClass = Styles.getCSSClass(context, dropDown, pressedButtonStyle, StyleGroup.rolloverStyleGroup(2), pressedButtonClass, DEFAULT_BUTTON_PRESSED_CLASS);

        if (dropDown.isDisabled()) {
            buttonRolloverStyleClass = "";
            String disabledButtonStyle = (String) dropDown.getAttributes().get("disabledButtonStyle");
            String disabledButtonClass = (String) dropDown.getAttributes().get("disabledButtonClass");
            String disabledButtonStyleClass = Styles.getCSSClass(context, dropDown, disabledButtonStyle,
                    StyleGroup.disabledStyleGroup(), disabledButtonClass, DEFAULT_DISABLED_BUTTON_CLASS);

            if (Rendering.isNullOrEmpty(disabledButtonStyle) && Rendering.isNullOrEmpty(disabledButtonClass)) {
                buttonStyleClass = Styles.mergeClassNames(disabledButtonStyleClass, buttonStyleClass);
            } else {
                buttonStyleClass = Styles.mergeClassNames(disabledButtonStyleClass, Styles.getCSSClass(context,
                        dropDown, null, StyleGroup.regularStyleGroup(), null, DEFAULT_BUTTON_CLASS));
            }
        }

        JSONObject options;
        try {
            options = createFormatOptions(context, spinner);
        } catch (JSONException e) {
            throw new FacesException(e);
        }

        ScriptBuilder sb = new ScriptBuilder().initScript(context, spinner, "O$.Spinner._init",
                spinner.getMinValue(),
                spinner.getMaxValue(),
                spinner.getStep(),
                spinner.isCycled(),
                buttonStyleClass,
                buttonRolloverStyleClass,
                buttonPressedStyleClass,
                spinner.isDisabled(),
                spinner.isRequired(),
                spinner.getOnchange(),
                options);

        return new InitScript(sb, new String[]{
                Resources.utilJsURL(context),
                getDropdownJsURL(context),
View Full Code Here


    }  

    @Override
    protected void writeFieldAttributes(ResponseWriter writer, DropDownComponent fieldComponent) throws IOException {
        super.writeFieldAttributes(writer, fieldComponent);
        Spinner spinner = ((Spinner) fieldComponent);
        if (!spinner.getTypingAllowed())
            writeAttribute(writer, "readonly", String.valueOf(!spinner.getTypingAllowed()));
    }
View Full Code Here

    }

    protected void encodeButton(FacesContext context, UIComponent component) throws IOException {
        FacesContext currentInstance = FacesContext.getCurrentInstance();
        Spinner spinner = (Spinner) component;
        ResponseWriter writer = context.getResponseWriter();

        String clientId = spinner.getClientId(currentInstance);
        String increaseButtonId = clientId + INCREASE_BUTTON_SUFFIX;
        String decreaseButtonId = clientId + DECREASE_BUTTON_SUFFIX;
        encodeRootElementStart(writer, spinner);
        writer.writeAttribute("nowrap", "nowrap", null);
        writer.writeAttribute("height", "100%", null);
View Full Code Here

    protected void encodeButton(FacesContext context, UIComponent component, String buttonID,
                                String imageUrlAttr, String defaultImagePath,
                                String disabledImageUrlAttr, String defaultDisabledImagePath) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        Spinner spinner = (Spinner) component;

        writer.startElement("tr", spinner);
        writer.startElement("td", spinner);

        writer.writeAttribute("id", buttonID, null);
        writer.writeAttribute("align", "center", null);
        writer.writeAttribute("valign", "middle", null);
        String resultImageUrl;
        if (spinner.isDisabled()) {
            String disabledButtonImageUrl = (String) spinner.getAttributes().get(disabledImageUrlAttr);
            resultImageUrl = Resources.getURL(context, disabledButtonImageUrl, null, defaultDisabledImagePath);
        } else {
            String buttonImageUrl = (String) spinner.getAttributes().get(imageUrlAttr);
            resultImageUrl = Resources.getURL(context, buttonImageUrl, null, defaultImagePath);
        }
        writer.startElement("img", spinner);
        writer.writeAttribute("src", resultImageUrl, null);
        writer.endElement("img");
View Full Code Here

        return (Spinner) Components.getChildBySuffix(container, SPINNER_BEFORE_ID_SUFFIX);
    }

    private Spinner createSpinnerBefore(FacesContext context, UIComponent container) {
        clearContainer(container);
        Spinner spinner = (Spinner) Components.createChildComponent(context, container, Spinner.COMPONENT_TYPE, SPINNER_BEFORE_ID_SUFFIX);
        spinner.setStyleClass(FilterRow.DEFAULT_PARAMETER_CLASS);
        spinner.setStyle("width: 70px;");
        return spinner;
    }
View Full Code Here

    private Spinner getSpinnerAfter(UIComponent container) {
        return (Spinner) Components.getChildBySuffix(container, SPINNER_AFTER_ID_SUFFIX);
    }

    private Spinner createSpinnerAfter(FacesContext context, UIComponent container) {
        Spinner spinner = (Spinner) Components.createChildComponent(context, container, Spinner.COMPONENT_TYPE, SPINNER_AFTER_ID_SUFFIX);
        spinner.setStyleClass(FilterRow.DEFAULT_PARAMETER_CLASS);
        spinner.setStyle("width: 70px;");
        return spinner;
    }
View Full Code Here

    }


    public void prepare(FacesContext context, CompositeFilter compositeFilter, FilterRow filterRow, UIComponent container) {
        super.prepare(context, compositeFilter, filterRow, container);
        Spinner spinnerBefore = getSpinnerBefore(container);
        if (spinnerBefore == null) {
            spinnerBefore = createSpinnerBefore(context, container);
        }
        initSpinnerBefore(spinnerBefore);

        Spinner spinnerAfter = getSpinnerAfter(container);
        if (spinnerAfter == null) {
            spinnerAfter = createSpinnerAfter(context, container);
        }
        initSpinnerAfter(spinnerAfter);
View Full Code Here

        initSpinnerAfter(spinnerAfter);

    }

    public void update(FacesContext context, CompositeFilter compositeFilter, FilterRow filterRow, UIComponent container) {
        Spinner spinnerBefore = getSpinnerBefore(container);
        if (spinnerBefore == null) {
            return;
        }
        criterion.setArg1(spinnerBefore.getValue());

        Spinner spinnerAfter = getSpinnerAfter(container);
        if (spinnerAfter == null) {
            return;
        }
        criterion.setArg2(spinnerAfter.getValue());
    }
View Full Code Here

        return (Spinner) Components.getChildBySuffix(container, SPINNER_ID_SUFFIX);
    }

    private Spinner createSpinner(FacesContext context, UIComponent container) {
        clearContainer(container);
        Spinner spinner = (Spinner) Components.createChildComponent(context, container, Spinner.COMPONENT_TYPE, SPINNER_ID_SUFFIX);
        spinner.setStep(filterProperty.getStep());
        spinner.setMinValue(filterProperty.getMinValue());
        spinner.setMaxValue(filterProperty.getMaxValue());
        //spinner.setStyleClass(FilterRow.DEFAULT_PARAMETER_CLASS);
        //spinner.setStyle("width: 70px;");
        return spinner;
    }
View Full Code Here

        spinner.setValue(criterion.getArg1());
    }

    public void prepare(FacesContext context, CompositeFilter compositeFilter, FilterRow filterRow, UIComponent container) {
        super.prepare(context, compositeFilter, filterRow, container);
        Spinner spinner = getSpinner(container);
        if (spinner == null) {
            spinner = createSpinner(context, container);
        }
        initSpinner(spinner);
    }
View Full Code Here

TOP

Related Classes of org.openfaces.component.input.Spinner

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.