Package org.openfaces.component.calendar

Examples of org.openfaces.component.calendar.Calendar


                = (DateChooserPopup) context.getApplication().createComponent(DateChooserPopup.COMPONENT_TYPE);
        List<UIComponent> children = dateChooser.getChildren();
        popup.setParent(dateChooser); // todo: it's not correct according to setParent's JavaDoc to use this method from applications, the proper way is to use parent.getChildren().add

        popup.setId(component.getId() + POPUP_SUFFIX);
        Calendar c = (Calendar) context.getApplication().createComponent(Calendar.COMPONENT_TYPE);

        c.getAttributes().put(CalendarRenderer.HIDE_DEFAULT_FOCUS_KEY, Boolean.TRUE);

        if (dateChooser.isValid()) {
            c.setValue(dateChooser.getValue());
        }
        c.setTimeZone(dateChooser.getTimeZone());
        c.setStyle(dateChooser.getCalendarStyle());
        c.setDayStyle(dateChooser.getDayStyle());
        c.setRolloverDayStyle(dateChooser.getRolloverDayStyle());
        c.setInactiveMonthDayStyle(dateChooser.getInactiveMonthDayStyle());
        c.setRolloverInactiveMonthDayStyle(dateChooser.getRolloverInactiveMonthDayStyle());
        c.setSelectedDayStyle(dateChooser.getSelectedDayStyle());
        c.setRolloverSelectedDayStyle(dateChooser.getRolloverSelectedDayStyle());
        c.setTodayStyle(dateChooser.getTodayStyle());
        c.setRolloverTodayStyle(dateChooser.getRolloverTodayStyle());
        c.setDisabledDayStyle(dateChooser.getDisabledDayStyle());
        c.setRolloverDisabledDayStyle(dateChooser.getRolloverDisabledDayStyle());
        c.setWeekendDayStyle(dateChooser.getWeekendDayStyle());
        c.setRolloverWeekendDayStyle(dateChooser.getRolloverWeekendDayStyle());
        c.setDaysHeaderStyle(dateChooser.getDaysHeaderStyle());
        c.setHeaderStyle(dateChooser.getHeaderStyle());
        c.setFooterStyle(dateChooser.getFooterStyle());

        c.setStyleClass(dateChooser.getCalendarClass());
        c.setDayClass(dateChooser.getDayClass());
        c.setRolloverDayClass(dateChooser.getRolloverDayClass());
        c.setInactiveMonthDayClass(dateChooser.getInactiveMonthDayClass());
        c.setRolloverInactiveMonthDayClass(dateChooser.getRolloverInactiveMonthDayClass());
        c.setSelectedDayClass(dateChooser.getSelectedDayClass());
        c.setRolloverSelectedDayClass(dateChooser.getRolloverSelectedDayClass());
        c.setTodayClass(dateChooser.getTodayClass());
        c.setRolloverTodayClass(dateChooser.getRolloverTodayClass());
        c.setDisabledDayClass(dateChooser.getDisabledDayClass());
        c.setRolloverDisabledDayClass(dateChooser.getRolloverDisabledDayClass());
        c.setWeekendDayClass(dateChooser.getWeekendDayClass());
        c.setRolloverWeekendDayClass(dateChooser.getRolloverWeekendDayClass());
        c.setDaysHeaderClass(dateChooser.getDaysHeaderClass());
        c.setHeaderClass(dateChooser.getHeaderClass());
        c.setFooterClass(dateChooser.getFooterClass());

        c.setFirstDayOfWeek(dateChooser.getFirstDayOfWeek());
        c.setShowFooter(dateChooser.isShowFooter());

        c.setFocusedStyle(dateChooser.getCalendarStyle());
        c.setFocusedClass(dateChooser.getCalendarClass());
        c.setFocusable(true);

        Locale locale = dateChooser.getLocale();
        if (locale == null) {
            Object requestObj = context.getExternalContext().getRequest();
            RequestFacade requestFacade = RequestFacade.getInstance(requestObj);
            locale = requestFacade.getLocale();
        }
        c.setLocale(locale);

        c.setTodayText(dateChooser.getTodayText());
        c.setNoneText(dateChooser.getNoneText());

        for (UIComponent child : children) {
            if (child instanceof DateRanges) {
                c.getChildren().add(child);
            }
        }

        popup.setCalendar(c);
View Full Code Here


    public void setPopupCalendarEnabled(boolean popupCalendarEnabled) {
        this.popupCalendarEnabled = popupCalendarEnabled;
    }

    public Calendar getPopupCalendar() {
        Calendar calendar = Components.getOrCreateFacet(
                getFacesContext(), this, Calendar.COMPONENT_TYPE, "popupCalendar", Calendar.class);
        return calendar;
    }
View Full Code Here

            writer.write(dateFormat.format(timetableView.getDay()));

            writer.endElement("div");

            if (daySwitcher.isPopupCalendarEnabled()) {
                Calendar calendar = daySwitcher.getPopupCalendar();
                calendar.setRequired(true);
                calendar.setValue(new Date());
                calendar.setLocale(daySwitcher.getLocale());
                calendar.setTimeZone(daySwitcher.getTimeZone());
                calendar.setId(switcher.getId() + TimePeriodSwitcherRenderer.CALENDAR_SUFFIX);
                SimplePopup popup = new SimplePopup("o_daySwitcherPopup", calendar);
                popup.setId(switcher.getId() + TimePeriodSwitcherRenderer.POPUP_SUFFIX);
                try {
                    popup.encodeAll(context);
                } catch (IOException e) {
View Full Code Here

    public static final String HIDE_DEFAULT_FOCUS_KEY = "hideDefaultFocusStyle";

    @Override
    public void decode(FacesContext context, UIComponent component) {
        Map<String, String> params = context.getExternalContext().getRequestParameterMap();
        Calendar calendar = ((Calendar) component);
        String newValue = params.get(component.getClientId(context) + VALUE_DATE_HOLDER_SUFFIX);
        if (null != newValue) {
            calendar.setSubmittedValue(newValue);
        }
    }
View Full Code Here

        if (AjaxUtil.getSkipExtraRenderingOnPortletsAjax(context))
            return;

        Components.generateIdIfNotSpecified(component);

        Calendar calendar = (Calendar) component;
        Rendering.registerDateTimeFormatObject(calendar.getLocale());

        String clientId = component.getClientId(context);
        ResponseWriter writer = context.getResponseWriter();
        writer.startElement("table", calendar);
        context.getResponseWriter().writeAttribute("id", clientId, null);
        Rendering.writeStandardEvents(writer, calendar);

        writeAttribute(writer, "cellpadding", "0");
        writeAttribute(writer, "cellspacing", "0");
        writeAttribute(writer, "border", "0");

        String calendarStyleClass = Styles.getCSSClass(context, calendar, calendar.getStyle(), StyleGroup.regularStyleGroup(), calendar.getStyleClass(),
                getDefaultClass());

        if (calendar.isDisabled()) {
            String disabledCalendarStyleClass = Styles.getCSSClass(context, calendar, calendar.getDisabledStyle(),
                    StyleGroup.disabledStyleGroup(), calendar.getDisabledClass(), null);

            if (Rendering.isNullOrEmpty(calendar.getDisabledStyle()) && Rendering.isNullOrEmpty(calendar.getDisabledClass())) {
                calendarStyleClass = Styles.mergeClassNames(disabledCalendarStyleClass, calendarStyleClass);
            } else {
                calendarStyleClass = Styles.mergeClassNames(disabledCalendarStyleClass, Styles.getCSSClass(context, calendar, null
                        , StyleGroup.regularStyleGroup(), null, getDefaultClass()));
            }
        }
        calendarStyleClass = Styles.mergeClassNames(DefaultStyles.CLASS_INITIALLY_INVISIBLE, calendarStyleClass);
        writeAttribute(writer, "class", calendarStyleClass);

        writer.startElement("col", calendar);
        writer.writeAttribute("id", clientId + Rendering.CLIENT_ID_SUFFIX_SEPARATOR + "col", null);
        writer.writeAttribute("span", "7", null);
        writer.writeAttribute("class", "o_calendarCol", null);
        writer.endElement("col");

        renderHeader(context, calendar);
        renderBody(context, calendar);
        if (calendar.isShowFooter())
            renderFooter(context, calendar);
        writer.endElement("table");
    }
View Full Code Here

        }
        return result;
    }

    private void renderScriptsAndStyles(FacesContext context, UIComponent component) throws IOException {
        Calendar calendar = ((Calendar) component);

        String clientId = component.getClientId(context);
        ScriptBuilder sb = new ScriptBuilder();

        String onchange = calendar.getOnchange();
        if (onchange != null && onchange.length() > 0) {
            sb.append("O$('").append(clientId).append("').onchange = " // todo: refactor passing events into passing them as a single JSON param to the initialization function
                    "function(event) {").append(onchange).append("};\n");
        }

        String onPeriodChange = calendar.getOnperiodchange();
        if (onPeriodChange != null && onPeriodChange.length() > 0) {
            sb.append("O$('").append(clientId).append("').onperiodchange = " +
                    "function(event) {").append(onPeriodChange).append("};\n");
        }

        TimeZone timeZone = (calendar.getTimeZone() != null)
                ? calendar.getTimeZone()
                : TimeZone.getDefault();
        String selectedDateParam = null;
        Date selectedDate = (Date) calendar.getValue();
        if (selectedDate != null) {
            selectedDateParam = DataUtil.formatDateForJs(selectedDate, timeZone);
        }

        Date todayDate = java.util.Calendar.getInstance().getTime();
        String todayDateStr = DataUtil.formatDateForJs(todayDate, timeZone);

        String focusedClassStr;
        if (calendar.getAttributes().get(HIDE_DEFAULT_FOCUS_KEY) == null)
            focusedClassStr = Rendering.getFocusedClass(context, calendar);
        else
            focusedClassStr = Styles.getCSSClass(context, calendar, calendar.getFocusedStyle(), StyleGroup.selectedStyleGroup(), calendar.getFocusedClass(), getDefaultClass());

        Script rangesArray = getJSDateRangesArray(context, calendar);

        sb.initScript(context, calendar, "O$.Calendar._init",
                selectedDateParam,
                todayDateStr,
                Rendering.getRolloverClass(context, calendar),
                calendar.isFocusable(),
                focusedClassStr,
                getStyleClassesWithFont(context, calendar.getDayStyle(), calendar.getDayClass(), DEFAULT_DAY_CLASS, calendar),
                new StyleParam(calendar, "rolloverDay", DEFAULT_ROLLOVER_DAY_CLASS, StyleGroup.rolloverStyleGroup()),
                new StyleParam(calendar, "inactiveMonthDay", DEFAULT_INACTIVE_MONTH_DAY_CLASS, StyleGroup.regularStyleGroup(3)),
                new StyleParam(calendar, "rolloverInactiveMonthDay", DEFAULT_ROLLOVER_INACTIVE_MONTH_DAY_CLASS, StyleGroup.rolloverStyleGroup(3)),
                Styles.getCSSClass_dontCascade(context, component, calendar.getSelectedDayStyle(), StyleGroup.selectedStyleGroup(), calendar.getSelectedDayClass(), DefaultStyles.getDefaultSelectionStyle()),
                new StyleParam(calendar, "rolloverSelectedDay", DEFAULT_ROLLOVER_SELECTED_DAY_CLASS, StyleGroup.selectedStyleGroup(1)),
                new StyleParam(calendar, "today", DEFAULT_TODAY_CLASS, StyleGroup.regularStyleGroup(5)),
                new StyleParam(calendar, "rolloverToday", DEFAULT_ROLLOVER_TODAY_CLASS, StyleGroup.rolloverStyleGroup(5)),
                new StyleParam(calendar, "weekendDay", DEFAULT_WEEKEND_DAY_CLASS, StyleGroup.regularStyleGroup(2)),
                new StyleParam(calendar, "rolloverWeekendDay", DEFAULT_ROLLOVER_WEEKEND_DAY_CLASS, StyleGroup.rolloverStyleGroup(2)),
                new StyleParam(calendar, "disabledDay", DEFAULT_DISABLED_DAY_CLASS, StyleGroup.rolloverStyleGroup(2)),
                new StyleParam(calendar, "rolloverDisabledDay", DEFAULT_ROLLOVER_DISABLED_DAY_CLASS, StyleGroup.rolloverStyleGroup()),
                calendar.getFirstDayOfWeek() - 1, // in JS Date object first day is less by one that in corresponding Java object

                getStyleClassesWithFont(context, calendar.getHeaderStyle(), calendar.getHeaderClass(), DEFAULT_HEADER_CLASS, calendar),

                rangesArray,
                calendar.isShowFooter(),
                calendar.getLocale().toString(),
                calendar.isRequired(),
                calendar.isDisabled(),
                isAuxiliaryTagsRenderedInFooter(calendar),
                clientId + VALUE_HOLDER_SUFFIX,
                Rendering.convertToString(context, calendar, calendar.getValue()),
                clientId + BODY_SUFFIX
        );

        Styles.renderStyleClasses(context, calendar);
        Rendering.renderInitScript(context, sb,
View Full Code Here

    }

    @Override
    public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException {
        Date convertedValue = (Date) Rendering.convertFromString(context, (Calendar) component, (String) submittedValue);
        Calendar calendar = (Calendar) component;
        boolean keepTime = calendar.isKeepTime();
        if (!keepTime) {
            return convertedValue;
        }
        Date currentValue = (Date) calendar.getValue();
        TimeZone timeZone = calendar.getTimeZone();
        DataUtil.copyDateKeepingTime(convertedValue, currentValue, timeZone);
        return currentValue;
    }
View Full Code Here

TOP

Related Classes of org.openfaces.component.calendar.Calendar

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.